diff options
author | SimonErm <33630884+SimonErm@users.noreply.github.com> | 2024-04-16 07:41:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-16 05:41:39 +0000 |
commit | 6ba0c371c21237376c292ee92ec067b4a1ef1218 (patch) | |
tree | 6a889f172aa44cb4a49d1ad4739e30b41735175c /modules | |
parent | cf9061f44a439aa7775e301a7467dbda22a06eaa (diff) | |
download | gitea-6ba0c371c21237376c292ee92ec067b4a1ef1218.tar.gz gitea-6ba0c371c21237376c292ee92ec067b4a1ef1218.zip |
Allow `preferred_username` as username source for OIDC (#30454)
This PR adds the preferred_username claim as a possible username source
for the oauth2_client.
Closes #21518
Diffstat (limited to 'modules')
-rw-r--r-- | modules/setting/oauth2.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/modules/setting/oauth2.go b/modules/setting/oauth2.go index 830472db32..6930197b22 100644 --- a/modules/setting/oauth2.go +++ b/modules/setting/oauth2.go @@ -22,11 +22,13 @@ const ( OAuth2UsernameNickname OAuth2UsernameType = "nickname" // OAuth2UsernameEmail username of oauth2 email field will be used as gitea name OAuth2UsernameEmail OAuth2UsernameType = "email" + // OAuth2UsernameEmail username of oauth2 preferred_username field will be used as gitea name + OAuth2UsernamePreferredUsername OAuth2UsernameType = "preferred_username" ) func (username OAuth2UsernameType) isValid() bool { switch username { - case OAuth2UsernameUserid, OAuth2UsernameNickname, OAuth2UsernameEmail: + case OAuth2UsernameUserid, OAuth2UsernameNickname, OAuth2UsernameEmail, OAuth2UsernamePreferredUsername: return true } return false |