Documentation
¶
Index ¶
- Constants
- type Access
- type Authentication
- type AuthenticationManager
- type Authenticator
- type AuthenticatorRegistration
- type AuthenticatorRegistry
- type Authorization
- type AuthorizationManager
- type Authorizer
- type AuthorizerRegistration
- type AuthorizerRegistry
- type Configurer
- type Context
- type Holder
- type Identity
- type SecurityContext
- type Session
- type SessionAdapter
- type SessionAdapterFactory
- type SessionContext
- type SessionFactory
- type SessionLoader
- type SessionProvider
- type SessionProviderRegistration
- type SessionProviderRegistry
- type SessionSerializer
- type SessionTransaction
- type Subject
- type SubjectManager
Constants ¶
const ( SessionFieldUserID = "userid" SessionFieldUserName = "username" SessionFieldDisplayName = "displayname" SessionFieldPhone = "phone" SessionFieldEmail = "email" SessionFieldAvatar = "avatar" SessionFieldAuthenticated = "authenticated" )
定义会话中包含的基本字段
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Access ¶
type Access interface {
Path() string
PathPattern() string
Method() string
GetSessionData() []byte
SetSessionData(data []byte)
}
Access 访问参数
type Authentication ¶
Authentication 身份验证请求
type AuthenticationManager ¶
type AuthenticationManager interface {
Authenticate(ctx context.Context, a Authentication) (Identity, error)
}
AuthenticationManager 验证管理器
type Authenticator ¶
type Authenticator interface {
Supports(ctx context.Context, a Authentication) bool
Verify(ctx context.Context, a Authentication) (Identity, error)
}
Authenticator 身份验证器
type AuthenticatorRegistration ¶
type AuthenticatorRegistration struct {
Name string
Authenticator Authenticator
}
AuthenticatorRegistration 身份验证器注册项
type AuthenticatorRegistry ¶
type AuthenticatorRegistry interface {
GetRegistrationList() []*AuthenticatorRegistration
}
AuthenticatorRegistry 身份验证器注册器 【inject:".keeper-authenticator-registry"】
type Authorization ¶
Authorization 授权请求
type AuthorizationManager ¶
type AuthorizationManager interface {
Accept(ctx context.Context, a Authorization) bool
}
AuthorizationManager 授权管理器
type Authorizer ¶
type Authorizer interface {
Supports(ctx context.Context, a Authorization) bool
Accept(ctx context.Context, a Authorization) bool
}
Authorizer 授权者
type AuthorizerRegistration ¶
type AuthorizerRegistration struct {
Name string
Authorizer Authorizer
}
AuthorizerRegistration 授权者注册项
type AuthorizerRegistry ¶
type AuthorizerRegistry interface {
GetRegistrationList() []*AuthorizerRegistration
}
AuthorizerRegistry 授权者注册器 【inject:".keeper-authorizer-registry"】
type Configurer ¶
Configurer 用来配置keeper上下文 【inject:".keeper-configurer"】
type Context ¶
type Context struct {
Authentications AuthenticationManager
Authorizations AuthorizationManager
Subjects SubjectManager
SessionProvider SessionProvider
}
Context 默认的安全上下文
func (*Context) GetAuthentications ¶
func (inst *Context) GetAuthentications() AuthenticationManager
func (*Context) GetAuthorizations ¶
func (inst *Context) GetAuthorizations() AuthorizationManager
func (*Context) GetSessionProvider ¶
func (inst *Context) GetSessionProvider() SessionProvider
func (*Context) GetSubjects ¶
func (inst *Context) GetSubjects() SubjectManager
type Holder ¶
type Holder struct {
// contains filtered or unexported fields
}
Holder 持有会话相关的对象
func (*Holder) GetSessionContext ¶
func (inst *Holder) GetSessionContext() *SessionContext
GetSessionContext 获取会话上下文,如果没有就新建一个
type Identity ¶
type Identity interface {
UserID() string
UserUUID() string
Nickname() string
Avatar() string
Roles() []string
}
Identity 身份
type SecurityContext ¶
type SecurityContext interface {
GetAuthentications() AuthenticationManager
GetAuthorizations() AuthorizationManager
GetSubjects() SubjectManager
GetSessionProvider() SessionProvider
}
SecurityContext 安全上下文
type Session ¶
type Session interface {
GetContext() context.Context
// 可持久化的属性
Properties() collection.Properties
BeginTransaction() SessionTransaction
}
Session 会话
type SessionAdapter ¶
type SessionAdapter interface {
GetContext() context.Context
Load(s Session) error
Store(s Session) error
}
SessionAdapter 会话适配器
type SessionAdapterFactory ¶
type SessionAdapterFactory interface {
Create(ctx context.Context) (SessionAdapter, error)
}
SessionAdapterFactory 会话适配器工厂
type SessionContext ¶
type SessionContext struct {
Access Access
Adapter SessionAdapter
Context context.Context
SecurityContext SecurityContext
Session Session
Subject Subject
}
SessionContext 会话上下文
type SessionFactory ¶
type SessionFactory interface {
Create(adapter SessionAdapter) (Session, error)
}
SessionFactory 会话工厂
type SessionLoader ¶
SessionLoader 会话加载器
type SessionProvider ¶
type SessionProvider interface {
GetSessionFactory() SessionFactory
GetAdapterFactory() SessionAdapterFactory
}
SessionProvider 会话提供商
type SessionProviderRegistration ¶
type SessionProviderRegistration struct {
Name string
Provider SessionProvider
}
SessionProviderRegistration 会话提供商注册项
type SessionProviderRegistry ¶
type SessionProviderRegistry interface {
GetRegistrationList() []*SessionProviderRegistration
}
SessionProviderRegistry 会话提供商注册器 【inject:".keeper-session-provider-registry"】
type SessionSerializer ¶
SessionSerializer 会话存储器
type SessionTransaction ¶
SessionTransaction 表示一个会话的事务
type Subject ¶
type Subject interface {
GetSession() Session
GetAccess() Access
GetContext() context.Context
IsAuthenticated() bool
SetSession(s Session)
SetAccess(a Access)
SetAuthenticated(authenticated bool)
Login(ctx context.Context, a Authentication) (Identity, error)
Logout() error
Authorize(ctx context.Context, a Access) (bool, error)
}
Subject 代表操作的主体