mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 02:09:56 +00:00
Merge pull request #68850 from mikedanese/oidc
oidc: respect the legacy goog issuer
This commit is contained in:
commit
3611c5c498
@ -342,6 +342,12 @@ func untrustedIssuer(token string) (string, error) {
|
|||||||
if err := json.Unmarshal(payload, &claims); err != nil {
|
if err := json.Unmarshal(payload, &claims); err != nil {
|
||||||
return "", fmt.Errorf("while unmarshaling token: %v", err)
|
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
|
return claims.Issuer, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1365,6 +1365,28 @@ func TestToken(t *testing.T) {
|
|||||||
},
|
},
|
||||||
wantInitErr: true,
|
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 {
|
for _, test := range tests {
|
||||||
t.Run(test.name, test.run)
|
t.Run(test.name, test.run)
|
||||||
|
Loading…
Reference in New Issue
Block a user