serviceaccount

package
v1.5.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
const (
	ServiceAccountUsernamePrefix    = "system:serviceaccount:"
	ServiceAccountUsernameSeparator = ":"
	ServiceAccountGroupPrefix       = "system:serviceaccounts:"
	AllServiceAccountsGroup         = "system:serviceaccounts"
)

Variables

This section is empty.

Functions

func IsServiceAccountToken added in v1.2.0

func IsServiceAccountToken(secret *api.Secret, sa *api.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 MakeGroupNames added in v1.2.0

func MakeGroupNames(namespace, name string) []string

MakeGroupNames generates service account group names for the given namespace and ServiceAccount name

func MakeNamespaceGroupName added in v1.2.0

func MakeNamespaceGroupName(namespace string) string

MakeNamespaceGroupName returns the name of the group all service accounts in the namespace are included in

func MakeUsername

func MakeUsername(namespace, name string) string

MakeUsername generates a username from the given namespace and ServiceAccount name. The resulting username can be passed to SplitUsername to extract the original namespace and ServiceAccount name.

func ReadPrivateKey

func ReadPrivateKey(file string) (interface{}, error)

ReadPrivateKey is a helper function for reading a private key from a PEM-encoded file

func ReadPrivateKeyFromPEM added in v1.5.0

func ReadPrivateKeyFromPEM(data []byte) (interface{}, error)

ReadPrivateKeyFromPEM is a helper function for reading a private key from a PEM-encoded file

func ReadPublicKeys added in v1.5.0

func ReadPublicKeys(file string) ([]interface{}, error)

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

func ReadPublicKeysFromPEM(data []byte) ([]interface{}, error)

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.

func SplitUsername

func SplitUsername(username string) (string, string, error)

SplitUsername returns the namespace and ServiceAccount name embedded in the given username, or an error if the username is not a valid name produced by MakeUsername

func UserInfo added in v1.2.0

func UserInfo(namespace, name, uid string) user.Info

UserInfo returns a user.Info interface for the given namespace, service account name and UID

Types

type ServiceAccountTokenGetter

type ServiceAccountTokenGetter interface {
	GetServiceAccount(namespace, name string) (*api.ServiceAccount, error)
	GetSecret(namespace, name string) (*api.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 api.ServiceAccount, secret api.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()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL