OIDC: fallback to "email" if IDP doesn't provide "preferred_username" claim
Some IDPs (e.g. Authelia) don't add the "preferred_username" claim. Fallback to the "email" claim in that case. Fixes: #2644
This commit is contained in:
@@ -123,8 +123,12 @@ func (a accountsServiceBackend) CreateUserFromClaims(ctx context.Context, claims
|
||||
}
|
||||
}
|
||||
if req.Account.PreferredName, ok = claims[oidc.PreferredUsername].(string); !ok {
|
||||
a.logger.Warn().Msg("Missing preferred_username claim")
|
||||
} else {
|
||||
a.logger.Warn().Msg("Missing preferred_username claim, falling back to email")
|
||||
if req.Account.PreferredName, ok = claims[oidc.Email].(string); !ok {
|
||||
a.logger.Debug().Msg("Missing email claim as well")
|
||||
}
|
||||
}
|
||||
if req.Account.PreferredName != "" {
|
||||
// also use as on premises samaccount name
|
||||
req.Account.OnPremisesSamAccountName = req.Account.PreferredName
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user