subjects

package module
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 14 Imported by: 0

README

security-web-app

这个模块为 web 应用程序提供支持安全访问的能力

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildModuleForLib

func BuildModuleForLib() *application.ModuleBuilder

func BuildModuleForTest

func BuildModuleForTest() *application.ModuleBuilder

func CheckDTO added in v0.10.0

func CheckDTO(cc context.Context, o rbac.DTORef) error

func CheckEntity added in v0.10.0

func CheckEntity(cc context.Context, o rbac.EntityRef) error

Types

type Adapter

type Adapter interface {
	GetHolder(c context.Context) (*Holder, error)
}

func GetAdapter

func GetAdapter(c context.Context) (Adapter, error)

type Buffer

type Buffer struct {
	Properties properties.Table

	SessionID rbac.SessionID

	SessionUUID dxo.SessionUUID
}

func (*Buffer) HasData

func (inst *Buffer) HasData() bool

func (*Buffer) Init

func (inst *Buffer) Init() *Buffer

func (*Buffer) IsEmpty

func (inst *Buffer) IsEmpty() bool

type Cache

type Cache struct {
	Properties properties.Table

	SessionID rbac.SessionID

	SessionUUID dxo.SessionUUID

	Loaded bool
}

func (*Cache) Ready

func (inst *Cache) Ready() bool

type CacheHolder

type CacheHolder interface {
	GetCache(c *Context) (*Cache, error)
}

type CacheLoader

type CacheLoader interface {
	LoadCache(c *Context) (*Cache, error)
}

type Checker added in v0.0.6

type Checker interface {
	Check() error

	CheckObject(ch *Checking) Checker
	CheckDTO(ref rbac.DTORef) Checker
	CheckEntity(ref rbac.EntityRef) Checker

	AcceptAdmin() Checker
	AcceptAnonymous() Checker
	AcceptAny() Checker
	AcceptOwner() Checker
	AcceptRoot() Checker

	AcceptRole(role rbac.RoleName) Checker
}

type Checking added in v0.0.6

type Checking struct {
	Owner rbac.UserID

	Type string

	Target any
}

type Context

type Context struct {
	CC context.Context

	Cache       *Cache // for reader
	CacheHolder CacheHolder
	CacheLoader CacheLoader

	Buffer *Buffer // for writer

	FlagCreate bool
	FlagDirty  bool

	Facade Subject

	Checker Checker

	Reader ReadFilterChain

	Writer WriteFilterChain

	ChainHolder FilterChainHolder

	Attributes attributes.Table
}

func (*Context) Clone

func (inst *Context) Clone() *Context

func (*Context) GetAttributes

func (inst *Context) GetAttributes(autoMake bool) attributes.Table

func (*Context) GetBuffer

func (inst *Context) GetBuffer(autoMake bool) *Buffer

func (*Context) GetCC

func (inst *Context) GetCC(autoMake bool) context.Context

func (*Context) GetCache

func (inst *Context) GetCache(autoMake bool) *Cache

func (*Context) GetCacheHolder

func (inst *Context) GetCacheHolder(autoMake bool) CacheHolder

func (*Context) GetCacheLoader

func (inst *Context) GetCacheLoader(autoMake bool) CacheLoader

func (*Context) GetChecker added in v0.0.6

func (inst *Context) GetChecker(autoMake bool) Checker

func (*Context) GetFacade

func (inst *Context) GetFacade(autoMake bool) Subject

func (*Context) GetReader

func (inst *Context) GetReader(autoMake bool) ReadFilterChain

func (*Context) GetWriter

func (inst *Context) GetWriter(autoMake bool) WriteFilterChain

func (*Context) NewIOC

func (inst *Context) NewIOC(method Method) *IOC

type FilterChainHolder

type FilterChainHolder interface {
	GetReaderChain() (ReadFilterChain, error)
	GetWriterChain() (WriteFilterChain, error)
}

type FilterChainLoader

type FilterChainLoader interface {
	LoadReaderChain() (ReadFilterChain, error)
	LoadWriterChain() (WriteFilterChain, error)
}

type FilterPriority

type FilterPriority int
const (
	FilterPriorityMin FilterPriority = iota

	FilterPriorityDB
	FilterPriorityCache2 // with redis
	FilterPriorityJWT
	FilterPriorityBuffer
	FilterPriorityCodec
	FilterPriorityGoodResult
	FilterPriorityLog
	FilterPriorityCache1 // with runtime memory

	FilterPriorityMax
)

type FilterRegistration

type FilterRegistration struct {
	Name string

	Enabled bool

	Priority FilterPriority

	Writer WriteFilter

	Reader ReadFilter
}

type FilterRegistry

type FilterRegistry interface {
	GetRegistrationList() []*FilterRegistration
}

type Getter

type Getter interface {
	GetProperty(name PropertyName) string

	Names() []string

	GetSession(se *rbac.SessionDTO) error

	GetToken(tk *rbac.TokenDTO) error

	IsAuthenticated() bool

	GetUserID() rbac.UserID

	GetUserName() rbac.UserName

	GetDisplayName() string

	GetUserEmail() string

	GetLocale() localization.Locale

	GetRoles() rbac.RoleNameList

	GetAvatar() string

	GetNotBefore() lang.Time

	GetNotAfter() lang.Time
}

type Have

