auth: add AllowMissingExpiration option to RequireBearerTokenOptions#971
Open
BorisTyshkevich wants to merge 1 commit into
Open
auth: add AllowMissingExpiration option to RequireBearerTokenOptions#971BorisTyshkevich wants to merge 1 commit into
BorisTyshkevich wants to merge 1 commit into
Conversation
Some IdPs emit session-bound bearer tokens that do not carry a standalone `exp` claim — the token's lifetime is bounded by an external session and is not advertised in-band. Resource servers integrating with such IdPs need to opt in to validating the rest of the token (scopes, signature via the verifier callback) without requiring the expiration field to be present. Adds an AllowMissingExpiration bool to RequireBearerTokenOptions. Default false preserves the existing strict behaviour. When true, a TokenInfo with a zero Expiration is accepted; non-zero expirations are still checked for elapsed validity. Extends TestVerify with a "no expiration with AllowMissingExpiration accepts" case mirroring the existing strict-reject case. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 tasks
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
AllowMissingExpiration boolfield toRequireBearerTokenOptionsthat opts the middleware out of the existingtokenInfo.Expiration.IsZero()reject.Motivation
Some IdPs emit session-bound bearer tokens that do not carry a standalone
expclaim — the token's lifetime is bounded by an external session and is not advertised in-band. Resource servers integrating with such IdPs today have to synthesise a fake Expiration from their TokenVerifier callback (dishonest data through the auth layer) or forkRequireBearerTokento bypass the check.This option lets the verifier honestly report "no expiration in the token" via a zero
Expirationand have the middleware accept it — while still applying the elapsed-validity check for tokens that DO carry an Expiration.