Support nonce parameter in ID tokens#74
Merged
Merged
Conversation
When a client sends a nonce in the authorization request, it is now stored with the authorization code and included in the ID token. This allows clients to mitigate token injection attacks by verifying the nonce matches what they originally sent. The nonce flows through: - authorize → login form (hidden field) → authorization code (DB) - authorization code → token exchange → ID token claims - MFA pending session also stores nonce for the MFA flow Changes: - Migration 000008: adds nonce column to oauth_authorization_codes and auth_mfa_pending - Updated sqlc queries and regenerated code - Added Nonce field to IDTokenClaims, LoginPageData - Threaded nonce through generateAuthorizationCode, generateTokens, writeTokenResponse, and the login/MFA handlers - Added nonce hidden field to login.html template When nonce is not provided (the common case for existing clients), the field is omitted from the ID token via omitempty — fully backwards compatible. Closes #55. Co-Authored-By: Claude Opus 4.6 (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
Implements OIDC nonce support per OIDC Core Section 3.1.2.1. When a client sends a
nonceparameter in the authorization request, it is stored with the authorization code and included in the ID token. This allows clients to mitigate token injection attacks by verifying the nonce matches what they originally sent.nonceis not provided (the common case for all existing clients), the claim is omitted from the ID token viaomitemptyauth_mfa_pending)Changes
noncecolumn tooauth_authorization_codesandauth_mfa_pendingInsertAuthorizationCodeandCreateMFAPendingto include noncegenerateAuthorizationCode,generateTokens,writeTokenResponse, login handler, MFA handlerNoncefield toIDTokenClaimsTest plan
TestIDTokenIncludesNonce— sends nonce in authorize, verifies it appears in the ID token (written red/green TDD)TestIDTokenOmitsNonceWhenNotProvided— verifies no nonce claim when not sentCloses #55.
🤖 Generated with Claude Code