jwt

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenExpired     = errors.New("Token 已过期")
	TokenNotValidYet = errors.New("Token 未激活")
	TokenMalformed   = errors.New("这不是 Token")
	TokenInvalid     = errors.New("无法解析的 Token")
	SignKey          = []byte(config.C.Jwt.SignKey)
)

一些常量

Functions

func CreateLongToken

func CreateLongToken(uid string) (*customClaims, string, error)

CreateToken 生成一个token

func CreateToken

func CreateToken(uid string) (string, error)

CreateToken 生成一个token

func ParseToken

func ParseToken(tokenString string) (*customClaims, error)

解析Token

func RefreshToken

func RefreshToken(tokenString string, appid int) (string, error)

更新token

Types

type OBSAuthToken

type OBSAuthToken struct {
	Code    int              `json:"code"`
	Data    OBSAuthTokenData `json:"data"`
	Message string           `json:"message"`
}

OBS 企业服务总线token认证接口返回数据结构

type OBSAuthTokenData

type OBSAuthTokenData struct {
	ExpiresIn int    `json:"expires_in"`
	Token     string `json:"token"`
}

type TokenField

type TokenField struct {
	AppId      string `json:"app_id"`
	UserId     string `json:"user_id"`
	Platform   string `json:"platform"`
	DeviceId   string `json:"device_id"`
	DeviceName string `json:"device_name"`
	UserName   string `json:"user_name"`
	RealName   string `json:"real_name"`
	UserType   string `json:"user_type"`
}

func ParseTokenFromRedis

func ParseTokenFromRedis(tokenString string) (*TokenField, error)

解析Token

func (*TokenField) RetMap added in v1.4.9

func (tf *TokenField) RetMap() map[string]interface{}

func (*TokenField) RetStruct added in v1.4.9

func (tf *TokenField) RetStruct(tfmap map[string]string) error

type TokenFieldOption added in v1.4.9

type TokenFieldOption func(o *TokenField)

Option for web

func AppId added in v1.4.9

func AppId(n string) TokenFieldOption

func DeviceId added in v1.4.9

func DeviceId(n string) TokenFieldOption

func DeviceName added in v1.4.11

func DeviceName(n string) TokenFieldOption

func Platform added in v1.4.9

func Platform(n string) TokenFieldOption

func RealName added in v1.4.9

func RealName(n string) TokenFieldOption

func UserId added in v1.4.9

func UserId(n string) TokenFieldOption

func UserName added in v1.4.9

func UserName(n string) TokenFieldOption

func UserType added in v1.4.9

func UserType(n string) TokenFieldOption

type TokenFieldService added in v1.4.9

type TokenFieldService interface {
	RetMap() map[string]interface{}
	RetStruct(map[string]string) error
}

func NewTokenField added in v1.4.9

func NewTokenField(opts ...TokenFieldOption) TokenFieldService

NewService returns a new web.Service

Jump to

Keyboard shortcuts

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