serviceaccount

package
v2.14.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Now = time.Now

Now stubbed out to allow testing

Functions

func ValidateKey

func ValidateKey(privateKey []byte) error

Types

type CustomTokenClaim

type CustomTokenClaim struct {
	Email     string `json:"email,omitempty"`
	ProjectID string `json:"project_id,omitempty"`
	TokenID   string `json:"token_id,omitempty"`
}

CustomTokenClaim represents authenticated user

func Claims

func Claims(email, projectID, tokenID string) (*jwt.Claims, *CustomTokenClaim)

type TokenAuthenticator

type TokenAuthenticator interface {
	// Authenticate checks given token and transform it to custom claim object
	Authenticate(tokenData string) (*jwt.Claims, *CustomTokenClaim, error)
}

TokenAuthenticator declares the method to check JWT token

func JWTTokenAuthenticator

func JWTTokenAuthenticator(privateKey []byte) TokenAuthenticator

JWTTokenAuthenticator authenticates tokens as JWT tokens produced by JWTTokenGenerator

type TokenGenerator

type TokenGenerator interface {
	// Generate 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.
	Generate(claims *jwt.Claims, customClaims *CustomTokenClaim) (string, error)
}

TokenGenerator declares the method to generate JWT token

func JWTTokenGenerator

func JWTTokenGenerator(privateKey []byte) (TokenGenerator, error)

JWTTokenGenerator returns a TokenGenerator that generates signed JWT tokens, using the given privateKey.

Jump to

Keyboard shortcuts

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