broker: use /userinfo as fallback for claims not available in id token#1476
Open
shiv-tyagi wants to merge 1 commit intocanonical:mainfrom
Open
broker: use /userinfo as fallback for claims not available in id token#1476shiv-tyagi wants to merge 1 commit intocanonical:mainfrom
shiv-tyagi wants to merge 1 commit intocanonical:mainfrom
Conversation
Fixes [canonical#1440](canonical#1440). This uses the information retrieved from /userinfo endpoint as a fallback for claims not available in id token. This only affects the generic oidc broker, for ms entra id, we simple drop the information retrieved from /userinfo. I have verified both oidc and msentraid brokers with these changes, they both work fine. Signed-off-by: Shiv Tyagi <shivtyagi3015@gmail.com>
7fcdce8 to
94176c9
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1476 +/- ##
==========================================
- Coverage 86.94% 80.42% -6.52%
==========================================
Files 93 20 -73
Lines 6366 1073 -5293
Branches 111 0 -111
==========================================
- Hits 5535 863 -4672
+ Misses 775 210 -565
+ Partials 56 0 -56 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
adombeck
reviewed
Apr 22, 2026
Comment on lines
+1176
to
1184
| oidcUserInfo, err := session.oidcServer.UserInfo(ctx, oauth2.StaticTokenSource(token)) | ||
| if err != nil { | ||
| log.Warningf(ctx, "could not fetch information from /userinfo endpoint: %v", err) | ||
| } | ||
|
|
||
| userInfo, err := b.provider.GetUserInfo(idToken, oidcUserInfo) | ||
| if err != nil { | ||
| return info.User{}, err | ||
| } |
Contributor
There was a problem hiding this comment.
The UserInfo request is one more network request which can go wrong, and it's not needed in most cases, so I think we should not do it unconditionally but only if the ID token is actually missing a required claim. I would implement it like this:
- First, call
b.provider.GetUserInfo(idToken) - If the ID token misses a required claim,
GetUserInfoshould return aMissingClaimError - If it does, we fetch the claims from the UserInfo endpoint and merge them with the ones from the ID token into a single
claimsstruct and then callb.provider.GetUserInfo(claims)
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.
Fixes #1440.
This uses the information retrieved from /userinfo endpoint as a fallback for claims not available in id token.
This only affects the generic oidc broker, for msentraid, we simple drop the information retrieved from /userinfo.
I have verified both oidc and msentraid brokers with these changes, they both work fine.