Skip to content

Commit d0695a4

Browse files
authored
Make sure to respect the IDClaim override (#4650)
1 parent ef2c198 commit d0695a4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/auth/manager/oidc/oidc.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,17 @@ func (am *mgr) isIssuerAllowed(issuer string) bool {
185185
}
186186

187187
func (am *mgr) doUserMapping(tkn *oidc.IDToken, claims jwt.MapClaims) (string, error) {
188+
var sub = tkn.Subject
189+
if am.c.IDClaim != "sub" && claims[am.c.IDClaim] != nil {
190+
sub, _ = claims[am.c.IDClaim].(string)
191+
}
188192
if len(am.oidcUsersMapping) == 0 {
189-
return tkn.Subject, nil
193+
return sub, nil
190194
}
191195
// we need the custom claims for the mapping
192196
if claims[am.c.GroupClaim] == nil {
193197
// we are required to perform a user mapping but the group claim is not available
194-
return tkn.Subject, nil
198+
return sub, nil
195199
}
196200

197201
mappings := make([]string, 0, len(am.oidcUsersMapping))

0 commit comments

Comments
 (0)