jwt

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: MIT Imports: 7 Imported by: 0

README

go-jwt

Implementation of JWT in golang.

Documentation

Index

Constants

View Source
const (
	HS256 = "HS256"
	HS1   = "HS1"
)

Variables

This section is empty.

Functions

func NewJwt

func NewJwt() *jwt

Types

type Header struct {
	Typ string `json:"typ"`
	Alg string `json:"alg"`
}

Header

func (*Header) SetAlg

func (h *Header) SetAlg(alg string) error

func (*Header) SetTyp

func (h *Header) SetTyp(typ string)

type Payload

type Payload struct {
	StandardPayload
	Addition map[string]interface{}
}

func (*Payload) SetAud

func (p *Payload) SetAud(aud string)

func (*Payload) SetExp

func (p *Payload) SetExp(exp string)

func (*Payload) SetIat

func (p *Payload) SetIat(iat string)

func (*Payload) SetIss

func (p *Payload) SetIss(iss string)

func (*Payload) SetJti

func (p *Payload) SetJti(jti string)

func (*Payload) SetNbf

func (p *Payload) SetNbf(nbf string)

func (*Payload) SetSub

func (p *Payload) SetSub(sub string)

type StandardPayload

type StandardPayload struct {
	Iss string `json:"iss"` // 签发者
	Iat string `json:"iat"` // 签发时间
	Exp string `json:"exp"` // 过期时间
	Aud string `json:"aud"` // 接收jwt的一方
	Sub string `json:"sub"` // jwt面向的用户
	Nbf string `json:"nbf"` // 定义在什么时间之前,该jwt都是不可用的
	Jti string `json:"jti"` // jwt的唯一身份标识,主要用来作为一次性token,从而回避重放攻击
}

Payload

Jump to

Keyboard shortcuts

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