token

package
v0.0.0-...-1be49ad Latest Latest
Warning

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

Go to latest
Published: Dec 16, 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")

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