add min valid jwt payload to API docs for structured authn config
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com> Kubernetes-commit: b57d7d6ad79ed0a2a8359144c07eadeef0ea3fd3
This commit is contained in:
parent
3d757e5f42
commit
b3e4dc29ef
|
|
@ -176,6 +176,14 @@ type AuthenticationConfiguration struct {
|
||||||
// authenticators is neither defined nor stable across releases. Since
|
// authenticators is neither defined nor stable across releases. Since
|
||||||
// each JWT authenticator must have a unique issuer URL, at most one
|
// each JWT authenticator must have a unique issuer URL, at most one
|
||||||
// JWT authenticator will attempt to cryptographically validate the token.
|
// JWT authenticator will attempt to cryptographically validate the token.
|
||||||
|
//
|
||||||
|
// The minimum valid JWT payload must contain the following claims:
|
||||||
|
// {
|
||||||
|
// "iss": "https://issuer.example.com",
|
||||||
|
// "aud": ["audience"],
|
||||||
|
// "exp": 1234567890,
|
||||||
|
// "<username claim>": "username"
|
||||||
|
// }
|
||||||
JWT []JWTAuthenticator `json:"jwt"`
|
JWT []JWTAuthenticator `json:"jwt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2953,6 +2953,38 @@ func TestToken(t *testing.T) {
|
||||||
}`, valid.Unix()),
|
}`, valid.Unix()),
|
||||||
want: &user.DefaultInfo{},
|
want: &user.DefaultInfo{},
|
||||||
},
|
},
|
||||||
|
// test to assert the minimum valid jwt payload
|
||||||
|
// the required claims are iss, aud, exp and <claimMappings.Username> (in this case user).
|
||||||
|
{
|
||||||
|
name: "minimum valid jwt payload",
|
||||||
|
options: Options{
|
||||||
|
JWTAuthenticator: apiserver.JWTAuthenticator{
|
||||||
|
Issuer: apiserver.Issuer{
|
||||||
|
URL: "https://auth.example.com",
|
||||||
|
Audiences: []string{"my-client"},
|
||||||
|
},
|
||||||
|
ClaimMappings: apiserver.ClaimMappings{
|
||||||
|
Username: apiserver.PrefixedClaimOrExpression{
|
||||||
|
Expression: "claims.user",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
now: func() time.Time { return now },
|
||||||
|
},
|
||||||
|
signingKey: loadRSAPrivKey(t, "testdata/rsa_1.pem", jose.RS256),
|
||||||
|
pubKeys: []*jose.JSONWebKey{
|
||||||
|
loadRSAKey(t, "testdata/rsa_1.pem", jose.RS256),
|
||||||
|
},
|
||||||
|
claims: fmt.Sprintf(`{
|
||||||
|
"iss": "https://auth.example.com",
|
||||||
|
"aud": "my-client",
|
||||||
|
"user": "jane",
|
||||||
|
"exp": %d
|
||||||
|
}`, valid.Unix()),
|
||||||
|
want: &user.DefaultInfo{
|
||||||
|
Name: "jane",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
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