API key verification forwards client User-Agent, causing Python urllib requests to fail
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- node.js, typescript
- Lĩnh vực
- api, authentication
Hướng nghiên cứu
The report names verifyAPIKey() and createBackendApiClient(options) in @clerk/backend, and includes a reproduction repository with an npm run repro script. Read the verification path and compare the outbound request's User-Agent with the incoming request; run the reproduction with both User-Agent values. Done when both requests authenticate successfully with the same credentials. An open linked pull request (#10358) indicates work is already underway.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Preliminary Checks
-
I have reviewed the documentation: https://clerk.com/docs
-
I have searched for existing issues: https://github.com/clerk/javascript/issues
-
I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
-
This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.
Reproduction
https://github.com/jandorn/clerk-api-key-user-agent-repro
Publishable key
pk_live_Y2xlcmsudGVsZXNjb3BlLmVuZXJneSQ
Description
Steps to reproduce:
- Clone the reproduction repository and run
npm ci. - Copy
.env.exampleto.envand configure credentials from the same Clerk instance, including a valid API key. - Run
npm run repro.
The script uses unpatched @clerk/[email protected] and calls authenticateRequest(request, { acceptsToken: 'api_key' }) twice with the same credentials. Only the incoming User-Agent changes.
Expected behavior:
Both requests authenticate successfully.
Actual behavior:
Python-urllib/3.11→ upstream HTTP 403 (text/html),isAuthenticated: false, reason:unexpected-error.clerk-api-key-repro/1.0→ upstream HTTP 200 (application/json),isAuthenticated: true.
The full live output is included in the reproduction README.
Suspected cause:
verifyAPIKey() passes the authentication context to createBackendApiClient(options). The context's incoming userAgent overrides the SDK's default User-Agent.
Using the SDK User-Agent for this outbound request resolved the issue in our application:
const client = createBackendApiClient({ ...options, userAgent: USER_AGENT });
Environment
System:
OS: macOS 27.0.1
CPU: (15) arm64 Apple M5 Pro
Memory: 75.17 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 23.11.0 - /opt/homebrew/bin/node
npm: 11.19.1 - /opt/homebrew/bin/npm
pnpm: 10.11.0 - /opt/homebrew/bin/pnpm
bun: 1.3.9 - /Users/jandorn/.bun/bin/bun
Browsers:
Chrome: 155.0.8059.85
Firefox: 144.0.2
Safari: 27.0.1
npmPackages:
@clerk/backend: 3.2.2 => 3.2.2
- Ngôn ngữ chính
- TypeScript
- Star
- 1.8k
- Fork
- 483
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 325
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của clerk/javascript
-
ClerkAPIError drops meta.lockout_expires_in_seconds from user_locked errorsCó thể đã có người làm @umeraamir69 đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
clerk/javascript#10026 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
@clerk/nextjs: onBeforeSetActive never settles when invalidateCacheAction rejects (e.g. after a redeploy), so setActive and signOut hang foreverCó thể đã có người làm @RaphaelFakhri đã nhận 21 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
clerk/javascript#9987 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 44/100
clerk/javascript#10413 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Dev instances: clerk-js rewrites __clerk_db_jwt non-atomically, concurrent requests fail with dev-browser-missingCó thể đã có người làm @umeraamir69 đã nhận 3 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
clerk/javascript#10411 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
clerk/javascript#10356 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của clerk/javascript
Issue tương tự
-
e2e-failure ready-to-code
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
redhat-developer/rhdh-plugin-export-overlays#4580 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
devdotfast/whiteboard#1415 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/sessions comp/desktop desktop/sessions P2 type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
NousResearch/hermes-agent#145383 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement p2 setup
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
vercel/eve#5419 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày