jwt

package
v0.0.0-...-99221f3 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccessTokenKey = []byte("moyn8y9abnd7q4zkq2m73yw8tu9j5ixm")

AccessTokenKey 因为 JWT Key 不太可能变,所以可以直接写成常量 也可以考虑做成依赖注入

View Source
var RefreshTokenKey = []byte("moyn8y9abnd7q4zkq2m73yw8tu9j5ixA")

Functions

This section is empty.

Types

type Handler

type Handler interface {
	ClearToken(ctx *gin.Context) error
	SetLoginToken(ctx *gin.Context, uid int64) error
	SetJWTToken(ctx *gin.Context, ssid string, uid int64) error
	CheckSession(ctx *gin.Context, ssid string) error
	ExtractTokenString(ctx *gin.Context) string
}

func NewRedisHandler

func NewRedisHandler(cmd redis.Cmdable) Handler

type RedisHandler

type RedisHandler struct {
	// contains filtered or unexported fields
}

func (*RedisHandler) CheckSession

func (h *RedisHandler) CheckSession(ctx *gin.Context, ssid string) error

func (*RedisHandler) ClearToken

func (h *RedisHandler) ClearToken(ctx *gin.Context) error

ClearToken 清除 token

func (*RedisHandler) ExtractTokenString

func (h *RedisHandler) ExtractTokenString(ctx *gin.Context) string

func (*RedisHandler) SetJWTToken

func (h *RedisHandler) SetJWTToken(ctx *gin.Context,
	ssid string,
	uid int64) error

func (*RedisHandler) SetLoginToken

func (h *RedisHandler) SetLoginToken(ctx *gin.Context, uid int64) error

SetLoginToken 设置登录后的 token

type RefreshClaims

type RefreshClaims struct {
	Id   int64
	Ssid string
	jwt.RegisteredClaims
}

type UserClaims

type UserClaims = ginx.UserClaims

UserClaims 别名机制,偷个懒,这样就不用修改其它的代码了

Jump to

Keyboard shortcuts

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