mirror of
https://github.com/weloe/token-go.git
synced 2025-09-30 13:22:14 +08:00
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package token_go
|
|
|
|
import (
|
|
"github.com/weloe/token-go/ctx"
|
|
"github.com/weloe/token-go/log"
|
|
"github.com/weloe/token-go/model"
|
|
"github.com/weloe/token-go/persist"
|
|
)
|
|
|
|
var _ IEnforcer = &Enforcer{}
|
|
|
|
type IEnforcer interface {
|
|
Login(id string, ctx ctx.Context) (string, error)
|
|
LoginByModel(id string, loginModel *model.Login, ctx ctx.Context) (string, error)
|
|
Logout(ctx ctx.Context) error
|
|
IsLogin(ctx ctx.Context) (bool, error)
|
|
IsLoginById(id string) (bool, error)
|
|
GetLoginId(ctx ctx.Context) (string, error)
|
|
GetLoginCount(id string) int
|
|
|
|
Replaced(id string, device string) error
|
|
// Banned TODO
|
|
Banned(id string, service string) error
|
|
Kickout(id string, device string) error
|
|
|
|
GetRequestToken(ctx ctx.Context) string
|
|
AddTokenGenerateFun(tokenStyle string, f model.GenerateFunc) error
|
|
|
|
CheckLogin(ctx ctx.Context) error
|
|
|
|
SetAuth(manager interface{})
|
|
CheckRole(ctx ctx.Context, role string) error
|
|
CheckPermission(ctx ctx.Context, permission string) error
|
|
|
|
SetType(t string)
|
|
GetType() string
|
|
GetAdapter() persist.Adapter
|
|
SetAdapter(adapter persist.Adapter)
|
|
SetWatcher(watcher persist.Watcher)
|
|
SetLogger(logger log.Logger)
|
|
EnableLog()
|
|
IsLogEnable() bool
|
|
GetSession(id string) *model.Session
|
|
SetSession(id string, session *model.Session, timeout int64) error
|
|
}
|