jwtMng

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JwtMng

type JwtMng struct {
	AppID           int        `json:"app_id"`       // app_id 主要用来区别登陆
	IdentifyKey     string     `json:"identify_key"` // 身份标识键名,这个key必须存在于tokenStruct里
	TokenStruct     jwt.Claims `json:"token_struct"`
	SaltKey         []byte     `json:"salt_key"`          // 盐值
	IsSingletonMode bool       `json:"is_singleton_mode"` // 是否单例登陆模式
}

func GetJwtMng

func GetJwtMng(appID int, isSingletonMode bool, identifyKey, saltKey string, tokenStruct jwt.Claims) *JwtMng

GetJwtMng 获取jwt管理器

func (*JwtMng) CompareJwtCache added in v0.5.2

func (mng *JwtMng) CompareJwtCache(appID, userID int, token string) error

CompareJwtCache 判断jwtToken

func (*JwtMng) Decrypt

func (mng *JwtMng) Decrypt(claims jwt.Claims, tokenStr string) error

Decrypt 解码

func (*JwtMng) DecryptWithoutValidation added in v0.5.2

func (mng *JwtMng) DecryptWithoutValidation(claims jwt.Claims, tokenStr string) error

DecryptWithoutValidation 解码但不验证时间

func (*JwtMng) DeleteCache added in v0.5.2

func (mng *JwtMng) DeleteCache(appID, userID int) (int64, error)

DeleteCache 从缓存中删除jwt

func (*JwtMng) FromAuthHeader

func (mng *JwtMng) FromAuthHeader(authHeader string) (string, error)

FromAuthHeader 从header头中获取jwt

func (*JwtMng) GetCache added in v0.5.2

func (mng *JwtMng) GetCache(appID, userID int) (string, error)

GetJwtCache 从缓存中读取jwt

func (*JwtMng) GetTokenStr

func (mng *JwtMng) GetTokenStr(claims jwt.Claims) (string, error)

GetTokenStr: 获取jwt token

func (*JwtMng) RefreshToken added in v0.5.2

func (mng *JwtMng) RefreshToken(ctx iris.Context, validDuration float64)

RefreshToken 刷新token

func (*JwtMng) Serve

func (mng *JwtMng) Serve(ctx iris.Context)

Serve 注入服务

func (*JwtMng) SetCache added in v0.5.2

func (mng *JwtMng) SetCache(appID, userID int, token string) (int64, error)

StorageJWT 存储kwt至redis中

type TokenData

type TokenData struct {
	UserID   int  `json:"user_id"`
	OgID     int  `json:"og_id"`
	Grouping int8 `json:"grouping"`
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

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