security

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Access added in v0.0.4

type Access interface {
	SessionID() string
	Path() string
	Method() string

	SetSessionID(sid string)
}

Access 访问参数

type Authentication added in v0.0.4

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

Authentication 身份验证请求

type AuthenticationManager added in v0.0.4

type AuthenticationManager interface {
	Authenticate(ctx context.Context, a Authentication) (Identity, error)
}

AuthenticationManager 验证管理器

type Authenticator added in v0.0.3

type Authenticator interface {
	Supports(ctx context.Context, a Authentication) bool
	Verify(ctx context.Context, a Authentication) (Identity, error)
}

Authenticator 身份验证器

type Authorization added in v0.0.4

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

Authorization 授权请求

type AuthorizationManager added in v0.0.4

type AuthorizationManager interface {
	Accept(ctx context.Context, a Authorization) bool
}

AuthorizationManager 授权管理器

type Authorizer added in v0.0.3

type Authorizer interface {
	Supports(ctx context.Context, a Authorization) bool
	Accept(ctx context.Context, a Authorization) bool
}

Authorizer 授权者

type Context

type Context interface {
	GetAuthenticationManager() AuthenticationManager

	GetAuthorizationManager() AuthorizationManager

	GetSubjectManager() SubjectManager

	GetSessionIDGenerator() SessionIDGenerator
	GetSessionFactory() SessionFactory
	GetSessionManager() SessionManager
}

Context 安全上下文

type Identity added in v0.0.4

type Identity interface {
	UserID() string
	UserUUID() string
	Nickname() string
	Avatar() string
	Roles() []string
}

Identity 身份

type Session

type Session interface {
	GetID() string // the session id

	GetProperty(name string) string
	SetProperty(name, value string)

	GetIdentity() Identity
	SetIdentity(ident Identity)
}

Session 会话

type SessionFactory

type SessionFactory interface {
	CreateSession() Session
}

SessionFactory 会话工厂

type SessionIDGenerator added in v0.0.4

type SessionIDGenerator interface {
	GenerateID() string
}

SessionIDGenerator 会话ID生成器

type SessionManager added in v0.0.3

type SessionManager interface {
	InsertSession(session Session) (Session, error)
	RemoveSession(sid string) error
	UpdateSession(sid string, session Session) (Session, error)
	FindSession(sid string) (Session, error)
}

SessionManager 会话管理器

type Subject added in v0.0.3

type Subject interface {
	GetSession() Session

	GetAccess() Access

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

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

SubjectManager 主体管理器

Jump to

Keyboard shortcuts

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