Documentation
¶
Index ¶
- Constants
- type Authentication
- type AuthenticationBuilder
- type Authenticator
- type AuthenticatorManager
- type Authorization
- type AuthorizationBuilder
- type Authorizer
- type AuthorizerManager
- type EmailIdentity
- type Feedback
- type Identity
- type Mechanism
- type PasswordCalculator
- func (inst *PasswordCalculator) Compute(plain []byte) []byte
- func (inst *PasswordCalculator) Reset() *PasswordCalculator
- func (inst *PasswordCalculator) Verify(plain []byte) error
- func (inst *PasswordCalculator) WithSalt(salt []byte) *PasswordCalculator
- func (inst *PasswordCalculator) WithTarget(target []byte) *PasswordCalculator
- type PhoneIdentity
- type Registration
- type Registry
- type Request
- type Service
- type UserIdentity
Constants ¶
const ( ActionLogin = rbac.ActionLogin ActionSignUp = rbac.ActionSignUp ActionResetPassword = rbac.ActionResetPassword ActionChangePassword = rbac.ActionChangePassword ActionSendCode = rbac.ActionSendCode )
定义几种常用的授权动作
const ( MechanismPassword = rbac.MechanismPassword MechanismEmail = rbac.MechanismEmail MechanismPhone = rbac.MechanismSMS MechanismSMS = rbac.MechanismSMS )
定义几种常用的验证机制
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authentication ¶
Authentication 表示一个身份验证请求
type AuthenticationBuilder ¶ added in v1.0.13
type AuthenticationBuilder struct { Context context.Context Action string Attributes attributes.Table Parameters parameters.Table Account string Mechanism string Secret lang.Base64 Step string Feedback Feedback }
AuthenticationBuilder 用于创建 Authentication 实例
func (*AuthenticationBuilder) Create ¶ added in v1.0.13
func (inst *AuthenticationBuilder) Create() Authentication
Create 创建 Authentication 实例
type Authenticator ¶
type Authenticator interface { // 验证用户身份 Authenticate(a Authentication) ([]Identity, error) }
Authenticator 表示一个身份验证算法
type AuthenticatorManager ¶ added in v1.0.22
type AuthenticatorManager interface { FindFor(a Authentication) (Authenticator, error) ListFor(a Authentication) []Authenticator }
AuthenticatorManager ...
type Authorization ¶
Authorization 表示一个授权请求
type AuthorizationBuilder ¶ added in v1.0.10
type AuthorizationBuilder struct { Context context.Context Attributes attributes.Table Parameters parameters.Table Action string Step string Identities []Identity Feedback Feedback }
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 }
Authorizer 表示一个授权组件
type AuthorizerManager ¶ added in v1.0.22
type AuthorizerManager interface { FindFor(a Authorization) (Authorizer, error) ListFor(a Authorization) []Authorizer }
AuthorizerManager ...
type EmailIdentity ¶ added in v1.0.24
type EmailIdentity interface { Identity Address() rbac.EmailAddress }
EmailIdentity 表示基于 email address 的身份信息
func NewEmailIdentity ¶ added in v1.0.24
func NewEmailIdentity(by Authentication, info *rbac.EmailAddressDTO) EmailIdentity
NewEmailIdentity ...
type Feedback ¶ added in v1.0.54
type Feedback interface {
Parameters() parameters.Table
}
Feedback ... 用于向请求方反馈验证信息
type Identity ¶ added in v1.0.22
type Identity interface { Class() string Name() string Mechanism() string By() Authentication }
Identity 表示一个经过验证的身份
type PasswordCalculator ¶
type PasswordCalculator struct {
// contains filtered or unexported fields
}
PasswordCalculator 是默认的密码计算器
func (*PasswordCalculator) Compute ¶
func (inst *PasswordCalculator) Compute(plain []byte) []byte
Compute 计算密码的哈希值
func (*PasswordCalculator) Reset ¶ added in v1.0.20
func (inst *PasswordCalculator) Reset() *PasswordCalculator
Reset ...
func (*PasswordCalculator) Verify ¶
func (inst *PasswordCalculator) Verify(plain []byte) error
Verify 验证密码是否正确
func (*PasswordCalculator) WithSalt ¶ added in v1.0.20
func (inst *PasswordCalculator) WithSalt(salt []byte) *PasswordCalculator
WithSalt ...
func (*PasswordCalculator) WithTarget ¶ added in v1.0.20
func (inst *PasswordCalculator) WithTarget(target []byte) *PasswordCalculator
WithTarget ...
type PhoneIdentity ¶ added in v1.0.24
type PhoneIdentity interface { Identity FullNumber() rbac.FullPhoneNumber }
PhoneIdentity 表示基于 phone number 的身份信息
func NewPhoneIdentity ¶ added in v1.0.24
func NewPhoneIdentity(by Authentication, info *rbac.PhoneNumberDTO) PhoneIdentity
NewPhoneIdentity ...
type Registration ¶
type Registration struct { Authenticator Authenticator Authorizer Authorizer Mechanism Mechanism Priority int Enabled bool }
Registration ... 注册信息
type Request ¶ added in v1.0.14
type Request interface { Context() context.Context Attributes() attributes.Table Parameters() parameters.Table Feedback() Feedback Action() string Step() string }
Request 包含 Authentication 和 Authorization 的公共方法
type Service ¶
type Service interface { Authenticator Authorizer // 验证并授权 Execute(r ...Request) error }
Service ...
type UserIdentity ¶ added in v1.0.24
type UserIdentity interface { Identity UserName() rbac.UserName UserID() rbac.UserID Nickname() string Avatar() string Roles() rbac.RoleNameList }
UserIdentity ...
func NewUserIdentity ¶ added in v1.0.24
func NewUserIdentity(by Authentication, info *rbac.UserDTO) UserIdentity
NewUserIdentity ...