Documentation ¶
Index ¶
- Constants
- Variables
- func FromContext(ctx context.Context) (token map[string]interface{}, ok bool)
- func NewContext(ctx context.Context, info map[string]interface{}) context.Context
- func Sign(signingMethod string, secret string, data map[string]interface{}, ...) (string, error)
- func Verify(tokenVal, secret string) (map[string]interface{}, error)
Constants ¶
View Source
const ( // bearerWord the bearer key word for authorization BearerWord string = "Bearer" // authorizationKey holds the key used to store the JWT Token in the request tokenHeader. AuthorizationKey string = "Authorization" )
Variables ¶
View Source
var ( ErrMissingJwtToken = errors.Unauthorized("JWT token is missing") ErrMissingKeyFunc = errors.Unauthorized("secret is missing") ErrTokenInvalid = errors.Unauthorized("Token is invalid") ErrTokenExpired = errors.Unauthorized("JWT token has expired") ErrTokenParseFail = errors.Unauthorized("Fail to parse JWT token ") ErrUnSupportSigningMethod = errors.Unauthorized("Wrong signing method") ErrWrongContext = errors.Unauthorized("Wrong context for middleware") ErrNeedTokenProvider = errors.Unauthorized("Token provider is missing") ErrSignToken = errors.Unauthorized("Can not sign token.Is the key correct?") ErrGetKey = errors.Unauthorized("Can not get key while signing token") )
Functions ¶
func FromContext ¶
FromContext extract auth info from context
func NewContext ¶
NewContext put auth info into context
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.