jwt

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptySignedKey = errors.New("jwt signed key is empty")
	ErrTokenNotValid  = errors.New("jwt token is not valid")
	ErrTokenIsExpired = errors.New("jwt token is expired")
)

Functions

func GenerateUserJwt

func GenerateUserJwt(claims AccessClaims, userKey string, uID int) (jwtToken string, err error)

GenerateUserJwt 以用户 token 作为加密串生成 JWT,用户 ID 使用 uid 字段

Types

type AccessClaims

type AccessClaims struct {
	UID           int           `json:"uid"`
	AreaID        uint64        `json:"area_id,omitempty"`
	RoleIds       []int         `json:"role_ids,omitempty"`
	SAID          string        `json:"sa_id,omitempty"`
	Exp           int64         `json:"exp,omitempty"`
	Scope         string        `json:"scope,omitempty"`
	AreaType      orm2.AreaType `json:"area_type"`
	DepartmentIds []int         `json:"department_ids"`
}

func ValidateUserJwt

func ValidateUserJwt(jwtToken string) (*AccessClaims, error)

ValidateUserJwt 校验用户 JWT 的有效性

func (AccessClaims) Valid

func (c AccessClaims) Valid() error

Jump to

Keyboard shortcuts

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