Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Now = time.Now
Now stubbed out to allow testing
Functions ¶
func ValidateKey ¶
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
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.
Click to show internal directories.
Click to hide internal directories.