Documentation ¶
Index ¶
- Constants
- type GfToken
- func (m *GfToken) AuthPath(urlPath string) bool
- func (m *GfToken) DecryptToken(token string) Resp
- func (m *GfToken) EncryptToken(userKey string, uuid string) Resp
- func (m *GfToken) GetTokenData(r *ghttp.Request) Resp
- func (m *GfToken) InitConfig() bool
- func (m *GfToken) Login(r *ghttp.Request)
- func (m *GfToken) Logout(r *ghttp.Request)
- func (m *GfToken) Middleware(group *ghttp.RouterGroup) bool
- func (m *GfToken) MiddlewareEx(group *ghttp.RouterGroup) bool
- func (m *GfToken) RemoveToken(token string) Resp
- func (m *GfToken) Start() bool
- func (m *GfToken) Stop() bool
- func (m *GfToken) String() string
- type Resp
Constants ¶
View Source
const ( CacheModeCache = 1 CacheModeRedis = 2 MiddlewareTypeGroup = 1 MiddlewareTypeBind = 2 MiddlewareTypeGlobal = 3 )
View Source
const ( SUCCESS = 0 FAIL = -1 ERROR = -99 UNAUTHORIZED = -401 //配置 TypeConfig = 1 // 字典 TypeDict = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GfToken ¶
type GfToken struct { // GoFrame server name ServerName string // 缓存模式 1 gcache 2 gredis 默认1 CacheMode int8 // 缓存key CacheKey string // 超时时间 默认10天(毫秒) Timeout int // 缓存刷新时间 默认为超时时间的一半(毫秒) MaxRefresh int // Token分隔符 TokenDelimiter string // Token加密key EncryptKey []byte // 认证失败中文提示 AuthFailMsg string // 是否支持多端登录,默认false MultiLogin bool // 是否是全局认证,兼容历史版本,已废弃 GlobalMiddleware bool // 中间件类型 1 GroupMiddleware 2 BindMiddleware 3 GlobalMiddleware MiddlewareType uint // 登录路径 LoginPath string // 登录验证方法 return userKey 用户标识 如果userKey为空,结束执行 LoginBeforeFunc func(r *ghttp.Request) (string, interface{}) // 登录返回方法 LoginAfterFunc func(r *ghttp.Request, respData Resp) // 登出地址 LogoutPath string // 登出验证方法 return true 继续执行,否则结束执行 LogoutBeforeFunc func(r *ghttp.Request) bool // 登出返回方法 LogoutAfterFunc func(r *ghttp.Request, respData Resp) // 拦截地址 AuthPaths g.SliceStr // 拦截排除地址 AuthExcludePaths g.SliceStr // 认证验证方法 return true 继续执行,否则结束执行 AuthBeforeFunc func(r *ghttp.Request) bool // 认证返回方法 AuthAfterFunc func(r *ghttp.Request, respData Resp) }
GfToken gtoken结构体
func (*GfToken) DecryptToken ¶
DecryptToken token解密方法
func (*GfToken) EncryptToken ¶
EncryptToken token加密方法
func (*GfToken) GetTokenData ¶
GetTokenData 通过token获取对象
func (*GfToken) MiddlewareEx ¶ added in v1.4.7
func (m *GfToken) MiddlewareEx(group *ghttp.RouterGroup) bool
MiddlewareEx 绑定group,不增加route
Click to show internal directories.
Click to hide internal directories.