Repository navigation
fix(serveredition): accept the Bearer scheme case-insensitively for user JWTs - #1755
Merged
Dumbris merged 1 commit intoOct 26, 2026
Conversation
…ser JWTs Co-authored-by: Cursor <cursoragent@cursor.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Dumbris
approved these changes
Oct 26, 2026
Dumbris
left a comment
Member
There was a problem hiding this comment.
Verified: the PR test fails on main for the reason described and passes on this branch merged with main; race tests for the touched packages and CI lint (bare and server tags) are clean. Also built and tested together with the rest of this batch, independently reviewed, and cross-reviewed with a second model.
Member
|
Merged. Thank you, @rudycelekli! The server edition accepts user JWTs with a lower- or upper-case Bearer scheme. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
ServerEditionAuthMiddleware.authenticateFromBeareronly recognises anAuthorizationheader that starts with the exact bytesBearer. The auth-scheme name is case-insensitive (RFC 7235 §2.1, RFC 6750 §2.1), so a valid user JWT sent asbearer <jwt>orBEARER <jwt>is ignored and the request gets401 Authentication requiredon the server edition.Trigger
Build with
-tags server, log in, mint a JWT withPOST /api/v1/auth/token, then:Fix
Compare the scheme prefix with
strings.EqualFoldinstead ofstrings.HasPrefix. Nothing else changes: empty tokens and agent tokens are still skipped, and the JWT is validated exactly as before.This is the server-edition counterpart of #1754 (which fixes the core
internal/httpapiparser). The two are independent and can land in either order.Test
TestMiddleware_ValidJWT_SchemeCaseInsensitivesends a valid JWT with thebearerandBEARERschemes throughMiddleware()and checks for 200 and the rightuser_id.Commands run
CGO_ENABLED=0 go test -count=1 -tags server ./internal/serveredition/auth: ok on 3 of 4 runs. The one failing run wasTestHandleCallback_Unavailable_ProviderErrorRenders503, an OAuth-callback timing test that does not go through this middleware. It passes alone (-count=3) and passes on the other three full runs.CGO_ENABLED=0 go test -count=1 -tags server -skip TestHandleCallback_Unavailable_ProviderErrorRenders503 ./internal/serveredition/auth: okCGO_ENABLED=0 go vet -tags server ./internal/serveredition/auth: cleangit stashofmiddleware.go),-run SchemeCaseInsensitivefails withbearer: expected 200 ..., got 401andBEARER: expected 200 ..., got 401.gofmt -lon the edited files: no output