Add email claim to ID token #7
Merged
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
Fixes the issue where the mock OAuth2 server was not returning an
emailclaim in the ID token. The ID token now includes theemailclaim along with the standard OpenID Connect claims.Changes
The
GenerateIDTokenfunction has been updated to accept anemailparameter and include it in the token claims. The email is automatically generated based on the client ID using the format{clientID}@example.com.Before
ID tokens contained only these claims:
aud,exp,iat,iss,nonce,subAfter
ID tokens now include:
aud,exp,iat,iss,nonce,sub,emailExample
When a client exchanges an authorization code for tokens with client ID
test-client, the decoded ID token payload now looks like:{ "iss": "http://localhost:8080", "sub": "user-test-client", "aud": "test-client", "exp": 1760286080, "iat": 1760282480, "nonce": "randomNonce123", "email": "[email protected]" }Testing
Files Modified
internal/jwt/jwt.go- Added email parameter toGenerateIDTokenand included email in claimsinternal/jwt/jwt_test.go- Updated tests to verify email claiminternal/handlers/token.go- Updated to generate and pass email based on client IDpkg/oauth/google.go- Updated OAuth provider to include email in ID tokensOriginal prompt
Fixes #6
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.