jwt

package
v1.0.1-0...-bd443ad Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIatTime = errors.New("jwt in bad format,iat>=exp")
View Source
var ErrTimeExp = errors.New("jwt is expiration")

同一類型的多個錯誤實例

Functions

func GetNewJwtToken

func GetNewJwtToken(hs256Key []byte, userClaims *UserClaims) (string, error)

創建一個新的jwt,

Types

type UserClaims

type UserClaims struct {
	ClientId string `json:"client_id"` //頒發給哪個端
	UserId   string `json:"user_id"`   //用戶id
	Iat      int64  `json:"iat"`       //發放時間
	Exp      int64  `json:"exp"`       //過期時間
	Jti      string `json:"jti"`       //token 的id ,唯一標識
	Iss      string `json:"iss"`       //簽發者 是sys_user_control
}

jwt payload的內容,如果是app角色,則appid為空。,web端默認web

func CheckJwtToken

func CheckJwtToken(hs256Key []byte, jwtString string) (userClaims UserClaims, err error)

檢查jwt是否有效

func (UserClaims) Valid

func (u UserClaims) Valid() error

jwt 是否有效,如果沒效,則入出錯誤

Jump to

Keyboard shortcuts

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