Skip to content

Commit

Permalink
Merge pull request oauth2-proxy#1583 from adriananeci/groups_token_to…
Browse files Browse the repository at this point in the history
…_session

Add groups to session too when creating session from bearer token
  • Loading branch information
JoelSpeed authored Mar 14, 2022
2 parents ce750e9 + a392cc1 commit f820deb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

## Changes since v7.2.1

- [#1583](https://github.com/oauth2-proxy/oauth2-proxy/pull/1583) Add groups to session too when creating session from bearer token (@adriananeci)
- [#1418](https://github.com/oauth2-proxy/oauth2-proxy/pull/1418) Support for passing arbitrary query parameters through from `/oauth2/start` to the identity provider's login URL. Configuration settings control which parameters are passed by default and precisely which values can be overridden per-request (@ianroberts)
- [#1559](https://github.com/oauth2-proxy/oauth2-proxy/pull/1559) Introduce ProviderVerifier to clean up OIDC discovery code (@JoelSpeed)
- [#1561](https://github.com/oauth2-proxy/oauth2-proxy/pull/1561) Add ppc64le support (@mgiessing)
Expand Down
10 changes: 6 additions & 4 deletions pkg/apis/middleware/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ type VerifyFunc func(ctx context.Context, token string) (*oidc.IDToken, error)
func CreateTokenToSessionFunc(verify VerifyFunc) TokenToSessionFunc {
return func(ctx context.Context, token string) (*sessionsapi.SessionState, error) {
var claims struct {
Subject string `json:"sub"`
Email string `json:"email"`
Verified *bool `json:"email_verified"`
PreferredUsername string `json:"preferred_username"`
Subject string `json:"sub"`
Email string `json:"email"`
Verified *bool `json:"email_verified"`
PreferredUsername string `json:"preferred_username"`
Groups []string `json:"groups"`
}

idToken, err := verify(ctx, token)
Expand All @@ -46,6 +47,7 @@ func CreateTokenToSessionFunc(verify VerifyFunc) TokenToSessionFunc {
newSession := &sessionsapi.SessionState{
Email: claims.Email,
User: claims.Subject,
Groups: claims.Groups,
PreferredUsername: claims.PreferredUsername,
AccessToken: token,
IDToken: token,
Expand Down

0 comments on commit f820deb

Please sign in to comment.