Skip to content

Commit

Permalink
Do not collect IdP tokens unless configured to do so
Browse files Browse the repository at this point in the history
  • Loading branch information
ipiadm authored and ipiadm committed Jul 23, 2020
1 parent dc5d4b6 commit db32069
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ vouch:
redirect: X-Vouch-Requested-URI
# claims:
claimheader: X-Vouch-IdP-Claims-
accesstoken: X-Vouch-IdP-AccessToken
idtoken: X-Vouch-IdP-IdToken
# https://github.com/vouch/vouch-proxy/issues/287
# accesstoken: X-Vouch-IdP-AccessToken
# idtoken: X-Vouch-IdP-IdToken
# test_url:
# post_logout_redirect_uris:
# oauth:
Expand Down
13 changes: 11 additions & 2 deletions pkg/jwtmanager/jwtmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ type VouchClaims struct {
Username string `json:"username"`
Sites []string `json:"sites"` // tempting to make this a map but the array is fewer characters in the jwt
CustomClaims map[string]interface{}
// PAccessToken string
// PIdToken string
PAccessToken string
PIdToken string
jwt.StandardClaims
}

Expand Down Expand Up @@ -86,6 +86,15 @@ func CreateUserTokenString(u structs.User, customClaims structs.CustomClaims, pt
StandardClaims,
}

// https://github.com/vouch/vouch-proxy/issues/287
if cfg.Cfg.Headers.AccessToken == "" {
claims.PAccessToken = ""
}

if cfg.Cfg.Headers.IDToken == "" {
claims.PIdToken = ""
}

claims.StandardClaims.ExpiresAt = time.Now().Add(time.Minute * time.Duration(cfg.Cfg.JWT.MaxAge)).Unix()

// https://godoc.org/github.com/dgrijalva/jwt-go#NewWithClaims
Expand Down

0 comments on commit db32069

Please sign in to comment.