jwt

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	jwt.RegisteredClaims
	PublicClaims
	PrivateClaims
}

type Jwt

type Jwt struct {
	Secret        []byte
	Payload       *Payload
	SigningMethod jwt.SigningMethod
}

func (Jwt) Create

func (j Jwt) Create() (string, error)

Create 创建Token

func (Jwt) Parse

func (j Jwt) Parse(token string) (jwt.Claims, error)

Parse 解析JWT Token

type Payload

type Payload struct {
	Subject   string
	Issuer    string
	ExpiresAt int64
	Scope     []string
	Admin     bool
}

Payload 载荷

type PrivateClaims

type PrivateClaims struct {
	Admin bool `json:"admin"`
}

PrivateClaims 私有声明

type PublicClaims

type PublicClaims struct {
	// 作用域
	Scope []string `json:"scope"`
}

PublicClaims 公有声明,JWT 签发方可以自定义的声明,但是为了避免冲突,应该在 Registry 中定义它们 声明参考 https://www.iana.org/assignments/jwt/jwt.xhtml

Jump to

Keyboard shortcuts

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