security

package module
v1.0.54 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 6 Imported by: 2

README

security

Starter for using Session Security

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMainModule added in v1.0.45

func NewMainModule() *application.ModuleBuilder

NewMainModule 导出模块[github.com/starter-go/security]

func NewTestModule added in v1.0.45

func NewTestModule() *application.ModuleBuilder

NewTestModule 导出模块[github.com/starter-go/security#test]

Types

type Context added in v1.0.48

type Context struct {
	Parent context.Context

	// token
	DirtyToken   Token // 表示还没有保存的数据集
	Token        Token
	TokenManager TokenManager

	// session
	DirtySession   Session // 表示还没有保存的数据集
	Session        Session
	SessionManager SessionManager
}

Context 包含当前上下文中跟安全问题相关的信息

func (*Context) Flush added in v1.0.48

func (inst *Context) Flush() error

Flush 保存被标记为 dirty 的数据

type ContextFactory added in v1.0.48

type ContextFactory interface {
	CreateContext(parent context.Context) (*Context, error)
}

ContextFactory ...

type Session added in v1.0.20

type Session interface {
	SessionID() rbac.SessionID

	UserID() rbac.UserID

	UUID() lang.UUID

	GetProperties() properties.Table

	SetProperty(name, value string)

	Get() *rbac.SessionDTO

	Set(s *rbac.SessionDTO)

	UserName() rbac.UserName

	Nickname() string

	Avatar() string

	Language() string

	Roles() rbac.RoleNameList

	HasRole(role rbac.RoleName) bool

	Authenticated() bool

	Create() error

	// 提交已修改的内容
	Commit() error
}

Session 代表当前会话

type SessionGetter added in v1.0.48

type SessionGetter interface {
	Get(ctx *Context) (Session, error)
}

SessionGetter ...

type SessionLoader added in v1.0.48

type SessionLoader interface {
	Load(ctx *Context) (Session, error)
}

SessionLoader ...

type SessionManager added in v1.0.48

type SessionManager interface {
	SessionGetter
	SessionSetter
	SessionLoader
	SessionSaver
}

SessionManager ...

type SessionProvider added in v1.0.20

type SessionProvider interface {
	Support(c context.Context) bool
	Current(c context.Context) (Session, error)
}

SessionProvider 会话的实现方案

type SessionRegistration added in v1.0.20

type SessionRegistration struct {
	Name     string
	Enabled  bool
	Priority int
	Provider SessionProvider
}

SessionRegistration 会话方案的注册信息

type SessionRegistry added in v1.0.20

type SessionRegistry interface {
	Registration() *SessionRegistration
}

SessionRegistry 会话方案的注册接口

type SessionSaver added in v1.0.48

type SessionSaver interface {
	Save(ctx *Context, se Session) error
}

SessionSaver ...

type SessionService added in v1.0.20

type SessionService interface {
	GetCurrent(c context.Context) (Session, error)
}

SessionService 是针对 SessionDTO 的服务

type SessionSetter added in v1.0.48

type SessionSetter interface {
	Set(ctx *Context, se Session) error
}

SessionSetter ...

type Token added in v1.0.48

type Token interface {
	Get() *rbac.TokenDTO

	Set(t *rbac.TokenDTO)

	GetProperties() properties.Table

	SetProperty(name, value string)

	SetSessionID(sid rbac.SessionID)

	GetSessionID() rbac.SessionID

	Roles() rbac.RoleNameList

	HasRole(role rbac.RoleName) bool

	// 提交已修改的内容
	Commit() error
}

Token ... 表示一个安全令牌

type TokenGetter added in v1.0.48

type TokenGetter interface {
	Get(ctx *Context) (Token, error)
}

TokenGetter ...

type TokenLoader added in v1.0.48

type TokenLoader interface {
	Load(ctx *Context) (Token, error)
}

TokenLoader ...

type TokenManager added in v1.0.48

type TokenManager interface {
	TokenGetter
	TokenSetter
	TokenLoader
	TokenSaver
}

TokenManager ...

type TokenSaver added in v1.0.48

type TokenSaver interface {
	Save(ctx *Context, t Token) error
}

TokenSaver ...

type TokenSetter added in v1.0.48

type TokenSetter interface {
	Set(ctx *Context, t Token) error
}

TokenSetter ...

Directories

Path Synopsis
gen
modules
src
configen command
test command

Jump to

Keyboard shortcuts

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