mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
feat: allow configurable username claim field in OIDC (#5507)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
This commit is contained in:
@ -198,6 +198,9 @@ type OIDCConfig struct {
|
||||
// IgnoreEmailVerified allows ignoring the email_verified claim
|
||||
// from an upstream OIDC provider. See #5065 for context.
|
||||
IgnoreEmailVerified bool
|
||||
// UsernameField selects the claim field to be used as the created user's
|
||||
// username.
|
||||
UsernameField string
|
||||
}
|
||||
|
||||
func (api *API) userOIDC(rw http.ResponseWriter, r *http.Request) {
|
||||
@ -236,7 +239,7 @@ func (api *API) userOIDC(rw http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
return
|
||||
}
|
||||
usernameRaw, ok := claims["preferred_username"]
|
||||
usernameRaw, ok := claims[api.OIDCConfig.UsernameField]
|
||||
var username string
|
||||
if ok {
|
||||
username, _ = usernameRaw.(string)
|
||||
|
Reference in New Issue
Block a user