Documentation ¶
Index ¶
Constants ¶
View Source
const ( // RobotAccountProviderKey is the key for robot account token provider RobotAccountProviderKey = "robotAccountProvider" // APITokenProviderKey is the key for api token provider APITokenProviderKey = "apiTokenProvider" )
Variables ¶
View Source
var ( ErrMissingJwtToken = errorsAPI.Unauthorized(reason, "JWT token is missing") ErrMissingKeyFunc = errorsAPI.Unauthorized(reason, "keyFunc is missing") ErrMissingVerifyAudienceFunc = errorsAPI.Unauthorized(reason, "verifyAudienceFunc is missing") ErrTokenInvalid = errorsAPI.Unauthorized(reason, "Token is invalid") ErrTokenExpired = errorsAPI.Unauthorized(reason, "JWT token has expired") ErrTokenParseFail = errorsAPI.Unauthorized(reason, "Fail to parse JWT token ") ErrUnSupportSigningMethod = errorsAPI.Unauthorized(reason, "Wrong signing method") ErrWrongContext = errorsAPI.Unauthorized(reason, "Wrong context for middleware") )
Functions ¶
func WithJWTMulti ¶
func WithJWTMulti(opts ...JWTOption) middleware.Middleware
WithJWTMulti creates a custom JWT middleware that configured with different token providers tries to run all validations from an incoming token. If one of the providers matches the expected audience it gets parsed and sent down to the next middleware. If none matches an error is returned
Types ¶
type JWTAuthContext ¶
func FromJWTAuthContext ¶
func FromJWTAuthContext(ctx context.Context) (authContext JWTAuthContext, ok bool)
FromJWTAuthContext extract JWTAuthContext from context
type JWTOption ¶
type JWTOption func(*options)
func NewAPITokenProvider ¶
NewAPITokenProvider return the configuration to validate and verify token issued for API Tokens
func NewRobotAccountProvider ¶
NewRobotAccountProvider return the configuration to validate and verify token issued for Robot Accounts
type TokenProviderOption ¶
type TokenProviderOption func(*providerOption)
func WithClaims ¶
func WithClaims(f func() jwt.Claims) TokenProviderOption
func WithKeyFunc ¶
func WithKeyFunc(keyFunc jwt.Keyfunc) TokenProviderOption
func WithSigningMethod ¶
func WithSigningMethod(method jwt.SigningMethod) TokenProviderOption
func WithVerifyAudienceFunc ¶
func WithVerifyAudienceFunc(f VerifyAudienceFunc) TokenProviderOption
type VerifyAudienceFunc ¶
type VerifyAudienceFunc func(*jwt.Token) bool
Click to show internal directories.
Click to hide internal directories.