serviceaccount

package
v0.17.1-0...-7ba4162 Latest Latest
Warning

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

Go to latest
Published: May 13, 2015 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package serviceaccount provides implementations to manage service accounts and service account tokens

Index

Constants

View Source
const (
	ServiceAccountUsernamePrefix    = "serviceaccount"
	ServiceAccountUsernameSeparator = ":"

	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 JWTTokenAuthenticator

func JWTTokenAuthenticator(keys []*rsa.PublicKey, lookup bool, client client.Interface) 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 using the given client

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) (*rsa.PrivateKey, error)

ReadPrivateKey is a helper function for reading an rsa.PrivateKey from a PEM-encoded file

func ReadPublicKey

func ReadPublicKey(file string) (*rsa.PublicKey, error)

ReadPublicKey is a helper function for reading an rsa.PublicKey from a PEM-encoded file 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

Types

type ServiceAccountControllerOptions

type ServiceAccountControllerOptions struct {
	Name                 string
	ServiceAccountResync time.Duration
	NamespaceResync      time.Duration
}

func DefaultServiceAccountControllerOptions

func DefaultServiceAccountControllerOptions() ServiceAccountControllerOptions

type ServiceAccountsController

type ServiceAccountsController struct {
	// contains filtered or unexported fields
}

ServiceAccountsController manages ServiceAccount objects inside Namespaces

func NewServiceAccountsController

func NewServiceAccountsController(cl *client.Client, options ServiceAccountControllerOptions) *ServiceAccountsController

NewServiceAccountsController returns a new *ServiceAccountsController.

func (*ServiceAccountsController) Run

func (e *ServiceAccountsController) Run()

Runs controller loops and returns immediately

func (*ServiceAccountsController) Stop

func (e *ServiceAccountsController) Stop()

Stop gracefully shuts down this controller

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(key *rsa.PrivateKey) 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 TokensController

type TokensController struct {
	// contains filtered or unexported fields
}

TokensController manages ServiceAccountToken secrets for ServiceAccount objects

func NewTokensController

func NewTokensController(cl client.Interface, options TokensControllerOptions) *TokensController

NewTokensController returns a new *TokensController.

func (*TokensController) Run

func (e *TokensController) Run()

Runs controller loops and returns immediately

func (*TokensController) Stop

func (e *TokensController) Stop()

Stop gracefully shuts down this controller

type TokensControllerOptions

type TokensControllerOptions struct {
	// TokenGenerator is the generator to use to create new tokens
	TokenGenerator TokenGenerator
	// ServiceAccountResync is the time.Duration at which to fully re-list service accounts.
	// If zero, re-list will be delayed as long as possible
	ServiceAccountResync time.Duration
	// SecretResync is the time.Duration at which to fully re-list secrets.
	// If zero, re-list will be delayed as long as possible
	SecretResync time.Duration
}

TokensControllerOptions contains options for the TokensController

func DefaultTokenControllerOptions

func DefaultTokenControllerOptions(tokenGenerator TokenGenerator) TokensControllerOptions

DefaultTokenControllerOptions returns

Jump to

Keyboard shortcuts

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