Documentation ¶
Index ¶
- Constants
- func Claims(sa core.ServiceAccount, pod *core.Pod, secret *core.Secret, ...) (*jwt.Claims, interface{})
- func InternalIsServiceAccountToken(secret *api.Secret, sa *api.ServiceAccount) bool
- func IsServiceAccountToken(secret *v1.Secret, sa *v1.ServiceAccount) bool
- func JWTTokenAuthenticator(iss string, keys []interface{}, validator Validator) authenticator.Token
- func LegacyClaims(serviceAccount v1.ServiceAccount, secret v1.Secret) (*jwt.Claims, interface{})
- func UserInfo(namespace, name, uid string) user.Info
- type ServiceAccountTokenGetter
- type TokenGenerator
- type Validator
Constants ¶
const LegacyIssuer = "kubernetes/serviceaccount"
Variables ¶
This section is empty.
Functions ¶
func InternalIsServiceAccountToken ¶ added in v1.7.0
func InternalIsServiceAccountToken(secret *api.Secret, sa *api.ServiceAccount) bool
TODO: remove the duplicate code InternalIsServiceAccountToken returns true if the secret is a valid api token for the service account
func IsServiceAccountToken ¶ added in v1.3.0
func IsServiceAccountToken(secret *v1.Secret, sa *v1.ServiceAccount) bool
IsServiceAccountToken returns true if the secret is a valid api token for the service account
func JWTTokenAuthenticator ¶
func JWTTokenAuthenticator(iss string, keys []interface{}, validator Validator) authenticator.Token
JWTTokenAuthenticator authenticates tokens as JWT tokens produced by JWTTokenGenerator Token signatures are verified using each of the given public keys until one works (allowing key rotation) If lookup is true, the service account and secret referenced as claims inside the token are retrieved and verified with the provided ServiceAccountTokenGetter
func LegacyClaims ¶ added in v1.10.8
Types ¶
type ServiceAccountTokenGetter ¶
type ServiceAccountTokenGetter interface { GetServiceAccount(namespace, name string) (*v1.ServiceAccount, error) GetPod(namespace, name string) (*v1.Pod, error) GetSecret(namespace, name string) (*v1.Secret, error) }
ServiceAccountTokenGetter defines functions to retrieve a named service account and secret
type TokenGenerator ¶
type TokenGenerator interface { // GenerateToken generates a token which will identify the given // ServiceAccount. privateClaims is an interface that will be // serialized into the JWT payload JSON encoding at the root level of // the payload object. Public claims take precedent over private // claims i.e. if both claims and privateClaims have an "exp" field, // the value in claims will be used. GenerateToken(claims *jwt.Claims, privateClaims interface{}) (string, error) }
func JWTTokenGenerator ¶
func JWTTokenGenerator(iss string, privateKey interface{}) TokenGenerator
JWTTokenGenerator returns a TokenGenerator that generates signed JWT tokens, using the given privateKey. privateKey is a PEM-encoded byte array of a private RSA key. JWTTokenAuthenticator()
type Validator ¶ added in v1.10.8
type Validator interface { // Validate validates a token and returns user information or an error. // Validator can assume that the issuer and signature of a token are already // verified when this function is called. Validate(tokenData string, public *jwt.Claims, private interface{}) (namespace, name, uid string, err error) // NewPrivateClaims returns a struct that the authenticator should // deserialize the JWT payload into. The authenticator may then pass this // struct back to the Validator as the 'private' argument to a Validate() // call. This struct should contain fields for any private claims that the // Validator requires to validate the JWT. NewPrivateClaims() interface{} }
Validator is called by the JWT token authentictaor to apply domain specific validation to a token and extract user information.
func NewLegacyValidator ¶ added in v1.10.8
func NewLegacyValidator(lookup bool, getter ServiceAccountTokenGetter) Validator
func NewValidator ¶ added in v1.10.8
func NewValidator(audiences []string, getter ServiceAccountTokenGetter) Validator