jwt

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Zlib Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Type = "jwt"

Variables

This section is empty.

Functions

func DecodeToken

func DecodeToken(tk string) (token.Token, error)

DecodeToken 不需要认证,解包里面的信息

func DecodeTokenNoBase64 added in v0.5.42

func DecodeTokenNoBase64(tk string) (token.Token, error)

func VerifyToken

func VerifyToken(tk string, key token.Key) (token.Token, error)

VerifyToken 需要认证,解包里面的信息

func VerifyTokenNoBase64 added in v0.5.42

func VerifyTokenNoBase64(tk string, key token.Key) (token.Token, error)

Types

type Authenticate

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

func New added in v0.5.13

func New(secret token.Secret) *Authenticate

func NewWith added in v1.3.18

func NewWith(secret token.Secret, method string, factory token.Factory) *Authenticate

func (*Authenticate) Check

func (t *Authenticate) Check(secretKey string, tok string, opts ...token.Option) (token.Token, error)

Check implement token.Authenticate interface

func (*Authenticate) Create

func (t *Authenticate) Create(secretKey string, expireSeconds int64, opts ...token.Option) (token.Token, error)

Create implement token.Authenticate interface

func (*Authenticate) Decode

func (t *Authenticate) Decode(tok string, opts ...token.Option) (token.Token, error)

Decode implement token.Authenticate interface

func (*Authenticate) EnableFlag added in v0.5.19

func (t *Authenticate) EnableFlag(secretKey string) int

EnableFlag implement token.Authenticate interface

func (*Authenticate) SetEnabled

func (t *Authenticate) SetEnabled(secretKey string, enable bool)

SetEnabled implement token.Authenticate interface

func (*Authenticate) Type

func (t *Authenticate) Type() string

type Token

type Token struct {
	Uid     string       `json:"uid"`
	Token   string       `json:"token"`
	Session string       `json:"-"` //for server and server
	Extend  string       `json:"-"`
	Source  token.Source `json:"-"`
	// contains filtered or unexported fields
}

func NewToken

func NewToken(key token.Key, ujc UpdateJWTClaims, base64 bool) *Token

func (*Token) ExpireIn added in v1.4.20

func (tk *Token) ExpireIn() int64

ExpireIn token.Token interface

func (*Token) GetToken

func (tk *Token) GetToken() string

func (*Token) GetVar added in v1.3.18

func (tk *Token) GetVar(key string) interface{}

func (*Token) Update

func (tk *Token) Update() (string, error)

Update token.Token interface

func (*Token) WithVar added in v1.3.18

func (tk *Token) WithVar(key string, value interface{}) token.Token

type UpdateJWTClaims added in v1.4.20

type UpdateJWTClaims func(tk token.Token) jwt.Claims

Jump to

Keyboard shortcuts

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