Documentation
¶
Index ¶
- Constants
- type CreatePolicyRequest
- type DeletePolicyRequest
- type DescribePolicyRequest
- type PermissionService
- type Policy
- type PolicyService
- type QueryEndpointRequest
- type QueryMenuRequest
- type QueryNamespaceRequest
- type QueryPolicyRequest
- func (r *QueryPolicyRequest) SetEnabled(v bool) *QueryPolicyRequest
- func (r *QueryPolicyRequest) SetExpired(v bool) *QueryPolicyRequest
- func (r *QueryPolicyRequest) SetNamespaceId(nsId uint64) *QueryPolicyRequest
- func (r *QueryPolicyRequest) SetSkipPage(v bool) *QueryPolicyRequest
- func (r *QueryPolicyRequest) SetUserId(uid uint64) *QueryPolicyRequest
- func (r *QueryPolicyRequest) SetWithRole(v bool) *QueryPolicyRequest
- func (r *QueryPolicyRequest) SetWithUser(v bool) *QueryPolicyRequest
- func (r *QueryPolicyRequest) SetWithUsers(v bool) *QueryPolicyRequest
- type Service
- type UpdatePolicyRequest
- type ValidateEndpointPermissionRequest
- type ValidateEndpointPermissionResponse
- type ValidatePagePermissionRequest
- type ValidatePagePermissionResponse
Constants ¶
View Source
const (
AppName = "policy"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreatePolicyRequest ¶
type CreatePolicyRequest struct { // 创建者 CreateBy uint64 `json:"create_by" bson:"create_by" gorm:"column:create_by;type:uint" description:"创建者" optional:"true"` // 空间 NamespaceId *uint64 `` /* 144-byte string literal not displayed */ // 用户Id UserId uint64 `` /* 129-byte string literal not displayed */ // 角色Id RoleId uint64 `` /* 129-byte string literal not displayed */ // 访问范围, 需要提前定义scope, 比如环境 Scope map[string]string `json:"scope" bson:"scope" gorm:"column:scope;serializer:json;type:json" description:"数据访问的范围" optional:"true"` // 策略过期时间 ExpiredTime *time.Time `` /* 136-byte string literal not displayed */ // 只读策略, 不允许用户修改, 一般用于系统管理 ReadOnly bool `` /* 165-byte string literal not displayed */ // 该策略是否启用 Enabled bool `json:"enabled" bson:"enabled" gorm:"column:enabled;type:tinyint(1)" description:"该策略是否启用" optional:"true"` // 策略标签 Label string `json:"label" gorm:"column:label;type:varchar(200);index" description:"策略标签" optional:"true"` // 扩展信息 Extras map[string]string `json:"extras" bson:"extras" gorm:"column:extras;serializer:json;type:json" description:"扩展信息" optional:"true"` }
func NewCreatePolicyRequest ¶
func NewCreatePolicyRequest() *CreatePolicyRequest
func (*CreatePolicyRequest) Validate ¶
func (r *CreatePolicyRequest) Validate() error
type DeletePolicyRequest ¶
type DeletePolicyRequest struct {
apps.GetRequest
}
func NewDeletePolicyRequest ¶
func NewDeletePolicyRequest() *DeletePolicyRequest
type DescribePolicyRequest ¶
type DescribePolicyRequest struct {
apps.GetRequest
}
func NewDescribePolicyRequest ¶
func NewDescribePolicyRequest() *DescribePolicyRequest
type PermissionService ¶
type PermissionService interface { // 查询用户可以访问的空间 QueryNamespace(context.Context, *QueryNamespaceRequest) (*types.Set[*namespace.Namespace], error) // 查询用户可以访问的菜单 QueryMenu(context.Context, *QueryMenuRequest) (*types.Set[*view.Menu], error) // 查询用户可以访问的Api接口 QueryEndpoint(context.Context, *QueryEndpointRequest) (*types.Set[*endpoint.Endpoint], error) // 校验页面权限 ValidatePagePermission(context.Context, *ValidatePagePermissionRequest) (*ValidatePagePermissionResponse, error) // 校验接口权限 ValidateEndpointPermission(context.Context, *ValidateEndpointPermissionRequest) (*ValidateEndpointPermissionResponse, error) }
type Policy ¶
type Policy struct { // 基础数据 apps.ResourceMeta // 策略定义 CreatePolicyRequest // 关联空间 Namespace *namespace.Namespace `json:"namespace,omitempty" gorm:"-"` // 关联用户 User *user.User `json:"user,omitempty" gorm:"-"` // 关联角色 Role *role.Role `json:"role,omitempty" gorm:"-"` }
type PolicyService ¶
type PolicyService interface { // 创建策略 CreatePolicy(context.Context, *CreatePolicyRequest) (*Policy, error) // 查询策略列表 QueryPolicy(context.Context, *QueryPolicyRequest) (*types.Set[*Policy], error) // 查询详情 DescribePolicy(context.Context, *DescribePolicyRequest) (*Policy, error) // 更新策略 UpdatePolicy(context.Context, *UpdatePolicyRequest) (*Policy, error) // 删除策略 DeletePolicy(context.Context, *DeletePolicyRequest) (*Policy, error) }
type QueryEndpointRequest ¶
type QueryEndpointRequest struct { UserId uint64 `json:"user_id"` NamespaceId uint64 `json:"namespace_id"` }
func NewQueryEndpointRequest ¶
func NewQueryEndpointRequest() *QueryEndpointRequest
func (*QueryEndpointRequest) SetNamespaceId ¶
func (r *QueryEndpointRequest) SetNamespaceId(v uint64) *QueryEndpointRequest
func (*QueryEndpointRequest) SetUserId ¶
func (r *QueryEndpointRequest) SetUserId(v uint64) *QueryEndpointRequest
type QueryMenuRequest ¶
type QueryMenuRequest struct { UserId uint64 `json:"user_id"` NamespaceId uint64 `json:"namespace_id"` }
func NewQueryMenuRequest ¶
func NewQueryMenuRequest() *QueryMenuRequest
type QueryNamespaceRequest ¶
type QueryNamespaceRequest struct { UserId uint64 `json:"user_id"` NamespaceId uint64 `json:"namespace_id"` }
func NewQueryNamespaceRequest ¶
func NewQueryNamespaceRequest() *QueryNamespaceRequest
func (*QueryNamespaceRequest) SetNamespaceId ¶
func (r *QueryNamespaceRequest) SetNamespaceId(v uint64) *QueryNamespaceRequest
func (*QueryNamespaceRequest) SetUserId ¶
func (r *QueryNamespaceRequest) SetUserId(v uint64) *QueryNamespaceRequest
type QueryPolicyRequest ¶
type QueryPolicyRequest struct { *request.PageRequest // 忽略分页 SkipPage bool `json:"skip_page"` // 关联用户Id UserId *uint64 `json:"user_id"` // 关联空间 NamespaceId *uint64 `json:"namespace_id"` // 没有过期 Expired *bool `json:"expired"` // 有没有启动 Enabled *bool `json:"active"` // 关联查询出空间对象 WithNamespace bool `json:"with_namespace"` // 关联查询出用户对象 WithUser bool `json:"with_user"` // 关联查询角色对象 WithRole bool `json:"with_role"` }
func NewQueryPolicyRequest ¶
func NewQueryPolicyRequest() *QueryPolicyRequest
func (*QueryPolicyRequest) SetEnabled ¶
func (r *QueryPolicyRequest) SetEnabled(v bool) *QueryPolicyRequest
func (*QueryPolicyRequest) SetExpired ¶
func (r *QueryPolicyRequest) SetExpired(v bool) *QueryPolicyRequest
func (*QueryPolicyRequest) SetNamespaceId ¶
func (r *QueryPolicyRequest) SetNamespaceId(nsId uint64) *QueryPolicyRequest
func (*QueryPolicyRequest) SetSkipPage ¶
func (r *QueryPolicyRequest) SetSkipPage(v bool) *QueryPolicyRequest
func (*QueryPolicyRequest) SetUserId ¶
func (r *QueryPolicyRequest) SetUserId(uid uint64) *QueryPolicyRequest
func (*QueryPolicyRequest) SetWithRole ¶
func (r *QueryPolicyRequest) SetWithRole(v bool) *QueryPolicyRequest
func (*QueryPolicyRequest) SetWithUser ¶
func (r *QueryPolicyRequest) SetWithUser(v bool) *QueryPolicyRequest
func (*QueryPolicyRequest) SetWithUsers ¶
func (r *QueryPolicyRequest) SetWithUsers(v bool) *QueryPolicyRequest
type Service ¶
type Service interface { // 策略管理 PolicyService // 权限查询, 整合用户多个角色的权限合集 PermissionService }
func GetService ¶
func GetService() Service
type UpdatePolicyRequest ¶
type UpdatePolicyRequest struct { apps.GetRequest CreatePolicyRequest }
Click to show internal directories.
Click to hide internal directories.