jwt

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(token string) bool

func IsExpire added in v0.1.2

func IsExpire(token string) bool

func Refresh added in v0.1.2

func Refresh(token string) string

func SetSignature

func SetSignature(sign string)

Types

type Header struct {
	Algorithm string `json:"algorithm"`
	Type      string `json:"type"`
}

type JWT

type JWT struct {
	Header    *Header  `json:"header"`
	Payload   *Payload `json:"payload"`
	Signature string   `json:"signature"`
}

func NewToken added in v0.1.2

func NewToken() *JWT

func (*JWT) GetPayload

func (jwt *JWT) GetPayload() Payload

func (*JWT) SetDuration added in v0.1.2

func (jwt *JWT) SetDuration(duration time.Duration) *JWT

func (*JWT) SetExpire added in v0.1.2

func (jwt *JWT) SetExpire(expire time.Duration) *JWT

func (*JWT) SetExternal

func (jwt *JWT) SetExternal(external map[string]interface{}) *JWT

func (*JWT) SetIssuer

func (jwt *JWT) SetIssuer(issuer string) *JWT

func (*JWT) SetOwner

func (jwt *JWT) SetOwner(owner string) *JWT

func (*JWT) SetPurpose

func (jwt *JWT) SetPurpose(purpose string) *JWT

func (*JWT) SetRecipient

func (jwt *JWT) SetRecipient(recipient string) *JWT

func (*JWT) String added in v0.1.2

func (jwt *JWT) String() string

type Payload

type Payload struct {
	// 签发者
	Issuer string `json:"issuer"`
	// 令牌所有者,存放ID等标识
	Owner string `json:"owner"`
	// 用途,默认值authentication表示用于登录认证
	Purpose string `json:"purpose"`
	// 接受方,表示申请该令牌的设备来源,如浏览器、Android等
	Recipient string `json:"recipient"`
	// 令牌签发时间
	Time int64 `json:"time"`
	// 过期时间
	Expire int64 `json:"expire"`
	// 令牌持续时间,即生命周期
	Duration time.Duration `json:"duration"`
	// 其他扩展的自定义参数
	External map[string]interface{} `json:"external"`
}

func GetPayload

func GetPayload(token string) Payload

Jump to

Keyboard shortcuts

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