Documentation ¶
Index ¶
- func NewDefaultAdapter() persist.Adapter
- func NewHttpContext(req *http.Request, writer http.ResponseWriter) ctx.Context
- type Enforcer
- func InitWithConfig(tokenConfig *config.TokenConfig, adapter persist.Adapter) (*Enforcer, error)
- func InitWithDefaultConfig(adapter persist.Adapter) (*Enforcer, error)
- func InitWithFile(conf string, adapter persist.Adapter) (*Enforcer, error)
- func NewEnforcer(adapter persist.Adapter, args ...interface{}) (*Enforcer, error)
- func (e *Enforcer) AddTokenGenerateFun(tokenStyle string, f model.GenerateFunc) error
- func (e *Enforcer) Banned(id string, service string) error
- func (e *Enforcer) CheckLogin(ctx ctx.Context) error
- func (e *Enforcer) CheckPermission(ctx ctx.Context, permission string) error
- func (e *Enforcer) CheckRole(ctx ctx.Context, role string) error
- func (e *Enforcer) EnableLog()
- func (e *Enforcer) GetAdapter() persist.Adapter
- func (e *Enforcer) GetLoginCount(id string) int
- func (e *Enforcer) GetLoginId(ctx ctx.Context) (string, error)
- func (e *Enforcer) GetRequestToken(ctx ctx.Context) string
- func (e *Enforcer) GetSession(id string) *model.Session
- func (e *Enforcer) GetType() string
- func (e *Enforcer) IsLogEnable() bool
- func (e *Enforcer) IsLogin(ctx ctx.Context) (bool, error)
- func (e *Enforcer) IsLoginById(id string) (bool, error)
- func (e *Enforcer) Kickout(id string, device string) error
- func (e *Enforcer) Login(id string, ctx ctx.Context) (string, error)
- func (e *Enforcer) LoginByModel(id string, loginModel *model.Login, ctx ctx.Context) (string, error)
- func (e *Enforcer) Logout(ctx ctx.Context) error
- func (e *Enforcer) Replaced(id string, device string) error
- func (e *Enforcer) SetAdapter(adapter persist.Adapter)
- func (e *Enforcer) SetAuth(manager interface{})
- func (e *Enforcer) SetLogger(logger log.Logger)
- func (e *Enforcer) SetSession(id string, session *model.Session, timeout int64) error
- func (e *Enforcer) SetType(t string)
- func (e *Enforcer) SetWatcher(watcher persist.Watcher)
- type IEnforcer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDefaultAdapter ¶
func NewHttpContext ¶
Types ¶
type Enforcer ¶
type Enforcer struct {
// contains filtered or unexported fields
}
func InitWithConfig ¶
func NewEnforcer ¶
func (*Enforcer) AddTokenGenerateFun ¶
func (e *Enforcer) AddTokenGenerateFun(tokenStyle string, f model.GenerateFunc) error
AddTokenGenerateFun add token generate strategy
func (*Enforcer) CheckPermission ¶
func (*Enforcer) GetAdapter ¶
func (*Enforcer) GetLoginCount ¶
func (*Enforcer) GetRequestToken ¶
GetRequestToken read token from requestHeader | cookie | requestBody
func (*Enforcer) IsLogEnable ¶
func (*Enforcer) IsLoginById ¶
IsLoginById check if user logged in by loginId. check all tokenValue and if one is validated return true
func (*Enforcer) LoginByModel ¶
func (e *Enforcer) LoginByModel(id string, loginModel *model.Login, ctx ctx.Context) (string, error)
LoginByModel login by id and loginModel, return tokenValue and error
func (*Enforcer) SetAdapter ¶
func (*Enforcer) SetSession ¶
func (*Enforcer) SetWatcher ¶
type IEnforcer ¶
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 }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.