jwt

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultOption

func SetDefaultOption(opt Option)

SetDefaultOption 设置默认配置

func Token

func Token(data ...map[string]interface{}) (string, error)

Token 生成 token

func TokenWithKey

func TokenWithKey(key []byte, data ...map[string]interface{}) (string, error)

TokenWithKey 生成 token

func Verify

func Verify(s string) (map[string]interface{}, error)

Verify 验证 token,并获取自定义内容

func VerifyWithKey

func VerifyWithKey(key []byte, s string) (map[string]interface{}, error)

VerifyWithKey 验证 token,并获取自定义内容

Types

type JWT

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

JWT ..

func NewJWT

func NewJWT(opts ...Option) *JWT

NewJWT 创建一个 jwt

func (*JWT) Token

func (jwt *JWT) Token(data ...map[string]interface{}) (string, error)

Token 生成 token

func (*JWT) TokenWithKey

func (jwt *JWT) TokenWithKey(key []byte, data ...map[string]interface{}) (string, error)

TokenWithKey 生成 token

func (*JWT) Verify

func (jwt *JWT) Verify(s string) (map[string]interface{}, error)

Verify 验证 token,并获取自定义内容

func (*JWT) VerifyWithKey

func (jwt *JWT) VerifyWithKey(key []byte, s string) (map[string]interface{}, error)

VerifyWithKey 验证 token,并获取自定义内容

type Option

type Option struct {
	// Secret 签名密钥
	Secret []byte

	// Exp 过期时间
	Exp time.Duration
}

Option ..

Jump to

Keyboard shortcuts

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