authx

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameJwt = "jwt"
)

Variables

This section is empty.

Functions

func RegisterAuth

func RegisterAuth(name string, auth Auth)

Types

type Auth

type Auth interface {
	// GenerateToken 用于生成认证 Token
	GenerateToken(kv map[string]interface{}, expired time.Duration) (string, error)

	// ValidateToken 用于验证 Token,并返回用户 ID
	ValidateToken(token string) (map[string]interface{}, error)
}

Auth 是一个认证接口,可以支持 Session 或 JWT

func GetAuth

func GetAuth(name string) Auth

type JWT

type JWT struct{}

func (*JWT) GenerateToken

func (j *JWT) GenerateToken(kv map[string]interface{}, expired time.Duration) (string, error)

func (*JWT) ValidateToken

func (j *JWT) ValidateToken(token string) (map[string]interface{}, error)

Jump to

Keyboard shortcuts

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