Skip to content

Commit

Permalink
Do not fail when uid/gid are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Apr 20, 2022
1 parent 0642bd6 commit fb106b7
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions pkg/auth/manager/oidc/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,11 @@ func (am *mgr) Authenticate(ctx context.Context, clientID, clientSecret string)
if claims["email"] == nil {
return nil, nil, fmt.Errorf("no \"email\" attribute found in userinfo: maybe the client did not request the oidc \"email\"-scope")
}
if uid, ok := claims[am.c.UIDClaim].(float64); ok {
claims[am.c.UIDClaim] = int64(uid)
} else {
return nil, nil, fmt.Errorf("malformed or missing uid claim in userinfo: '%v'", claims[am.c.UIDClaim])
}
if gid, ok := claims[am.c.GIDClaim].(float64); ok {
claims[am.c.GIDClaim] = int64(gid)
} else {
return nil, nil, fmt.Errorf("malformed or missing gid claim in userinfo: '%v'", claims[am.c.GIDClaim])
}

uid, _ := claims[am.c.UIDClaim].(float64)
claims[am.c.UIDClaim] = int64(uid) // in case the uid claim is missing, resolveUser() should populate it
gid, _ := claims[am.c.GIDClaim].(float64)
claims[am.c.GIDClaim] = int64(gid)

err = am.resolveUser(ctx, claims)
if err != nil {
Expand Down

0 comments on commit fb106b7

Please sign in to comment.