goharbor/harbor · error

failed to get userinfo from both remote and ID token

Error message

failed to get userinfo from both remote and ID token

What it means

UserInfoFromToken could obtain user info from neither source: the remote userinfo endpoint call failed (only logged as a warning) and the ID token was missing/failed to yield claims, so no identity could be established for the token.

Solutions

  1. Check why the userinfo endpoint failed (network/TLS/endpoint config) in the warning log
  2. Verify the token actually carries an ID token with claims
  3. Confirm the OIDC provider configuration (endpoint, scopes) is correct
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/pkg/oidc/helper.go:315 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16). Data as JSON: /api/errors/bdeaaf9745269c6c. Report an issue: GitHub.

Appendix: source

Thrown at src/pkg/oidc/helper.go:315

	if err != nil {
		return nil, err
	}
	remote, err := userInfoFromRemote(ctx, token, *setting)
	if err != nil {
		log.Warningf("Failed to get userInfo by calling remote userinfo endpoint, error: %v ", err)
	}
	if remote != nil && local != nil {
		if remote.Subject != local.Subject {
			return nil, fmt.Errorf("the subject from userinfo: %s does not match the subject from ID token: %s, probably a security attack happened", remote.Subject, local.Subject)
		}
		return mergeUserInfo(remote, local), nil
	} else if remote != nil && local == nil {
		return remote, nil
	} else if local != nil && remote == nil {
		log.Debugf("Fall back to user data from ID token.")
		return local, nil
	}
	return nil, fmt.Errorf("failed to get userinfo from both remote and ID token")
}

func mergeUserInfo(remote, local *UserInfo) *UserInfo {
	res := &UserInfo{
		// data only contained in ID token
		Subject: local.Subject,
		Issuer:  local.Issuer,
		// Used data from userinfo
		Email: remote.Email,
	}
	// priority for username (high to low):
	// 1. Username based on the auto onboard claim from ID token
	// 2. Username from response of userinfo endpoint
	// 3. Username from the default "name" claim from ID token
	if local.autoOnboardUsername != "" {
		res.Username = local.autoOnboardUsername
	} else if remote.Username != "" {
		res.Username = remote.Username

View on GitHub (pinned to 7b2fd08cc5)