Documentation ¶
Index ¶
- type BaseCfg
- type CacheCfg
- type Config
- type MongodbCfg
- type Service
- func (self *Service) BearerAuth(r *http.Request) (string, bool)
- func (self *Service) CheckUser(ctx context.Context, username string) (int64, error)
- func (self *Service) CreateToken(ctx context.Context, u model.User, ip, userAgent string, ...) (m help.M, err error)
- func (self *Service) CreateUser(ctx context.Context, id primitive.ObjectID, username, password string, ...) (primitive.ObjectID, error)
- func (self *Service) DeleteTokenByToken(tokenID primitive.ObjectID, r *http.Request) (err error)
- func (self *Service) DeleteTokenByUsernameAndPassword(ctx context.Context, tokenID primitive.ObjectID, username, password string) error
- func (self *Service) GetClaims(r *http.Request) (claims *predefined.JWTTokenClaims)
- func (self *Service) GetTokensByToken(r *http.Request) (ts []help.M, err error)
- func (self *Service) GetTokensByUsernameAndPassword(ctx context.Context, username, password string) (ts []help.M, err error)
- func (self *Service) GetUserInfo(r *http.Request) (u model.User, found bool)
- func (self *Service) GetValidClaims(r *http.Request) (claims *predefined.JWTTokenClaims, u model.User)
- func (self *Service) Login(ctx context.Context, username, password, ip, userAgent string, ...) (m help.M, err error)
- func (self *Service) LoginByUserID(ctx context.Context, userID primitive.ObjectID, ip, userAgent string, ...) (m help.M, err error)
- func (self *Service) Logout(r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseCfg ¶
type BaseCfg struct { DefaultRole string `json:"default_role"` DefaultTag string `json:"default_tag"` DefaultLevel int `json:"default_level"` CheckLogin bool `json:"check_login"` TokenByUrlQuery bool `json:"token_by_url_query"` TokenByUrlQueryName string `json:"token_by_url_query_name"` IgnoreCheckLoginPath map[string][]string `json:"ignore_check_login_path"` TokenExpireDuration config.Duration `json:"token_expire_duration"` SpecifyUserIDTokenExpireDuration map[string]config.Duration `json:"specify_user_id_token_expire_duration"` //特别指定user_id的token过期时间 OnlySingleLogin bool `json:"only_single_login"` //设置后,allow_multi_login,allow_multi_login_num不起作用 OnlySingleLoginUserID []string `json:"only_single_login_user_id"` //不受only_single_login控制,设置后的user_id将使allow_multi_login,allow_multi_login_num不起作用 OnlySingleLoginUserIDUnlimited []string `json:"only_single_login_user_id_unlimited"` //不受only_single_login控制,设置后的user_id受allow_multi_login,allow_multi_login_num影响 AllowMultiLogin bool `json:"allow_multi_login"` AllowMultiLoginNum int64 `json:"allow_multi_login_num"` AllowMultiLoginUserIDUnlimited []string `json:"allow_multi_login_user_id_unlimited"` //在允许allow_multi_login的情况下,设置后的user_id不受allow_multi_login_num限制 }
type Config ¶
type Config struct { MongodbCfg CacheCfg BaseCfg }
type MongodbCfg ¶
type Service ¶
func (*Service) CreateToken ¶
func (*Service) CreateUser ¶
func (*Service) DeleteTokenByToken ¶
func (*Service) DeleteTokenByUsernameAndPassword ¶
func (*Service) GetClaims ¶
func (self *Service) GetClaims(r *http.Request) (claims *predefined.JWTTokenClaims)
func (*Service) GetTokensByToken ¶
func (*Service) GetTokensByUsernameAndPassword ¶
func (*Service) GetUserInfo ¶
func (*Service) GetValidClaims ¶
func (self *Service) GetValidClaims(r *http.Request) (claims *predefined.JWTTokenClaims, u model.User)
func (*Service) LoginByUserID ¶
Click to show internal directories.
Click to hide internal directories.