jwt

package
v0.1.33 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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

func FromContext(ctx context.Context) (token map[string]interface{}, ok bool)

FromContext extract auth info from context

func NewContext

func NewContext(ctx context.Context, info map[string]interface{}) context.Context

NewContext put auth info into context

func Sign

func Sign(signingMethod string, secret string, data map[string]interface{}, timeout int64) (string, error)

timeout 秒

func Verify

func Verify(tokenVal, secret string) (map[string]interface{}, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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