Keycloak provider - Retain user and prefered_username in session (#1815)
* Keycloak provider - Retain user and prefered_username in session * Add CHANGELOG for PR #1815
This commit is contained in:
parent
ece3d62d64
commit
5b5894af07
@ -41,6 +41,7 @@ to remain consistent with CLI flags. You should specify `code_challenge_method`
|
||||
- [#1750](https://github.com/oauth2-proxy/oauth2-proxy/pull/1750) Fix Nextcloud provider
|
||||
- [#1574](https://github.com/oauth2-proxy/oauth2-proxy/pull/1574) Add Azure groups support and Azure OAuth v2.0 (@adriananeci)
|
||||
- [#1851](https://github.com/oauth2-proxy/oauth2-proxy/pull/1851) Bump golang to 1.19 and min allowed version to 1.18
|
||||
- [#1815](https://github.com/oauth2-proxy/oauth2-proxy/pull/1815) Keycloak: save user and preferredUsername in session to populate headers for the backend (@babs)
|
||||
|
||||
# V7.3.0
|
||||
|
||||
|
@ -98,6 +98,20 @@ func (p *KeycloakProvider) EnrichSession(ctx context.Context, s *sessions.Sessio
|
||||
}
|
||||
s.Email = email
|
||||
|
||||
preferredUsername, err := json.Get("preferred_username").String()
|
||||
if err == nil {
|
||||
s.PreferredUsername = preferredUsername
|
||||
}
|
||||
|
||||
user, err := json.Get("user").String()
|
||||
if err == nil {
|
||||
s.User = user
|
||||
}
|
||||
|
||||
if s.User == "" && s.PreferredUsername != "" {
|
||||
s.User = s.PreferredUsername
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user