fix(oidc): guard against zero/negative token expiry in session TTL#92
Open
s0up4200 wants to merge 2 commits into
Open
fix(oidc): guard against zero/negative token expiry in session TTL#92s0up4200 wants to merge 2 commits into
s0up4200 wants to merge 2 commits into
Conversation
When an OIDC provider returns a token without expires_in (or with an already-past expiry), token.Expiry is the Go zero time, making time.Until() return a large negative duration. This caused sessions to be stored with an already-expired TTL and cookies with a negative max-age, resulting in an infinite redirect loop on /login after successful authentication. Fall back to a 24h TTL when the computed session TTL is non-positive. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
expires_in(or with an already-past expiry),token.Expiryis the Go zero time, makingtime.Until()return a large negative duration/loginafter successful authentication with the OIDC providerDetails
The OIDC callback handler used
time.Until(token.Expiry)in three places:ExpiresAtfield inSessionDatamax-ageIf the provider omits
expires_infrom the token response, theoauth2library leavesToken.Expiryas the zero value (0001-01-01T00:00:00Z).time.Until(zeroTime)produces a massive negative duration, causing:Get())Observed with Authentik as the OIDC provider — after successful authentication, the frontend's
/api/auth/oidc/verifycall would find no session, triggering a redirect loop.🤖 Generated with Claude Code