token

package
v0.0.0-...-2cc2fc2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assemble

func Assemble(header, payload, sign string) string

Assemble 组合

func Decode

func Decode(str string) string

Decode URL字符串转JSON

func Disassemble

func Disassemble(token string) []string

Disassemble 结构

func Encode

func Encode[T []byte | string](json T) string

Encode JSON转URL字符串

func Generator

func Generator(header, payload string) string

Generator 构造完整Token

func Jwt

func Jwt(opts ...OptionsFunc) gin.HandlerFunc

Jwt 获取Json web token

Types

type JWT

type JWT struct {
	Data   map[string]any
	Signed bool
	// contains filtered or unexported fields
}

func Default

func Default(c *gin.Context) (*JWT, bool)

Default 从gin context中获取JWT数据

func (*JWT) Get

func (jwt *JWT) Get(key string) any

Get 获取jwt中的数据

func (*JWT) Parse

func (jwt *JWT) Parse(verifySign bool) (err error)

Parse 解析Token中的数据 @params verifySign: 是否验证签名,只有验证签名才可以解析并读取payload中的数据

type OptionsFunc

type OptionsFunc func(option *options)

func OptAuthFunc

func OptAuthFunc(value func(*JWT) error) OptionsFunc

OptAuthFunc 验证数据方法

func OptMustFetchToken

func OptMustFetchToken(value bool) OptionsFunc

OptMustFetchToken 是否必须携带Token数据

func OptVerifySign

func OptVerifySign(value bool) OptionsFunc

OptVerifySign 是否需要验证登录签名

Jump to

Keyboard shortcuts

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