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:
Damien Degois 2022-10-24 09:47:59 +02:00 committed by GitHub
parent ece3d62d64
commit 5b5894af07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -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

View File

@ -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
}