token

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenInvalid = errors.New("couldn't handle this token")
)

Functions

This section is empty.

Types

type AuthToken

type AuthToken struct {
	SigningKey []byte                 // 密钥
	Header     map[string]interface{} // 头信息
	Raw        string                 // 加密token
}

func NewAuthToken

func NewAuthToken(secret []byte) *AuthToken

func (*AuthToken) CreateToken

func (p *AuthToken) CreateToken(claims Claims) (string, error)

CreateToken 创建一个token

func (*AuthToken) ParseFromRequest

func (p *AuthToken) ParseFromRequest(req *http.Request) (*Claims, error)

ParseFromRequest 解析token

func (*AuthToken) ParseToken

func (p *AuthToken) ParseToken(tokenString string) (*Claims, error)

type Claims

type Claims struct {
	jwt.RegisteredClaims
	UserId int64  // 应用内部用户id
	SignId string // 单点用户id
}

Jump to

Keyboard shortcuts

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