Skip to content

fix(preprod): Restore full token authentication on retention endpoint#109842

Merged
NicoHinderling merged 1 commit intomasterfrom
fix/preprod-retention-auth-order
Mar 3, 2026
Merged

fix(preprod): Restore full token authentication on retention endpoint#109842
NicoHinderling merged 1 commit intomasterfrom
fix/preprod-retention-auth-order

Conversation

@NicoHinderling
Copy link
Contributor

@NicoHinderling NicoHinderling commented Mar 3, 2026

Making sure we can hit the retention endpoint from CLI

https://linear.app/getsentry/issue/EME-855/wire-up-snapshots-retention-in-retention-api

Add OrgAuthTokenAuthentication and reorder authentication_classes on
OrganizationPreprodRetentionEndpoint so token classes come before
SessionAuthentication.

Previously, SessionAuthentication was listed before UserAuthTokenAuthentication.
When a request carried both session cookies and a Bearer token (e.g. from a browser
with an active Sentry session), session auth would win, set request.auth = None,
and trigger the SSO check — returning a spurious 401 sso-required error. Token
auth never got a chance to run.

The fix matches the ordering used by DEFAULT_AUTHENTICATION in src/sentry/api/base.py:
token classes first, session auth last as a fallback.

Add OrgAuthTokenAuthentication and reorder authentication_classes so
token classes come before SessionAuthentication. Previously, session
auth could win over token auth when both cookies and a Bearer token
were present, causing spurious 401 sso-required errors.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 3, 2026
@NicoHinderling NicoHinderling marked this pull request as ready for review March 3, 2026 22:20
@NicoHinderling NicoHinderling requested a review from a team as a code owner March 3, 2026 22:20
@NicoHinderling NicoHinderling enabled auto-merge (squash) March 3, 2026 22:24
@NicoHinderling NicoHinderling merged commit 718f636 into master Mar 3, 2026
79 checks passed
@NicoHinderling NicoHinderling deleted the fix/preprod-retention-auth-order branch March 3, 2026 22:44
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