Merge pull request #68850 from mikedanese/oidc

oidc: respect the legacy goog issuer
pull/58/head
k8s-ci-robot 2018-09-26 18:11:14 -07:00 committed by GitHub
commit 3611c5c498
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -342,6 +342,12 @@ func untrustedIssuer(token string) (string, error) {
if err := json.Unmarshal(payload, &claims); err != nil {
return "", fmt.Errorf("while unmarshaling token: %v", err)
}
// Coalesce the legacy GoogleIss with the new one.
//
// http://openid.net/specs/openid-connect-core-1_0.html#GoogleIss
if claims.Issuer == "accounts.google.com" {
return "https://accounts.google.com", nil
}
return claims.Issuer, nil
}

View File

@ -1365,6 +1365,28 @@ func TestToken(t *testing.T) {
},
wantInitErr: true,
},
{
name: "accounts.google.com issuer",
options: Options{
IssuerURL: "https://accounts.google.com",
ClientID: "my-client",
UsernameClaim: "email",
now: func() time.Time { return now },
},
claims: fmt.Sprintf(`{
"iss": "accounts.google.com",
"email": "thomas.jefferson@gmail.com",
"aud": "my-client",
"exp": %d
}`, valid.Unix()),
signingKey: loadRSAPrivKey(t, "testdata/rsa_1.pem", jose.RS256),
pubKeys: []*jose.JSONWebKey{
loadRSAKey(t, "testdata/rsa_1.pem", jose.RS256),
},
want: &user.DefaultInfo{
Name: "thomas.jefferson@gmail.com",
},
},
}
for _, test := range tests {
t.Run(test.name, test.run)