mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-02 13:01:23 +01:00
Fix a potential nil pointer issue
Signed-off-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
parent
8e7a18dc80
commit
5ea43abc67
@ -264,10 +264,6 @@ func UserInfoFromToken(ctx context.Context, token *Token) (*UserInfo, error) {
|
||||
if err != nil {
|
||||
log.Warningf("Failed to get userInfo by calling remote userinfo endpoint, error: %v ", err)
|
||||
}
|
||||
|
||||
if setting.UserClaim != "" && local.Username == "" && remote.Username == "" {
|
||||
return nil, fmt.Errorf("OIDC. Failed to recover Username from claim. Claim '%s' is invalid or not a string", setting.UserClaim)
|
||||
}
|
||||
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)
|
||||
|
@ -137,6 +137,11 @@ func (oc *OIDCController) Callback() {
|
||||
// If automatic onboard is enabled, skip the onboard page
|
||||
if oidcSettings.AutoOnboard {
|
||||
log.Debug("Doing automatic onboarding\n")
|
||||
if username == "" {
|
||||
oc.SendInternalServerError(fmt.Errorf("unable to recover username for auto onboard, username claim: %s",
|
||||
oidcSettings.UserClaim))
|
||||
return
|
||||
}
|
||||
user, onboarded := userOnboard(oc, info, username, tokenBytes)
|
||||
if onboarded == false {
|
||||
log.Error("User not onboarded\n")
|
||||
|
Loading…
Reference in New Issue
Block a user