Documentation ¶
Overview ¶
Package rbac 简单的 RBAC 权限规则实现
Index ¶
- func Install(mod string, db *orm.DB)
- type RBAC
- func (rbac *RBAC) DeleteRole(idName string, ctx *web.Context) web.Responser
- func (rbac *RBAC) Filter(uid int64, mod string, res string, next web.HandlerFunc) web.HandlerFunc
- func (rbac *RBAC) GetResourcesHandle(ctx *web.Context) web.Responser
- func (rbac *RBAC) GetRoleAllowedResourcesHandle(idName string, ctx *web.Context) web.Responser
- func (rbac *RBAC) GetRoleResourcesHandle(idName string, ctx *web.Context) web.Responser
- func (rbac *RBAC) GetRolesHandle(ctx *web.Context) web.Responser
- func (rbac *RBAC) IsAllow(uid int64, resID string) (allowed bool, err error)
- func (rbac *RBAC) IsAllowRoles(uid int64, rs []int64) (bool, error)
- func (rbac *RBAC) Link(tx *orm.Tx, uid int64, role ...int64) error
- func (rbac *RBAC) NewRole(parent int64, name, desc string) (int64, error)
- func (rbac *RBAC) PostRolesHandle(ctx *web.Context) web.Responser
- func (rbac *RBAC) PutRoleHandle(idName string, ctx *web.Context) web.Responser
- func (rbac *RBAC) PutRoleResourcesHandle(idName string, ctx *web.Context) web.Responser
- func (rbac *RBAC) RegisterResources(mod string, res map[string]web.LocaleStringer) error
- func (rbac *RBAC) Role(id int64) *Role
- func (rbac *RBAC) Unlink(tx *orm.Tx, uid int64, roleID ...int64) error
- type ResourcesType
- type Role
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type RBAC ¶
type RBAC struct {
// contains filtered or unexported fields
}
RBAC 权限管理类
func (*RBAC) DeleteRole ¶
func (*RBAC) Filter ¶
func (rbac *RBAC) Filter(uid int64, mod string, res string, next web.HandlerFunc) web.HandlerFunc
Filter 验证是否拥有指定的权限
func (*RBAC) GetResourcesHandle ¶
func (*RBAC) GetRoleAllowedResourcesHandle ¶
GetRoleAllowedResourcesHandle 获得权限组允许访问的资源列表
func (*RBAC) GetRoleResourcesHandle ¶
GetRoleResourcesHandle 获得角色可访问的资源列表
func (*RBAC) PutRoleHandle ¶
func (*RBAC) PutRoleResourcesHandle ¶
func (*RBAC) RegisterResources ¶
RegisterResources 一次性注册多个资源
module 表示资源 ID 的统一前缀值,一般为模块的 ID,用于区分不同模块下的 ID 相同的资源。
type ResourcesType ¶
Click to show internal directories.
Click to hide internal directories.