role

package
v0.0.0-...-a2093d6 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: LGPL-2.1 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenExpired     = errors.New("Token is expired")
	TokenNotValidYet = errors.New("Token not active yet")
	TokenMalformed   = errors.New("That's not even a token")
	TokenInvalid     = errors.New("Couldn't handle this token:")
)

Functions

func GetClaims

func GetClaims(c *gin.Context) (*request.CustomClaims, error)

func GetUserAuthorityId

func GetUserAuthorityId(c *gin.Context) string

从Gin的Context中获取从jwt解析出来的用户角色id

func GetUserID

func GetUserID(c *gin.Context) uint

从Gin的Context中获取从jwt解析出来的用户ID

func GetUserInfo

func GetUserInfo(c *gin.Context) *request.CustomClaims

从Gin的Context中获取从jwt解析出来的用户角色id

func GetUserUuid

func GetUserUuid(c *gin.Context) uuid.UUID

从Gin的Context中获取从jwt解析出来的用户UUID

Types

type JWT

type JWT struct {
	SigningKey []byte
}

func NewJWT

func NewJWT() *JWT

func (*JWT) CreateClaims

func (j *JWT) CreateClaims(baseClaims request.BaseClaims) request.CustomClaims

func (*JWT) CreateToken

func (j *JWT) CreateToken(claims request.CustomClaims) (string, error)

func (*JWT) CreateTokenByOldToken

func (j *JWT) CreateTokenByOldToken(oldToken string, claims request.CustomClaims) (string, error)

CreateTokenByOldToken 旧token 换新token 使用归并回源避免并发问题

func (*JWT) ParseToken

func (j *JWT) ParseToken(tokenString string) (*request.CustomClaims, error)

Jump to

Keyboard shortcuts

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