Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnrecognizedPublicKey = errors.New("unrecognized public key")
Functions ¶
This section is empty.
Types ¶
type Auth0Tokener ¶
type Auth0Tokener struct {
// contains filtered or unexported fields
}
Auth0Tokener implements anonymizer by requesting new tokens through an Auth0 machine-to-machine client
func NewTokener ¶
func NewTokener(url, clientID, clientSecret, audience string, doer Doer) Auth0Tokener
NewTokener builds an Auth0Tokener from the specified auth0 API url, client id, and secret.
type Authorization ¶
type Authorization struct { jwt.StandardClaims Session string `json:"https://jwt.smartatransit.com/session"` Role string `json:"https://jwt.smartatransit.com/role"` }
Authorization is used to interact with the `jwt` package
func (Authorization) SetAuthHeaders ¶
func (a Authorization) SetAuthHeaders(w http.ResponseWriter)
SetAuthHeaders converts the authorization claims into X-Smarta-Auth headers.
func (Authorization) Valid ¶
func (a Authorization) Valid() error
Valid implements jwt.Authorization
type CachedToken ¶
type CachedToken struct {
// contains filtered or unexported fields
}
CachedToken represents a cached token
type KeyServer ¶
type KeyServer struct {
// contains filtered or unexported fields
}
func NewKeyServer ¶
type Parser ¶
type Parser interface {
ParseToken(ctx context.Context, tokenStr string) (Authorization, error)
}
Parser parses a JWT into an Authorization struct
type ParserAgent ¶
type ParserAgent struct { ParseWithClaims ParseFunc // contains filtered or unexported fields }
ParserAgent implements Parser
func (ParserAgent) ParseToken ¶
func (a ParserAgent) ParseToken(ctx context.Context, tokenStr string) (Authorization, error)
ParseToken fails if the token is invalid, has an invalid signature, or fails standard claims validations. Otherwise, returns the claims covered by the Authorization struct. It uses the underlying Keys implementation to look up the `kid` in the key for verification.
type TokenAgent ¶
type TokenAgent struct {
// contains filtered or unexported fields
}
TokenAgent implements TokenCache
func (*TokenAgent) Clean ¶
func (a *TokenAgent) Clean(ctx context.Context)
Clean clears out any expired tokens
func (*TokenAgent) FetchToken ¶
FetchToken gets a token for the key if there is an unexpired one
type TokenCache ¶
type TokenCache interface { FetchToken(ctx context.Context, key string) (string, bool) Clean(ctx context.Context) AddToken(ctx context.Context, key string, token string, expy time.Time) }
TokenCache parses a JWT into an Authorization struct
type TokenerFactory ¶
TokenerFactory builds a tokener for a specific Auth0 client identity
func NewTokenerFactory ¶
func NewTokenerFactory(url, audience string, doer Doer) TokenerFactory
NewTokenerFactory returns a new tokener factory