tokenx

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Memory = iota
	Redis
)
View Source
const (
	Jwt = iota
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomClaims

type CustomClaims struct {
	UserId   string
	UserInfo map[string]interface{}
	jwt.StandardClaims
}

type GeneratorType

type GeneratorType int

type ManagerType

type ManagerType int

type TokenGenerator

type TokenGenerator interface {
	Generate(userId string, userInfo map[string]interface{}, expireAt int64) (tokens string, err *errors.Error)
	Parse(token string) (*CustomClaims, *errors.Error)
}

type TokenManager

type TokenManager interface {
	Record(userToken string, userInfo map[string]interface{}) bool
	GenerateAndRecord(userId string, userInfo map[string]interface{}, expireAt int64) (tokens string, err *errors.Error)
	IsNotExpired(token string, allowSec int64) (*CustomClaims, int)
	IsMeetRefresh(token string) bool
	Refresh(oldToken, newToken string) bool
	IsEffective(token string) bool
	Destroy(token string)
	GetUserID(token string) (userID string, exist bool)
	CleanAll()
	Clean(userId string)
}

type TokenService

type TokenService struct {
	Generator TokenGenerator
	Manager   TokenManager
}

func Get

func Get(generatorType GeneratorType, managerType ManagerType) *TokenService

func GetDef

func GetDef() *TokenService

Jump to

Keyboard shortcuts

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