Documentation ¶
Index ¶
- Constants
- func InternalIsServiceAccountToken(secret *api.Secret, sa *api.ServiceAccount) bool
- func IsServiceAccountToken(secret *v1.Secret, sa *v1.ServiceAccount) bool
- func JWTTokenAuthenticator(keys []interface{}, lookup bool, getter ServiceAccountTokenGetter) authenticator.Token
- func ReadPrivateKey(file string) (interface{}, error)
- func ReadPublicKeys(file string) ([]interface{}, error)
- func ReadPublicKeysFromPEM(data []byte) ([]interface{}, error)
- func UserInfo(namespace, name, uid string) user.Info
- type ServiceAccountTokenGetter
- type TokenGenerator
Constants ¶
const ( Issuer = "kubernetes/serviceaccount" SubjectClaim = "sub" IssuerClaim = "iss" ServiceAccountNameClaim = "kubernetes.io/serviceaccount/service-account.name" ServiceAccountUIDClaim = "kubernetes.io/serviceaccount/service-account.uid" SecretNameClaim = "kubernetes.io/serviceaccount/secret.name" NamespaceClaim = "kubernetes.io/serviceaccount/namespace" )
Variables ¶
This section is empty.
Functions ¶
func InternalIsServiceAccountToken ¶ added in v1.6.1
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.2.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(keys []interface{}, lookup bool, getter ServiceAccountTokenGetter) 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 ReadPrivateKey ¶
ReadPrivateKey is a helper function for reading a private key from a PEM-encoded file
func ReadPublicKeys ¶ added in v1.5.0
ReadPublicKeys is a helper function for reading an array of rsa.PublicKey or ecdsa.PublicKey from a PEM-encoded file. Reads public keys from both public and private key files.
func ReadPublicKeysFromPEM ¶ added in v1.5.0
ReadPublicKeysFromPEM is a helper function for reading an array of rsa.PublicKey or ecdsa.PublicKey from a PEM-encoded byte array. Reads public keys from both public and private key files.
Types ¶
type ServiceAccountTokenGetter ¶
type ServiceAccountTokenGetter interface { GetServiceAccount(namespace, name string) (*v1.ServiceAccount, 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. // The returned token will be stored in the given (and yet-unpersisted) Secret. GenerateToken(serviceAccount v1.ServiceAccount, secret v1.Secret) (string, error) }
func JWTTokenGenerator ¶
func JWTTokenGenerator(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()