Documentation ¶
Overview ¶
Package authenticator 用户验证
Index ¶
- Variables
- type Authenticator
- type Authenticators
- func (a *Authenticators) All(p *message.Printer) map[string]string
- func (a *Authenticators) GC(now time.Time) error
- func (a *Authenticators) Identities(uid int64) map[string]string
- func (a *Authenticators) IdentityExpired(id, identity string) bool
- func (a *Authenticators) Register(id string, auth Authenticator, name web.LocaleStringer)
- func (a *Authenticators) Valid(id, identity, password string) (int64, string, bool)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrExists = errors.New("user already exists") )
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator interface { // Valid 验证账号 // // username, password 向验证器提供的登录凭证,不同的实现对此两者的定义可能是不同的, // 比如 oauth2 中表示的是由 authURL 返回的 state 和 code 参数。 // ok 表示是否验证成功; // uid 表示验证成功之后返回与 username 关联的用户 ID; // identity 表示验证成功,但是并未与任何 uid 绑定时,则返回该验证器验证之后的用户标记; Valid(username, password string) (uid int64, identity string, ok bool) // Identity 获取 uid 关联的账号名 Identity(int64) (string, bool) }
Authenticator 身份验证接口
type Authenticators ¶
type Authenticators struct {
// contains filtered or unexported fields
}
Authenticators 验证器管理
func NewAuthenticators ¶
NewAuthenticators 声明 Authenticators 对象
d 每个验证失败的 ID 过期时间同时也是回收的频率; jobTitle 回收方法的名称;
func (*Authenticators) All ¶
func (a *Authenticators) All(p *message.Printer) map[string]string
All 返回所有的验证器
func (*Authenticators) Identities ¶
func (a *Authenticators) Identities(uid int64) map[string]string
Identities 获取 uid 已经关联的验证器
返回值键名为验证器 id,键值为该验证器对应的账号。
func (*Authenticators) IdentityExpired ¶
func (a *Authenticators) IdentityExpired(id, identity string) bool
IdentityExpired 验证由 [Authenticator.Valid] 返回的值是否还能使用
func (*Authenticators) Register ¶
func (a *Authenticators) Register(id string, auth Authenticator, name web.LocaleStringer)
Register 注册验证器
id 为验证器的类型名称,需要唯一; name 为该验证器的本地化名称; logo 为该验证器的 LOGO;
func (*Authenticators) Valid ¶
func (a *Authenticators) Valid(id, identity, password string) (int64, string, bool)
Valid 验证账号密码
id 表示通过 Authenticators.Register 注册验证器时的 id;
Click to show internal directories.
Click to hide internal directories.