Documentation
¶
Index ¶
Constants ¶
View Source
const ( ActionLogin = rbac.ActionLogin ActionSignUp = rbac.ActionSignUp ActionResetPassword = rbac.ActionResetPassword ActionChangePassword = rbac.ActionChangePassword )
定义几种常用的授权动作
View Source
const ( MechanismPassword = rbac.MechanismPassword MechanismEmail = rbac.MechanismEmail MechanismPhone = rbac.MechanismPhone )
定义几种常用的验证机制
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authentication ¶
type Authentication interface {
Context() context.Context
Attributes() attributes.Table
Parameters() parameters.Table
Mechanism() string
Account() string
Secret() []byte
}
Authentication 表示一个身份验证请求
type Authenticator ¶
type Authenticator interface {
// 验证用户身份
Authenticate(a Authentication) (*Result, error)
Support(a Authentication) bool
}
Authenticator 表示一个身份验证算法
type Authenticators ¶
type Authenticators interface {
// 验证用户身份
Authenticate(a Authentication) (*Result, error)
}
Authenticators 表示一组身份验证算法
type Authorization ¶
type Authorization interface {
Context() context.Context
Attributes() attributes.Table
Parameters() parameters.Table
User() User
Action() string
}
Authorization 表示一个授权请求
type AuthorizationBuilder ¶ added in v1.0.10
type AuthorizationBuilder struct {
Context context.Context
Attributes attributes.Table
Parameters parameters.Table
User User
Action string
}
AuthorizationBuilder ... 用于创建 Authorization
func (*AuthorizationBuilder) Create ¶ added in v1.0.10
func (inst *AuthorizationBuilder) Create() Authorization
Create ...
type Authorizer ¶
type Authorizer interface {
Authorize(a Authorization) error
Support(a Authorization) bool
}
Authorizer 表示一个授权组件
type Authorizers ¶
type Authorizers interface {
Authorize(a Authorization) error
}
Authorizers 表示一组授权组件
type PasswordCalculator ¶
type PasswordCalculator struct {
// contains filtered or unexported fields
}
PasswordCalculator 是默认的密码计算器
func (*PasswordCalculator) Compute ¶
func (inst *PasswordCalculator) Compute(plain []byte) []byte
Compute 计算密码的哈希值
func (*PasswordCalculator) Init ¶
func (inst *PasswordCalculator) Init(target, salt []byte)
Init ...
func (*PasswordCalculator) Verify ¶
func (inst *PasswordCalculator) Verify(plain []byte) error
Verify 验证密码是否正确
type Registration ¶
type Registration struct {
Authenticator Authenticator
Authorizer Authorizer
Priority int
Enabled bool
}
Registration ... 注册信息
type Service ¶
type Service interface {
Authenticators
Authorizers
Login(c context.Context, a Authentication) (*Result, error)
}
Service ...
type User ¶
type User interface {
ID() rbac.UserID // 用户ID
Name() rbac.UserName // 用户名
Avatar() string // 头像图片的 URL
Roles() rbac.RoleNameList // 角色
DisplayName() string // 显示名称(昵称)
}
User 表示经过验证的用户
type UserBuilder ¶
type UserBuilder struct {
ID rbac.UserID
Name rbac.UserName
Roles rbac.RoleNameList
Avatar string
DisplayName string
}
UserBuilder 用于创建 User 实例
Click to show internal directories.
Click to hide internal directories.