jwt

package
v0.0.0-...-3208bda Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JwtInit

func JwtInit()

Types

type CustomerClaim

type CustomerClaim struct {
	TokenUserClaim
	*jwt.StandardClaims
}

聚合jwt内部实现的Claims

type ITokenService

type ITokenService interface {
	Encode(user TokenUserClaim) (string, error)
	Decode(tokenString string) (*CustomerClaim, error)
}

type TokenService

type TokenService struct{}

实现token服务

var JwtService *TokenService

func (*TokenService) Decode

func (tks *TokenService) Decode(tokenString string) (*CustomerClaim, error)

token字符串解码成用户信息

func (*TokenService) Encode

func (tks *TokenService) Encode(user TokenUserClaim) (string, error)

传入用户信息编码成token

type TokenUserClaim

type TokenUserClaim struct {
	Id     int64  `json:"id"`
	Name   string `json:"name"`
	Avatar string `json:"avatar"`
}

JWT中携带的用户个人信息

Jump to

Keyboard shortcuts

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