Skip to content

Commit

Permalink
adding an iss field to IAM tokens (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
jprobinson authored Dec 27, 2018
1 parent c66e686 commit 3fb7c2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions auth/gcp/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ func (s iamTokenSource) newIAMToken(ctx context.Context, svc *iam.Service) (stri
exp := iss.Add(defaultTokenTTL)
payload, err := json.Marshal(IAMClaimSet{
ClaimSet: jws.ClaimSet{
Iss: Issuer,
Aud: s.cfg.Audience,
Exp: exp.Unix(),
Iat: iss.Unix(),
Expand Down
7 changes: 5 additions & 2 deletions auth/gcp/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,13 @@ func IdentityVerifyFunc(vf func(ctx context.Context, cs IdentityClaimSet) bool)

// Issuers contains the known Google account issuers for identity tokens.
var Issuers = map[string]bool{
"accounts.google.com": true,
"https://accounts.google.com": true,
"accounts.google.com": true,
Issuer: true,
}

// Issuer is the string that will be used for the "iss" field in tokens.
const Issuer = "https://accounts.google.com"

// ValidIdentityClaims ensures the token audience and issuers match expectations.
func ValidIdentityClaims(cs IdentityClaimSet, audience string) bool {
if cs.Aud != audience {
Expand Down

0 comments on commit 3fb7c2f

Please sign in to comment.