token

package
v1.9.0-alpha.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// TokenIDBytes defines a number of bytes used for a token id
	TokenIDBytes = 3
	// TokenSecretBytes defines a number of bytes used for a secret
	TokenSecretBytes = 8
)

Variables

View Source
var (
	// TokenIDRegexpString defines token's id regular expression pattern
	TokenIDRegexpString = "^([a-z0-9]{6})$"
	// TokenIDRegexp is a compiled regular expression of TokenIDRegexpString
	TokenIDRegexp = regexp.MustCompile(TokenIDRegexpString)
	// TokenRegexpString defines id.secret regular expression pattern
	TokenRegexpString = "^([a-z0-9]{6})\\.([a-z0-9]{16})$"
	// TokenRegexp is a compiled regular expression of TokenRegexpString
	TokenRegexp = regexp.MustCompile(TokenRegexpString)
)

Functions

func BearerToken

func BearerToken(d *kubeadmapi.TokenDiscovery) string

BearerToken returns a string representation of the passed token.

func GenerateToken

func GenerateToken() (string, error)

GenerateToken generates a new token with a token ID that is valid as a Kubernetes DNS label. For more info, see kubernetes/pkg/util/validation/validation.go.

func ParseToken

func ParseToken(s string) (string, string, error)

ParseToken tries and parse a valid token from a string. A token ID and token secret are returned in case of success, an error otherwise.

func ParseTokenID

func ParseTokenID(s string) error

ParseTokenID tries and parse a valid token ID from a string. An error is returned in case of failure.

func ValidateToken

func ValidateToken(d *kubeadmapi.TokenDiscovery) (bool, error)

ValidateToken validates whether a token is well-formed. In case it's not, the corresponding error is returned as well.

Types

This section is empty.

Jump to

Keyboard shortcuts

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