jwt

package
v0.0.0-...-750a8a5 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

@Description jwt @Author jiangyang @Created 2020/11/17 4:12 下午

Index

Constants

View Source
const DefaultExpireDuration = time.Hour * 24 * 30

Variables

View Source
var (
	ErrTokenExpired     = errors.New("Token is expired")
	ErrTokenNotValidYet = errors.New("Token not active yet")
	ErrTokenMalformed   = errors.New("That's not even a token")
	ErrTokenInvalid     = errors.New("Couldn't handle this token")
	SignKey             = []byte("243223ffslsfsldfl412fdsfsdf")
)

Functions

func Init

func Init(key string)

func ParseToken

func ParseToken(tokenString string) (interface{}, error)

解析Token

Types

type Business

type Business struct {
	UID  uint `json:"uid"`
	Role uint `json:"role"`
}

type CustomClaims

type CustomClaims struct {
	Business interface{}
	jwtgo.StandardClaims
}

type TokenResp

type TokenResp struct {
	Token     string `json:"token"`
	ExpiredAt string `json:"expired_at"`
}

func CreateToken

func CreateToken(bus interface{}, expires time.Duration) (*TokenResp, error)

创建Token

Jump to

Keyboard shortcuts

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