Preserve nonce through login page; allow GET on end_session_endpoint#77
Merged
Conversation
HandleLoginGet was not reading the nonce from the query string, so when an unauthenticated user was redirected from /oauth/authorize to the login form the rendered hidden input was empty. The POST then submitted an empty nonce, the resulting ID token had no nonce claim, and clients like authlib rejected the token for failing nonce validation. Consent and MFA already preserved nonce correctly — HandleLoginGet was the lone outlier. Also register GET on /oauth/logout so the endpoint advertised as end_session_endpoint in the OIDC discovery document works when browsers navigate to it via redirect, per OIDC RP-Initiated Logout 1.0. Co-Authored-By: Claude Opus 4.7 (1M context) <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
HandleLoginGetwasn't readingnoncefrom the query string, so when an unauthenticated user was redirected from/oauth/authorize→/oauth/loginthe rendered hidden input was empty. The form POST submitted an empty nonce, the ID token was issued without thenonceclaim (due toomitempty), and authlib-based clients (e.g. asset_manager) rejected the token for failing nonce validation. Consent and MFA flows already preserved nonce —HandleLoginGetwas the lone outlier./oauth/logoutis advertised asend_session_endpointin OIDC discovery, but was registered as POST-only. Added GET so browser redirects per OIDC RP-Initiated Logout 1.0 actually work.Test plan
go test ./...passesTestLoginGetPreservesNonceasserts the login form renders the nonce from the query stringTestIDTokenIncludesNonceThroughBrowserFlowwalks the full browser flow (authorize → login GET → login POST → authorize → consent → token) and verifies the nonce appears in the issued ID tokenTestLogoutAcceptsGETverifies GET on/oauth/logoutreturns 302 instead of 404/405🤖 Generated with Claude Code