jwtApi

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JwtCfg

type JwtCfg struct {
	Key                 string
	TokenExpireDuration time.Duration
	Issuer              string
}

func InitJwt

func InitJwt(secret string, opts ...OptionFunc) *JwtCfg

InitJwt 初始化jwt管理器

func (*JwtCfg) ParseToken

func (j *JwtCfg) ParseToken(tokenStr string) (*MyClaims, error)

ParseToken 解析 jwt token

func (*JwtCfg) SignedTokenStr

func (j *JwtCfg) SignedTokenStr(data interface{}) (string, error)

SignedTokenStr 签发jwt token

type MyClaims

type MyClaims struct {
	AuthData interface{}
	jwt.RegisteredClaims
}

type OptionFunc

type OptionFunc func(cfg *JwtCfg)

func WithExp

func WithExp(exp time.Duration) OptionFunc

WithExp 过期时间

func WithIssuer

func WithIssuer(iss string) OptionFunc

WithIssuer 添加issuer 项目名称

Jump to

Keyboard shortcuts

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