keeper

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 4 Imported by: 4

Documentation

Index

Constants

View Source
const (
	SessionFieldUserID        = "userid"
	SessionFieldUserName      = "username"
	SessionFieldDisplayName   = "displayname"
	SessionFieldPhone         = "phone"
	SessionFieldEmail         = "email"
	SessionFieldAvatar        = "avatar"
	SessionFieldAuthenticated = "authenticated"
	SessionFieldCreatedAt     = "created_at"
	SessionFieldUpdatedAt     = "updated_at"
)

定义会话中包含的基本字段

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

type Authentication interface {
	Mechanism() string
	UserID() string
	UserSecret() []byte
}

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

type Authorization interface {
	Identity() Identity
	Method() string
	Path() string
	PathPattern() string
}

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

type Configurer interface {
	Configure(c *Context) error
}

Configurer 用来配置keeper上下文 【inject:".keeper-configurer"】

type Context

type Context struct {
	Authentications AuthenticationManager

	Authorizations AuthorizationManager

	Subjects SubjectManager

	Permissions PermissionManager

	SessionProvider SessionProvider
}

Context 默认的安全上下文

func (*Context) GetAuthentications

func (inst *Context) GetAuthentications() AuthenticationManager

func (*Context) GetAuthorizations

func (inst *Context) GetAuthorizations() AuthorizationManager

func (*Context) GetPermissions added in v0.1.1

func (inst *Context) GetPermissions() PermissionManager

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 GetHolder

func GetHolder(ctx context.Context) (*Holder, error)

GetHolder 获取会话持有者对象

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 Permission added in v0.1.1

type Permission interface {
	Accept(ctx context.Context, a Access) bool

	AcceptAnonymous() bool
}

Permission 表示一个许可处理器

type PermissionManager added in v0.1.1

type PermissionManager interface {
	FindPermissions(ctx context.Context, a Access) []Permission
}

PermissionManager 许可管理器

type PermissionRegistration added in v0.1.1

type PermissionRegistration struct {
	Methods  []string // 操作方法表达式
	Paths    []string // 资源路径表达式
	Subjects []string // 操作主体表达式

	Permission Permission // 注册时如果为nil,就使用默认的处理器
}

PermissionRegistration 身份验证器注册项

type PermissionRegistry added in v0.1.1

type PermissionRegistry interface {
	GetRegistrationList() []*PermissionRegistration
}

PermissionRegistry 许可注册器 【inject:".keeper-permission-registry"】

type SecurityContext

type SecurityContext interface {
	GetAuthentications() AuthenticationManager

	GetAuthorizations() AuthorizationManager

	GetSubjects() SubjectManager

	GetPermissions() PermissionManager

	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

type SessionLoader interface {
	Load(data []byte) (Session, error)
}

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

type SessionSerializer interface {
	Serialize(s Session) ([]byte, error)
}

SessionSerializer 会话存储器

type SessionTransaction

type SessionTransaction interface {
	io.Closer
	Commit() error
}

SessionTransaction 表示一个会话的事务

type Subject

type Subject interface {
	GetSession(create bool) (Session, error)

	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 代表操作的主体

type SubjectManager

type SubjectManager interface {
	GetSubject(ctx context.Context) (Subject, error)
}

SubjectManager 主体管理器

Directories

Path Synopsis
support

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL