mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-07 04:40:05 -06:00
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:
6
changelog/unreleased/user-claim-fallback.md
Normal file
6
changelog/unreleased/user-claim-fallback.md
Normal file
@@ -0,0 +1,6 @@
|
||||
Change: OIDC: fallback if IDP doesn't provide "preferred_username" claim
|
||||
|
||||
Some IDPs don't add the "preferred_username" claim. Fallback to the "email"
|
||||
claim in that case
|
||||
|
||||
https://github.com/owncloud/ocis/issues/2644
|
||||
@@ -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