Repository navigation
Add jose typ package and authn scope and retry error fields - #506
Merged
Merged
Conversation
This was referenced Nov 11, 2026
Add package jose with the JOSE typ constants, IsJOSEType and IsIDJAG, and its CLAUDE.md and README rows. In authn, add CodeInsufficientScope, ReasonScope, Code.HTTPStatus, and the Error retryAfter and scopes fields with RetryAfter and RequiredScopes. Also add (*Error).HTTPStatus, (*Error).MissingCredentials and ReasonUnsupportedScheme. Code.HTTPStatus maps by Code alone, so it answers 400 for every ParseBearer failure, including a request with no credentials. RFC 6750 section 3.1 says a request that lacks authentication information, including one using an unsupported authentication method, should get 401 with a bare WWW-Authenticate: Bearer challenge and no error code. MissingCredentials is true for ReasonMissingHeader and ReasonUnsupportedScheme, and (*Error).HTTPStatus returns 401 for those and Code.HTTPStatus otherwise. Behaviour change: a non-Bearer Authorization scheme now reports ReasonUnsupportedScheme instead of ReasonMalformed. The Code stays CodeInvalidRequest. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jhrozek
force-pushed
the
ts-01-wp2-jose-errors
branch
from
November 11, 2026 23:46
629f161 to
02a6f0b
Compare
This was referenced Nov 11, 2026
rdimitrov
approved these changes
Nov 19, 2026
rdimitrov
left a comment
Member
There was a problem hiding this comment.
LGTM. The jose package is small and stdlib-only, and the MissingCredentials/(*Error).HTTPStatus split gets the RFC 6750 §3.1 case right. Reporting a non-Bearer scheme as ReasonUnsupportedScheme is a sensible behaviour change.
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.
Summary
jose: the JOSEtypconstants,IsJOSETypeandIsIDJAG(stdlib only), plus its CLAUDE.md and README rows.authn, addCodeInsufficientScope,ReasonScope,Code.HTTPStatus, and theErrorretry-after and required-scopes fields withRetryAfterandRequiredScopes.(*Error).HTTPStatusand(*Error).MissingCredentials, andReasonUnsupportedScheme.Code.HTTPStatusmaps byCodealone, so it would answer 400 for a request with no credentials; RFC 6750 §3.1 wants 401 with a bareWWW-Authenticate: Bearerchallenge and no error code, also when the client used an unsupported scheme.(*Error).HTTPStatusreturns 401 for those cases andCode.HTTPStatusotherwise.ParseBearerreports a non-Bearer scheme (e.g.Basic …) asReasonUnsupportedSchemeinstead ofReasonMalformed. TheCodestaysinvalid_request.First PR of a stack that prepares
authnfor verifying tokens from several issuers.Stack: #506 (jose, errors) → #507 (verify/accept) → #508 (checks) → #509 (scopes, algs) → #510 (JWKS close race) → #511 (ProviderOnly) → #514 (TrustSet) → #515 (guards)
Test plan
go vet ./...go test -race ./authn/... ./jose/...(incl.TestErrorMissingCredentialsAndHTTPStatusand newParseBearerscheme cases)🤖 Generated with Claude Code