Documentation ¶
Index ¶
- type Permission
- func (this *Permission) AddPermissionForUser(user string, permission ...string) (bool, error)
- func (this *Permission) AddPolicy(user string, ptype string, rule string) (bool, error)
- func (this *Permission) AddRoleForUser(user string, role string, domain ...string) (bool, error)
- func (this *Permission) AddRolesForUser(user string, roles []string, domain ...string) (bool, error)
- func (this *Permission) DeletePermission(permission ...string) (bool, error)
- func (this *Permission) DeletePermissionForUser(user string, permission ...string) (bool, error)
- func (this *Permission) DeletePermissionsForUser(user string) (bool, error)
- func (this *Permission) DeletePolicy(user string, ptype string, rule string) (bool, error)
- func (this *Permission) DeletePolicys(user string) (bool, error)
- func (this *Permission) DeleteRole(role string) (bool, error)
- func (this *Permission) DeleteRoleForUser(user string, role string) (bool, error)
- func (this *Permission) DeleteRolesForUser(user string) (bool, error)
- func (this *Permission) DeleteUser(user string) (bool, error)
- func (this *Permission) Enforce(user string, ptype string, rule string) (bool, error)
- func (this *Permission) GetAdapter() interfaces.Adapter
- func (this *Permission) GetDomainsForUser(user string) ([]string, error)
- func (this *Permission) GetEnforcer() *casbin.Enforcer
- func (this *Permission) GetImplicitPermissionsForUser(user string, domain ...string) ([][]string, error)
- func (this *Permission) GetImplicitResourcesForUser(user string, domain ...string) ([][]string, error)
- func (this *Permission) GetImplicitRolesForUser(user string, domain ...string) ([]string, error)
- func (this *Permission) GetImplicitUsersForPermission(permission ...string) ([]string, error)
- func (this *Permission) GetImplicitUsersForRole(user string, domain ...string) ([]string, error)
- func (this *Permission) GetModelConf() string
- func (this *Permission) GetPermissionsForUser(user string) [][]string
- func (this *Permission) GetRolesForUser(name string, domain ...string) ([]string, error)
- func (this *Permission) GetUsersForRole(name string, domain ...string) ([]string, error)
- func (this *Permission) HasPermissionForUser(user string, ptype string, rule string) bool
- func (this *Permission) HasRoleForUser(user string, role string) (bool, error)
- func (this *Permission) WithAdapter(a interfaces.Adapter) *Permission
- func (this *Permission) WithEnforcer(e *casbin.Enforcer) *Permission
- func (this *Permission) WithModelConf(modelConf string) *Permission
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Permission ¶
type Permission struct { // 权限文件 ModelConf string // 适配器 Adapter interfaces.Adapter // 决策器 Enforcer *casbin.Enforcer }
*
- 权限 *
- rbac_model.conf 中 matchers 内置可用函数:
- keyMatch [匹配*号], keyMatch2 [匹配 :file],
- keyMatch3 [匹配 {file}], keyMatch4 [匹配更严格 {file} ],
- regexMatch [正则匹配], ipMatch [IP地址或者CIDR匹配],
- globMatch, keyGet, keyGet2 *
- @create 2021-9-30
- @author deatil
func (*Permission) AddPermissionForUser ¶
func (this *Permission) AddPermissionForUser(user string, permission ...string) (bool, error)
*
- 添加用户权限
func (*Permission) AddRolesForUser ¶
func (this *Permission) AddRolesForUser(user string, roles []string, domain ...string) (bool, error)
*
- 批量添加用户角色
func (*Permission) DeletePermission ¶
func (this *Permission) DeletePermission(permission ...string) (bool, error)
*
- 删除权限
func (*Permission) DeletePermissionForUser ¶
func (this *Permission) DeletePermissionForUser(user string, permission ...string) (bool, error)
*
- 删除用户的权限
func (*Permission) DeletePermissionsForUser ¶
func (this *Permission) DeletePermissionsForUser(user string) (bool, error)
*
- 删除用户的所有权限
func (*Permission) DeletePolicys ¶
func (this *Permission) DeletePolicys(user string) (bool, error)
*
- 删除标识所有权限
func (*Permission) DeleteRole ¶
func (this *Permission) DeleteRole(role string) (bool, error)
*
- 删除角色
func (*Permission) DeleteRoleForUser ¶
func (this *Permission) DeleteRoleForUser(user string, role string) (bool, error)
*
- 删除用户角色
func (*Permission) DeleteRolesForUser ¶
func (this *Permission) DeleteRolesForUser(user string) (bool, error)
*
- 删除用户所有角色
func (*Permission) DeleteUser ¶
func (this *Permission) DeleteUser(user string) (bool, error)
*
- 删除用户信息
func (*Permission) GetDomainsForUser ¶
func (this *Permission) GetDomainsForUser(user string) ([]string, error)
*
- 用户的全部域名
func (*Permission) GetImplicitPermissionsForUser ¶
func (this *Permission) GetImplicitPermissionsForUser(user string, domain ...string) ([][]string, error)
*
- 用户的全部权限
func (*Permission) GetImplicitResourcesForUser ¶
func (this *Permission) GetImplicitResourcesForUser(user string, domain ...string) ([][]string, error)
*
- 用户的全部决策器
func (*Permission) GetImplicitRolesForUser ¶
func (this *Permission) GetImplicitRolesForUser(user string, domain ...string) ([]string, error)
*
- 全部角色
func (*Permission) GetImplicitUsersForPermission ¶
func (this *Permission) GetImplicitUsersForPermission(permission ...string) ([]string, error)
*
- 权限对应的用户
func (*Permission) GetImplicitUsersForRole ¶
func (this *Permission) GetImplicitUsersForRole(user string, domain ...string) ([]string, error)
*
- 角色的用户
func (*Permission) GetPermissionsForUser ¶
func (this *Permission) GetPermissionsForUser(user string) [][]string
*
- 全部权限
func (*Permission) GetRolesForUser ¶
func (this *Permission) GetRolesForUser(name string, domain ...string) ([]string, error)
*
- 用户的全部角色
func (*Permission) GetUsersForRole ¶
func (this *Permission) GetUsersForRole(name string, domain ...string) ([]string, error)
*
- 角色的全部用户
func (*Permission) HasPermissionForUser ¶
func (this *Permission) HasPermissionForUser(user string, ptype string, rule string) bool
*
- 判断是否有权限
func (*Permission) HasRoleForUser ¶
func (this *Permission) HasRoleForUser(user string, role string) (bool, error)
*
- 用户角色是否拥有某角色
func (*Permission) WithAdapter ¶
func (this *Permission) WithAdapter(a interfaces.Adapter) *Permission
*
- 设置适配器
func (*Permission) WithEnforcer ¶
func (this *Permission) WithEnforcer(e *casbin.Enforcer) *Permission
*
- 设置
func (*Permission) WithModelConf ¶
func (this *Permission) WithModelConf(modelConf string) *Permission
*
- 设置权限文件
Click to show internal directories.
Click to hide internal directories.