Documentation ¶
Index ¶
- Variables
- func InitBuiltinRBACModels() error
- func IsUserLoggedIn(ctx iris.Context) bool
- func PushBuiltinUser(user LoginUser)
- func ValidatePassword(userPassword string, hashed []byte) (bool, error)
- func VerifyAccessControl(ctx iris.Context) (uid string, err error)
- type BlacklistPool
- type BuiltinUser
- type BuiltinUserVerifyManager
- type LoginParam
- type LoginUser
- type LoginVerifier
- type UserController
- func (c *UserController) CurrentUserAppID(ctx iris.Context) string
- func (c *UserController) CurrentUserID(ctx iris.Context) string
- func (c *UserController) Init(app router.Party)
- func (c *UserController) IsLoggedIn(ctx iris.Context) bool
- func (c *UserController) PushAppID(ctx iris.Context, appID string)
- func (c *UserController) PushUID(ctx iris.Context, uid string)
- func (c *UserController) Session(ctx iris.Context) *sessions.Session
- func (c *UserController) Signin(ctx iris.Context)
- func (c *UserController) Signout(ctx iris.Context)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( BaseRouteUsers = "/authenticates" RouteUserSignin = "/signin" RouteUserSignup = "/signup" RouteUserSignout = "/signout" FullLoginURLPath = BaseRouteUsers + RouteUserSignin HeaderAuthorization = "Authorization" HeaderSignature = "Signature" DefaultSignatureAppKey = "" ValidateFailureDurationSecondsThreshold = 60 ValidateFailureCountThreshold = 15 BlockingIPDurationSeconds = 900 SessionExpireHours = 24 // DefaultUsers users<name: password> were used as localhost access DefaultUsers = map[string]string{"guest": "guest"} )
Constants
Functions ¶
func InitBuiltinRBACModels ¶
func InitBuiltinRBACModels() error
InitBuiltinRBACModels syncronize the RBAC model with database
func ValidatePassword ¶
ValidatePassword 将检查密码是否匹配
Types ¶
type BlacklistPool ¶
type BlacklistPool interface { IsBlocked(remoteIP string) bool PushBlocked(remoteIP string, expireTs int64) }
BlacklistPool pool of black ip
func NewBlacklistPool ¶
func NewBlacklistPool() BlacklistPool
type BuiltinUser ¶
type BuiltinUser struct { UserID string `json:"uid"` Name string `json:"name"` AppID string `json:"appId"` PasswordOrHash string `json:"-"` }
BuiltinUser
func (*BuiltinUser) VerifyPassword ¶
func (bu *BuiltinUser) VerifyPassword(passwordOrHash string) bool
VerifyPassword if password matches
type BuiltinUserVerifyManager ¶
type BuiltinUserVerifyManager struct {
// contains filtered or unexported fields
}
func (*BuiltinUserVerifyManager) PushBlocked ¶
func (buv *BuiltinUserVerifyManager) PushBlocked(remoteIP string, expireTs int64)
PushBlocked by remote IP
func (*BuiltinUserVerifyManager) PushUser ¶
func (buv *BuiltinUserVerifyManager) PushUser(user LoginUser)
PushUser for localhost login
func (*BuiltinUserVerifyManager) VerifyUser ¶
func (buv *BuiltinUserVerifyManager) VerifyUser(userName string, passwordOrHash string, remoteIP string) (LoginUser, error)
VerifyUser if user exists or password matches
type LoginParam ¶
type LoginParam struct { Name string `json:"name" form:"name" validate:"required" label:"名称"` Password string `json:"password" form:"password" validate:"required" label:"密码"` }
LoginParam form data
type LoginUser ¶
type LoginUser interface { GetUserID() string GetName() string VerifyPassword(passwordOrHash string) bool }
LoginUser interface of login user information
type LoginVerifier ¶
type LoginVerifier interface { VerifyUser(userName string, passwordOrHash string, remoteIP string) (LoginUser, error) PushBlocked(remoteIP string, expireTs int64) }
LoginVerifier interface of login user validator
var (
UserVerifyManager LoginVerifier = &BuiltinUserVerifyManager{blacklist: NewBlacklistPool()}
)
type UserController ¶
type UserController struct { SessionManager *sessions.Sessions DefaultUsers map[string]builtinmodels.UserModel // contains filtered or unexported fields }
UserController user session controller
func (*UserController) CurrentUserAppID ¶
func (c *UserController) CurrentUserAppID(ctx iris.Context) string
CurrentUserAppID logined with session
func (*UserController) CurrentUserID ¶
func (c *UserController) CurrentUserID(ctx iris.Context) string
CurrentUserID logined with session
func (*UserController) Init ¶
func (c *UserController) Init(app router.Party)
Init with iris application
func (*UserController) IsLoggedIn ¶
func (c *UserController) IsLoggedIn(ctx iris.Context) bool
IsLoggedIn with current session
func (*UserController) PushAppID ¶
func (c *UserController) PushAppID(ctx iris.Context, appID string)
PushAppID on user login
func (*UserController) PushUID ¶
func (c *UserController) PushUID(ctx iris.Context, uid string)
PushUID on user login
Source Files ¶
Click to show internal directories.
Click to hide internal directories.