type Have struct {

	// base of Have
	Message

	Cache *Cache

	Status int
}

type Holder

type Holder struct {
	Context *Context
}

type IOC

type IOC struct {
	Context *Context

	CC context.Context

	Want Want

	Have Have
}

the Input-Output-Context

type Message

type Message struct {
	SessionID rbac.SessionID

	SessionUUID lang.UUID

	Properties properties.Table // 引用 buffer | cache 中的属性
}

type Method

type Method string
const (
	MethodGet    Method = http.MethodGet
	MethodPut    Method = http.MethodPut
	MethodPost   Method = http.MethodPost
	MethodDelete Method = http.MethodDelete

	MethodReload Method = "RELOAD"
	MethodFlush  Method = "FLUSH"
)

type PropertyName

type PropertyName string
const (
	PNameExample PropertyName = "example"

	PNameAvatar        PropertyName = "avatar"
	PNameNickName      PropertyName = "nickname"
	PNameUserName      PropertyName = "username"
	PNameRoles         PropertyName = "roles"
	PNameAuthenticated PropertyName = "authenticated"

	PNameUserID   PropertyName = "user_id"
	PNameUserUUID PropertyName = "user_uuid"

	PNameSessionID   PropertyName = "session_id"
	PNameSessionUUID PropertyName = "session_uuid"

	PNameNotBefore   PropertyName = "not_before"
	PNameNotAfter    PropertyName = "not_after"
	PNameCreatedAt   PropertyName = "created_at"
	PNameUpdatedAt   PropertyName = "updated_at"
	PNameDeletedAt   PropertyName = "deleted_at"
	PNameMaxTokenAge PropertyName = "max_token_age"

	PNameMobile   PropertyName = "mobile"
	PNameEmail    PropertyName = "email"
	PNameLanguage PropertyName = "language"

	PNameTokenNotAfter  PropertyName = "token_not_after"  // a i64 of millisec
	PNameTokenNotBefore PropertyName = "token_not_before" // a i64 of millisec
	PNameTokenReferID   PropertyName = "token_ref_id"     // a session-id
	PNameTokenReferUUID PropertyName = "token_ref_uuid"   // a session-uuid
)

type ReadFilter

type ReadFilter interface {
	Read(c *IOC, next ReadFilterChain) error
}

type ReadFilterChain

type ReadFilterChain interface {
	Read(c *IOC) error
}

type ReadFilterChainBuilder

type ReadFilterChainBuilder struct {
	// contains filtered or unexported fields
}

func (*ReadFilterChainBuilder) AddRegistration

func (inst *ReadFilterChainBuilder) AddRegistration(r *FilterRegistration)

func (*ReadFilterChainBuilder) AddRegistry

func (inst *ReadFilterChainBuilder) AddRegistry(r FilterRegistry)

func (*ReadFilterChainBuilder) Build

func (*ReadFilterChainBuilder) Len

func (inst *ReadFilterChainBuilder) Len() int

func (*ReadFilterChainBuilder) Less

func (inst *ReadFilterChainBuilder) Less(i1, i2 int) bool

func (*ReadFilterChainBuilder) Swap

func (inst *ReadFilterChainBuilder) Swap(i1, i2 int)

type Setter

type Setter interface {
	SetProperty(name PropertyName, value string)

	SetSession(se *rbac.SessionDTO)

	SetAuthenticated(authenticated bool)

	SetUserID(uid rbac.UserID)

	SetUserName(name rbac.UserName)

	SetUserEmail(addr string)

	SetDisplayName(name string)

	SetRoles(roles rbac.RoleNameList)

	SetLocale(l localization.Locale)

	SetAvatar(l string)

	SetNotBefore(t lang.Time)

	SetNotAfter(t lang.Time)
}

type Subject

type Subject interface {
	GetContext() context.Context

	DoGet() (Getter, error)

	DoSet() (Setter, error)

	DoCheck() (Checker, error)

	SetChecker(c Checker)

	Reload() error

	Load() error

	Update() error

	Create() error

	Flush() error

	Exit() error
}

func GetCurrent

func GetCurrent(c context.Context) (Subject, error)

func NewSubject

func NewSubject(ctx *Context) Subject

type Want

type Want struct {

	// base of Want
	Message

	Buffer *Buffer

	Method Method
}

type WriteFilter

type WriteFilter interface {
	Write(c *IOC, next WriteFilterChain) error
}

type WriteFilterChain

type WriteFilterChain interface {
	Write(c *IOC) error
}

type WriteFilterChainBuilder

type WriteFilterChainBuilder struct {
	// contains filtered or unexported fields
}

func (*WriteFilterChainBuilder) AddRegistration

func (inst *WriteFilterChainBuilder) AddRegistration(r *FilterRegistration)

func (*WriteFilterChainBuilder) AddRegistry

func (inst *WriteFilterChainBuilder) AddRegistry(r FilterRegistry)

func (*WriteFilterChainBuilder) Build

func (*WriteFilterChainBuilder) Len

func (inst *WriteFilterChainBuilder) Len() int

func (*WriteFilterChainBuilder) Less

func (inst *WriteFilterChainBuilder) Less(i1, i2 int) bool

func (*WriteFilterChainBuilder) Swap

func (inst *WriteFilterChainBuilder) Swap(i1, i2 int)

Jump to

Keyboard shortcuts

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