{"record":{"id":"bdeaaf9745269c6c","repo":"goharbor/harbor","slug":"failed-to-get-userinfo-from-both-remote-and-id-tok","errorCode":null,"errorMessage":"failed to get userinfo from both remote and ID token","messagePattern":"failed to get userinfo from both remote and ID token","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"src/pkg/oidc/helper.go","lineNumber":315,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\tremote, err := userInfoFromRemote(ctx, token, *setting)\n\tif err != nil {\n\t\tlog.Warningf(\"Failed to get userInfo by calling remote userinfo endpoint, error: %v \", err)\n\t}\n\tif remote != nil && local != nil {\n\t\tif remote.Subject != local.Subject {\n\t\t\treturn 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)\n\t\t}\n\t\treturn mergeUserInfo(remote, local), nil\n\t} else if remote != nil && local == nil {\n\t\treturn remote, nil\n\t} else if local != nil && remote == nil {\n\t\tlog.Debugf(\"Fall back to user data from ID token.\")\n\t\treturn local, nil\n\t}\n\treturn nil, fmt.Errorf(\"failed to get userinfo from both remote and ID token\")\n}\n\nfunc mergeUserInfo(remote, local *UserInfo) *UserInfo {\n\tres := &UserInfo{\n\t\t// data only contained in ID token\n\t\tSubject: local.Subject,\n\t\tIssuer:  local.Issuer,\n\t\t// Used data from userinfo\n\t\tEmail: remote.Email,\n\t}\n\t// priority for username (high to low):\n\t// 1. Username based on the auto onboard claim from ID token\n\t// 2. Username from response of userinfo endpoint\n\t// 3. Username from the default \"name\" claim from ID token\n\tif local.autoOnboardUsername != \"\" {\n\t\tres.Username = local.autoOnboardUsername\n\t} else if remote.Username != \"\" {\n\t\tres.Username = remote.Username","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/pkg/oidc/helper.go#L297-L333","documentation":"Error \"failed to get userinfo from both remote and ID token\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/pkg/oidc/helper.go:315 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}