Skip to content

fix(api): Allow Bearer token auth for GET /api/0/auth/#112853

Open
BYK wants to merge 2 commits intomasterfrom
BYK/fix/auth-index-bearer-token
Open

fix(api): Allow Bearer token auth for GET /api/0/auth/#112853
BYK wants to merge 2 commits intomasterfrom
BYK/fix/auth-index-bearer-token

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Apr 13, 2026

GET /api/0/auth/ returns 400 for valid Authorization: Bearer <token> requests
because BaseAuthIndexEndpoint overrides authentication_classes to only
(QuietBasicAuthentication, SessionAuthentication), excluding UserAuthTokenAuthentication.

This adds an initialize_request override on AuthIndexEndpoint that conditionally
prepends UserAuthTokenAuthentication for GET requests only. POST (login), PUT (sudo),
and DELETE (logout) retain session-only auth since they are session-management operations
where Bearer token auth is inappropriate.

Fixes #112778

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 13, 2026
@BYK BYK marked this pull request as ready for review April 13, 2026 20:55
@BYK BYK force-pushed the BYK/fix/auth-index-bearer-token branch from fb6c27e to 08792d1 Compare April 13, 2026 20:55
@BYK BYK requested a review from a team as a code owner April 13, 2026 20:55
BaseAuthIndexEndpoint restricts authentication_classes to only
QuietBasicAuthentication and SessionAuthentication, which excludes
UserAuthTokenAuthentication. This causes GET /api/0/auth/ to return
400 for valid Bearer tokens since DRF treats the request as anonymous.

Override initialize_request on AuthIndexEndpoint to conditionally add
UserAuthTokenAuthentication for GET requests only. POST/PUT/DELETE
retain the original session-only auth since they are session management
operations where Bearer token auth is inappropriate.

Fixes GH-112778
Co-Authored-By: Claude Sonnet 4 <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.

AuthIndexEndpoint returns 400 for valid Bearer token auth (missing UserAuthTokenAuthentication)

1 participant