Skip to content

Commit 6c3e879

Browse files
committed
Do not fail when uid/gid are missing
1 parent 0642bd6 commit 6c3e879

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

pkg/auth/manager/oidc/oidc.go

+6-10
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,12 @@ func (am *mgr) Authenticate(ctx context.Context, clientID, clientSecret string)
198198
if claims["email"] == nil {
199199
return nil, nil, fmt.Errorf("no \"email\" attribute found in userinfo: maybe the client did not request the oidc \"email\"-scope")
200200
}
201-
if uid, ok := claims[am.c.UIDClaim].(float64); ok {
202-
claims[am.c.UIDClaim] = int64(uid)
203-
} else {
204-
return nil, nil, fmt.Errorf("malformed or missing uid claim in userinfo: '%v'", claims[am.c.UIDClaim])
205-
}
206-
if gid, ok := claims[am.c.GIDClaim].(float64); ok {
207-
claims[am.c.GIDClaim] = int64(gid)
208-
} else {
209-
return nil, nil, fmt.Errorf("malformed or missing gid claim in userinfo: '%v'", claims[am.c.GIDClaim])
210-
}
201+
202+
uid, _ := claims[am.c.UIDClaim].(float64)
203+
claims[am.c.UIDClaim] = int64(uid) // in case the uid claim is missing, resolveUser() should populate it
204+
// Note that if not, will silently carry a user with 0 uid, potentially problematic with storage providers
205+
gid, _ := claims[am.c.GIDClaim].(float64)
206+
claims[am.c.GIDClaim] = int64(gid)
211207

212208
err = am.resolveUser(ctx, claims)
213209
if err != nil {

0 commit comments

Comments
 (0)