BaseToken2

package
v5.1.37 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//OpenSub 是否启动订阅
	OpenSub = false
)

Functions

func Check

func Check(action, urlAction, timestamp, nonce, secretID, signatureKey, signatureMethod string) (tokenID int64, err error)

Check 检查token

func CheckByKey

func CheckByKey(action, urlAction, timestamp, nonce, secretID, signatureKey, signatureMethod, key string) (err error)

CheckByKey 计算密钥数据包 原先位于RouterMid中间件声明 action/timestamp/nonce/secretID/signatureKey/signatureMethod 为header头部提交的数据 urlAction 实际接口地址 key 密钥数据

func CheckTokenS

func CheckTokenS(val string) (b bool)

CheckTokenS 检查是否合法

func Create

func Create(args *ArgsCreate) (tokenID int64, errCode string, err error)

Create 创建token

func CreateTokenS

func CreateTokenS(tokenID int64) (val string)

CreateTokenS 生成一个短会话地址

func DeleteToken

func DeleteToken(id int64)

DeleteToken 清理token

func DeleteTokenByLoginFrom

func DeleteTokenByLoginFrom(loginFrom string)

DeleteTokenByLoginFrom 剔除指定登录渠道的所有会话

func DeleteTokenSByTokenID

func DeleteTokenSByTokenID(tokenID int64) (err error)

DeleteTokenSByTokenID 删除tokenID对应的所有短地址

func Init

func Init()

func SelectOrgAndBindID

func SelectOrgAndBindID(id int64, orgID int64, orgBindID int64) (err error)

SelectOrgAndBindID 选择组织和组织成员

func UpdateExpire

func UpdateExpire(args *ArgsUpdateExpire) error

UpdateExpire 更新过期时间

Types

type ArgsCreate

type ArgsCreate struct {
	//用户ID
	UserID int64 `db:"user_id" json:"userID"`
	//组织ID
	OrgID int64 `db:"org_id" json:"orgID"`
	//组织绑定成员ID
	OrgBindID int64 `db:"org_bind_id" json:"orgBindID"`
	//设备ID
	DeviceID int64 `db:"device_id" json:"deviceID"`
	//登录渠道
	LoginFrom string `db:"login_from" json:"loginFrom"`
	//IP地址
	IP string `db:"ip" json:"ip"`
	//key
	// 钥匙,用于配对
	// 用户模式下,采用用户密码+SHA1计算后得出
	// 设备模式下,直接使用设备的key实现
	// 如果不提供,则自动生成并反馈数据
	Key string `db:"key" json:"key"`
	//是否记住我
	// 会延长过期时间
	IsRemember bool `db:"is_remember" json:"isRemember"`
}

ArgsCreate 创建token参数

type ArgsGetList

type ArgsGetList struct {
	//分页
	Pages CoreSQLPages.ArgsDataList `json:"pages"`
	//用户ID
	UserID int64 `json:"userID" check:"id" empty:"true"`
	//组织ID
	OrgID int64 `json:"orgID" check:"id" empty:"true"`
	//组织成员ID
	OrgBindID int64 `json:"orgBindID" check:"id" empty:"true"`
	//设备ID
	DeviceID int64 `json:"deviceID" check:"id" empty:"true"`
	//登录渠道
	LoginFrom string `json:"loginFrom" check:"mark" empty:"true"`
	//搜索
	Search string `json:"search" check:"search" empty:"true"`
}

ArgsGetList 获取列表参数

type ArgsUpdateExpire

type ArgsUpdateExpire struct {
	//ID
	ID int64
	//过期时间
	// 请使用RFC3339Nano结构时间,eg: 2020-11-03T08:31:13.314Z
	// JS中使用new Date().toISOString()
	ExpireAt string
}

ArgsUpdateExpire 更新过期时间参数

type FieldsToken

type FieldsToken struct {
	//ID
	ID int64 `db:"id" json:"id"`
	//创建时间
	CreateAt time.Time `db:"create_at" json:"createAt"`
	//过期时间
	ExpireAt time.Time `db:"expire_at" json:"expireAt"`
	//key
	// 钥匙,用于配对
	Key string `db:"key" json:"key"`
	//用户ID
	UserID int64 `db:"user_id" json:"userID"`
	//组织ID
	OrgID int64 `db:"org_id" json:"orgID"`
	//组织绑定成员ID
	OrgBindID int64 `db:"org_bind_id" json:"orgBindID"`
	//设备ID
	DeviceID int64 `db:"device_id" json:"deviceID"`
	//登录渠道
	LoginFrom string `db:"login_from" json:"loginFrom"`
	//IP地址
	IP string `db:"ip" json:"ip"`
	//是否记住我
	// 会延长过期时间
	IsRemember bool `db:"is_remember" json:"isRemember"`
}

FieldsToken 会话结构体

func GetByFrom

func GetByFrom(userID, deviceID int64, loginFrom string) (data FieldsToken)

GetByFrom 根据来源获取token

func GetByID

func GetByID(id int64) (data FieldsToken)

GetByID 获取指定token

func GetList

func GetList(args *ArgsGetList) (dataList []FieldsToken, dataCount int64, err error)

GetList 获取列表

func GetTokenByS

func GetTokenByS(val string) (data FieldsToken)

GetTokenByS 获取对应值的会话

type FieldsTokenS

type FieldsTokenS struct {
	//ID
	ID int64 `db:"id" json:"id"`
	//创建时间
	CreateAt time.Time `db:"create_at" json:"createAt"`
	//绑定会话ID
	TokenID int64 `db:"token_id" json:"tokenID"`
	//匹配值
	Val string `db:"val" json:"val"`
}

FieldsTokenS 短验证模块表 用于浏览器URL注入字符串形式,验证访问的有效性

Jump to

Keyboard shortcuts

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