mirror of
https://github.com/weloe/token-go.git
synced 2025-10-11 10:20:10 +08:00
feat: support add token generate function
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package constant
|
package constant
|
||||||
|
|
||||||
|
// tokenStyle constant
|
||||||
const (
|
const (
|
||||||
UUID = "uuid"
|
UUID = "uuid"
|
||||||
SimpleUUID = "uuid-simple"
|
SimpleUUID = "uuid-simple"
|
||||||
|
@@ -445,6 +445,12 @@ func (e *Enforcer) GetRequestToken(ctx ctx.Context) string {
|
|||||||
return tokenValue
|
return tokenValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddTokenGenerateFun add token generate strategy
|
||||||
|
func (e *Enforcer) AddTokenGenerateFun(tokenStyle string, f model.GenerateFunc) error {
|
||||||
|
e.generateFunc.AddFunc(tokenStyle, f)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (e *Enforcer) GetSession(id string) *model.Session {
|
func (e *Enforcer) GetSession(id string) *model.Session {
|
||||||
if v := e.adapter.Get(e.spliceSessionKey(id)); v != nil {
|
if v := e.adapter.Get(e.spliceSessionKey(id)); v != nil {
|
||||||
session := v.(*model.Session)
|
session := v.(*model.Session)
|
||||||
|
@@ -23,6 +23,7 @@ type IEnforcer interface {
|
|||||||
Kickout(id string, device string) error
|
Kickout(id string, device string) error
|
||||||
|
|
||||||
GetRequestToken(ctx ctx.Context) string
|
GetRequestToken(ctx ctx.Context) string
|
||||||
|
AddTokenGenerateFun(tokenStyle string, f model.GenerateFunc) error
|
||||||
|
|
||||||
CheckLogin(ctx ctx.Context) error
|
CheckLogin(ctx ctx.Context) error
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user