token

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingHeader = errors.New("the length of the `Authorization` header is zero")

ErrMissingHeader 表示 `Authorization` 请求头为空.

Functions

func Init

func Init(key string, identityKey string)

Init 设置包级别的配置 config, config 会用于本包后面的 token 签发和解析.

func Parse

func Parse(tokenString string, key string) (string, error)

Parse 使用指定的密钥 key 解析 token,解析成功返回 token 上下文,否则报错.

func ParseRequest

func ParseRequest(c *gin.Context) (string, error)

ParseRequest 从请求头中获取令牌,并将其传递给 Parse 函数以解析令牌.

func Sign

func Sign(identityKey string) (tokenString string, err error)

Sign 使用 jwtSecret 签发 token,token 的 claims 中会存放传入的 subject.

Types

type Config

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

Config 包括 token 包的配置选项.

Jump to

Keyboard shortcuts

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