jwt

package
v0.0.0-...-5845281 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package jwt provides ...

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenExpired     error  = errors.New("Token is expired")
	TokenNotValidYet error  = errors.New("Token not active yet")
	TokenMalformed   error  = errors.New("That's not even a token")
	TokenInvalid     error  = errors.New("Couldn't handle this token:")
	SignKey          string = "martin"
)

Functions

func GetSignKey

func GetSignKey() string

获取SignKey

func JWTAuth

func JWTAuth() gin.HandlerFunc

JWTAuth 中间件,检查token

func SetSignKey

func SetSignKey(key string) string

设置SignKey

Types

type Customclaims

type Customclaims struct {
	Empname string `json:"empname"`
	Phone   string `json:"phone"`
	Role    string `json:"role"`
	jwt.StandardClaims
}

载荷

type JWT

type JWT struct {
	SigningKey []byte
}

JWT签名结构

func NewJWT

func NewJWT() *JWT

func (*JWT) CreateToken

func (j *JWT) CreateToken(claims Customclaims) (string, error)

创建Token

func (*JWT) ParseToken

func (j *JWT) ParseToken(tokenString string) (*Customclaims, error)

解析token

func (*JWT) RefreshToken

func (j *JWT) RefreshToken(tokenString string) (string, error)

更新Token

Jump to

Keyboard shortcuts

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