Documentation
¶
Overview ¶
admin/common/authz/adapter.go
admin/common/authz/subject.go
Index ¶
- type Adapter
- func (a *Adapter) AddPolicy(sec string, ptype string, rule []string) error
- func (a *Adapter) LoadPolicy(model model.Model) error
- func (a *Adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
- func (a *Adapter) RemovePolicy(sec string, ptype string, rule []string) error
- func (a *Adapter) SavePolicy(model model.Model) error
- type Subject
- type SubjectBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
func NewAdapter ¶
func (*Adapter) RemoveFilteredPolicy ¶
func (*Adapter) RemovePolicy ¶
type Subject ¶
type Subject struct {
UserID int64 `json:"user_id"`
Username string `json:"username"`
TenantID int64 `json:"tenant_id"` // 当前操作的租户
RoleCodes []string `json:"role_codes"` // 用户在当前租户下的角色code列表
IsPlatform bool `json:"is_platform"` // 是否拥有平台级角色
}
Subject ABAC主体,包含用户的所有授权相关属性
func (*Subject) HasAnyRole ¶
HasAnyRole 检查是否拥有任意一个角色
type SubjectBuilder ¶
type SubjectBuilder struct {
// contains filtered or unexported fields
}
SubjectBuilder 从数据库构建Subject
func NewSubjectBuilder ¶
func NewSubjectBuilder(client *ent.Client) *SubjectBuilder
func (*SubjectBuilder) BuildSubject ¶
func (b *SubjectBuilder) BuildSubject(ctx context.Context, userID int64, tenantID int64) (*Subject, error)
BuildSubject 根据userID和tenantID构建Subject
Click to show internal directories.
Click to hide internal directories.