apptoken

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorInvalidToken = errors.New("verify Token Failed")
)

Functions

func GenToken

func GenToken(UserID int64, Username string) (atoken, rtoken string, err error)

GenToken 颁发token access token 和 refresh token

func Init

func Init(AMinute, RHour time.Duration, TokenIssuer string)

Init 初始化设置token-过期时间、重新刷新时间、token签名

func RefreshToken

func RefreshToken(atoken, rtoken string) (newAtoken, newRtoken string, err error)

RefreshToken 通过 refresh token 刷新 atoken

Types

type MyClaim

type MyClaim struct {
	UserID    int64  `json:"userId"`
	UserEmail string `json:"userEmail"`
	jwt.RegisteredClaims
}

func VerifyToken

func VerifyToken(tokenID string) (*MyClaim, error)

VerifyToken 验证Token

Jump to

Keyboard shortcuts

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