jwt

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrJwtDecode is error message for get jwt claims failed
	ErrJwtDecode = errors.New("JWT Claims Failed")
	// DefaultKey is default jwt key we used
	DefaultKey = "you never know zcong"
	// JwtKey is jwt key we actually used
	JwtKey = utils.GetEnvOrDefault("JWTKEY", DefaultKey)
	// JwtMiddleware is jwt middleware for iris
	JwtMiddleware = jwtmiddleware.New(jwtmiddleware.Config{
		ValidationKeyGetter: func(token *jwt.Token) (interface{}, error) {
			return []byte(JwtKey), nil
		},
		SigningMethod: jwt.SigningMethodHS256,
		ErrorHandler: func(ctx iris.Context, err string) {
			ctx.StatusCode(iris.StatusUnauthorized)
			utils.ResponseErr(ctx, errors.New(err))
		},
	})
)

Functions

func JwtDecode

func JwtDecode(token *jwt.Token) (*user.User, error)

JwtDecode get user from a jwt token

func JwtEncode

func JwtEncode(user *user.User) (string, error)

JwtEncode create a token from user

Types

This section is empty.

Jump to

Keyboard shortcuts

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