jwt

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingJwtToken        = errors.Unauthorized("UNAUTHORIZED", "JWT token is missing")
	ErrMissingKeyFunc         = errors.Unauthorized("UNAUTHORIZED", "keyFunc is missing")
	ErrTokenInvalid           = errors.Unauthorized("UNAUTHORIZED", "Token is invalid")
	ErrTokenExpired           = errors.Unauthorized("UNAUTHORIZED", "JWT token has expired")
	ErrTokenParseFail         = errors.Unauthorized("UNAUTHORIZED", "Fail to parse JWT token ")
	ErrUnSupportSigningMethod = errors.Unauthorized("UNAUTHORIZED", "Wrong signing method")
	ErrWrongContext           = errors.Unauthorized("UNAUTHORIZED", "Wrong context for middleware")
	ErrNeedTokenProvider      = errors.Unauthorized("UNAUTHORIZED", "Token provider is missing")
	ErrSignToken              = errors.Unauthorized("UNAUTHORIZED", "Can not sign token.Is the key correct?")
	ErrGetKey                 = errors.Unauthorized("UNAUTHORIZED", "Can not get key while signing token")
)

Functions

func Client

func Client(keyProvider jwt.Keyfunc, opts ...Option) middleware.Middleware

Client is a client jwt middleware.

func FromContext

func FromContext(ctx context.Context) (token jwt.Claims, ok bool)

FromContext extract auth info from context

func NewContext

func NewContext(ctx context.Context, info jwt.Claims) context.Context

NewContext put auth info into context

func Server

func Server(keyFunc jwt.Keyfunc, opts ...Option) middleware.Middleware

Server is a server auth middleware. Check the token and extract the info from token.

Types

type Option

type Option func(*options)

Option is jwt option.

func WithClaims

func WithClaims(claims jwt.Claims) Option

WithClaims with customer claim

func WithSigningMethod

func WithSigningMethod(method jwt.SigningMethod) Option

WithSigningMethod with signing method option.

Jump to

Keyboard shortcuts

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