token

package
v0.0.0-...-489c00f Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenExpired     error  = errors.New("Token过期!")
	TokenNotValidYet error  = errors.New("Token not active yet")
	TokenMalformed   error  = errors.New("token错误!")
	TokenInvalid     error  = errors.New("token错误!")
	SignKey          string = "test"
)

-----------------------------------------------------------------------------------

Functions

func InitConfig

func InitConfig(address string, prefix string) *jwtCfg

Types

type JwtToken

type JwtToken struct {
	SigningKey []byte
}

func (*JwtToken) CreateToken

func (j *JwtToken) CreateToken(claims Subject) (string, error)

func (*JwtToken) Decode

func (j *JwtToken) Decode(r *http.Request, w http.ResponseWriter) (bool, string, *Subject)

Decode 解码

func (*JwtToken) ParseToken

func (j *JwtToken) ParseToken(tokenString string) (*Subject, error)

func (*JwtToken) RefreshToken

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

type Subject

type Subject struct {
	Mobile    string `json:"mobile"`
	AccountId string `json:"account_id"`
	DeviceId  string `json:"device_id"`
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

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