guard

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blacklist

type Blacklist interface {
	Black(string, time.Duration) error // 将牌照加入黑名单
	Checklist(string) (bool, error)    // 检查牌照是否在黑名单列表中
}

Blacklist 黑名单列表

type Guard

type Guard interface {
	License(*User) (string, error) // 发行牌照
	GetLicense(Type, int64) ([]string, error)
	Verify(string) (*User, error) // 验证牌照
	Cancellation(string) error    // 吊销牌照
	ExpiresAt(string) int64       // 获取牌照有效时间
	IssuerAt(string) int64        // 获取牌照发行时间
}

Guard API 入口守卫

type Store

type Store interface {
	GetTokenDetail(license string) (*TokenDetail, error)     // 通过 token 获取 token 的详细信息
	GetTokenByUid(uType Type, uid int64) (*UserToken, error) // 通过用户类型及用户的 uid 获取用户的 token 列表
	Save(license string, tokenDetail *TokenDetail) error     // 保存用户的 token
	Expired(license string) error                            // 将用户 token 过期
	Exist(license string) bool                               // 检查 token 是否存在
}

type TokenDetail added in v1.6.2

type TokenDetail struct {
	User
	Token     string `json:"token"`
	ExpiredAt int64  `json:"expired_at"`
	IssuerAt  int64  `json:"issuer_at"`
}

type Type added in v1.6.2

type Type int
const (
	Admin   Type = iota + 1 // 后台管理员
	General                 // 普通用户
)

type User

type User struct {
	Uid  int64 `json:"uid"`
	Type Type  `json:"type"`
}

type UserToken

type UserToken struct {
	Tokens []string `json:"tokens"`
}

func (*UserToken) Deserialize

func (ut *UserToken) Deserialize(utJson string) error

func (*UserToken) Serialize

func (ut *UserToken) Serialize() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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