Skip to content

feat(vercel): Rate limit extra API authentication per org - #127459

Merged
scttcper merged 1 commit into
masterfrom
scttcper/vercel-build-token-rate-limits
Oct 16, 2026
Merged

scttcper merged 1 commit into
masterfrom
scttcper/vercel-build-token-rate-limits

Conversation

@scttcper

@scttcper scttcper commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

AuthenticationMiddleware doesn't know about SENTRY_EXTRA_API_AUTHENTICATION (#127086), so getsentry's Vercel build tokens get rate limited per IP instead of per org like the token they replace.

The middleware now tries those classes first, and get_rate_limit_key uses the token's org when there's no ApiToken row. No change without getsentry, tested end to end in getsentry/getsentry#22522.

refs https://linear.app/getsentry/issue/IE-89/rate-limit-vercel-build-tokens-per-org-not-per-ip

getsentry's Vercel build tokens are only recognized by DRF, so
AuthenticationMiddleware treated them as anonymous and rate limiting
keyed them by IP. The middleware now tries SENTRY_EXTRA_API_AUTHENTICATION
first, and get_rate_limit_key uses the token's org when there's no
ApiToken row behind it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Oct 14, 2026

Copy link
Copy Markdown

IE-89

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 14, 2026
@scttcper scttcper changed the title fix(ratelimit): Rate limit extra API authentication per org feat(vercel): Rate limit extra API authentication per org Oct 14, 2026
@scttcper
scttcper marked this pull request as ready for review October 14, 2026 22:43
@scttcper
scttcper requested a review from a team as a code owner October 14, 2026 22:43
@scttcper
scttcper requested review from markstory and removed request for a team October 14, 2026 22:43

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a624ee1. Configure here.

AgentTokenAuthentication,
ApiKeyAuthentication,
):
for authenticator_class in TOKEN_AUTHENTICATION:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Middleware stops on extra-auth None

High Severity

The middleware returns after the first authenticator whose accepts_auth is true and treats a None result as anonymous. Extra API authenticators are documented to return None for unrecognized credentials so later classes can run. Regular Bearer tokens can then be rate-limited by IP instead of by user or org.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a624ee1. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an issue here: getsentry’s class only accepts JWTs from Vercel’s issuer in accepts_auth, so other bearer tokens still reach UserAuthTokenAuthentication.

@scttcper
scttcper merged commit 6a44aa5 into master Oct 16, 2026
97 checks passed
@scttcper
scttcper deleted the scttcper/vercel-build-token-rate-limits branch October 16, 2026 19:14
RudraPatel2003 pushed a commit that referenced this pull request Oct 19, 2026
`AuthenticationMiddleware` doesn't know about
`SENTRY_EXTRA_API_AUTHENTICATION` (#127086), so getsentry's Vercel build
tokens get rate limited per IP instead of per org like the token they
replace.

The middleware now tries those classes first, and `get_rate_limit_key`
uses the token's org when there's no `ApiToken` row. No change without
getsentry, tested end to end in getsentry/getsentry#22522.

refs
https://linear.app/getsentry/issue/IE-89/rate-limit-vercel-build-tokens-per-org-not-per-ip

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants