mirror of
https://github.com/goharbor/harbor
synced 2025-04-15 20:30:36 +00:00
fix: Store Username in auto-onboard flow
Signed-off-by: Joost Buskermolen <joost@buskervezel.nl> fix: Remove conditional & elaborate comment on fix Signed-off-by: Joost Buskermolen <joost@buskervezel.nl> Add conditional to res.Username override Signed-off-by: Joost Buskermolen <joost@buskervezel.nl> test: Set Username based on configured UserClaim Signed-off-by: Joost Buskermolen <joost@buskervezel.nl> fix: Remove breaking conditional Username may be set already if the token has a name claim. Username is should always be set as the autoOnboard setting. Signed-off-by: Joost Buskermolen <joost@buskervezel.nl> Remove conditional altogether autoOnboardUsername should always be the same as Username Signed-off-by: Joost Buskermolen <joost@buskervezel.nl>
This commit is contained in:
parent
5cd5bcaee4
commit
c103a6e9ef
|
@ -355,7 +355,10 @@ func userInfoFromClaims(c claimsProvider, setting cfgModels.OIDCSetting) (*UserI
|
|||
}
|
||||
|
||||
if username, ok := allClaims[setting.UserClaim].(string); ok {
|
||||
res.autoOnboardUsername = username
|
||||
// res.Username and autoOnboardUsername both need to be set to create a fallback when mergeUserInfo has not been successfully called.
|
||||
// This can for example occur when remote fails and only a local token is available for onboarding.
|
||||
// Otherwise the onboard flow only has a fallback when "name" is set in the token, which is not always the case as a custom Username Claim could be configured.
|
||||
res.autoOnboardUsername, res.Username = username, username
|
||||
} else {
|
||||
log.Warningf("OIDC. Failed to recover Username from claim. Claim '%s' is invalid or not a string", setting.UserClaim)
|
||||
}
|
||||
|
|
|
@ -284,7 +284,7 @@ func TestUserInfoFromClaims(t *testing.T) {
|
|||
Issuer: "",
|
||||
Subject: "",
|
||||
autoOnboardUsername: "airadier@gmail.com",
|
||||
Username: "Alvaro",
|
||||
Username: "airadier@gmail.com", // Set Username based on configured UserClaim
|
||||
Email: "airadier@gmail.com",
|
||||
Groups: []string{},
|
||||
hasGroupClaim: false,
|
||||
|
|
Loading…
Reference in New Issue
Block a user