token

package
v0.0.0-...-5a23a7a Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 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")

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