Documentation
¶
Index ¶
- Constants
- type AppUserIdentity
- type Authentication
- type AuthenticationBuilder
- type Authenticator
- type AuthenticatorManager
- type Authorization
- type AuthorizationBuilder
- type Authorizer
- type AuthorizerManager
- type EmailUserIdentity
- 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 PhoneUserIdentity
- type Registration
- type Registry
- type Request
- type Service
Constants ¶
View Source
const ( ActionLogin = rbac.ActionLogin ActionSignUp = rbac.ActionSignUp ActionResetPassword = rbac.ActionResetPassword ActionChangePassword = rbac.ActionChangePassword ActionSendCode = rbac.ActionSendCode )
定义几种常用的授权动作
View Source
const ( MechanismPassword = rbac.MechanismPassword MechanismEmail = rbac.MechanismEmail MechanismPhone = rbac.MechanismPhone )
定义几种常用的验证机制
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppUserIdentity ¶ added in v1.0.22
AppUserIdentity ...
type Authentication ¶
Authentication 表示一个身份验证请求
type AuthenticationBuilder ¶ added in v1.0.13
type AuthenticationBuilder struct { Context context.Context Attributes attributes.Table Parameters parameters.Table Account string Mechanism string Secret lang.Base64 }
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 Identities []Identity }
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 EmailUserIdentity ¶ added in v1.0.22
EmailUserIdentity ...
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 PhoneUserIdentity ¶ added in v1.0.22
PhoneUserIdentity ...
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 }
Request 包含 Authentication 和 Authorization 的公共方法
type Service ¶
type Service interface { Authenticator Authorizer // 验证并授权 Execute(r ...Request) error }
Service ...
Click to show internal directories.
Click to hide internal directories.