RBAC with Domains API
Convenience API for RBAC with domains:按域限定的用户-角色和权限操作。它是 Management API 的子集。在下文中,e 是一个加载了支持域的模型的 Enforcer 实例。
参考
e, err := NewEnforcer("examples/rbac_with_domains_model.conf", "examples/rbac_with_domains_policy.csv")
const e = await newEnforcer('examples/rbac_with_domains_model.conf', 'examples/rbac_with_domains_policy.csv')
$e = new Enforcer('examples/rbac_with_domains_model.conf', 'examples/rbac_with_domains_policy.csv');
e = casbin.Enforcer("examples/rbac_with_domains_model.conf", "examples/rbac_with_domains_policy.csv")
var e = new Enforcer("examples/rbac_with_domains_model.conf", "examples/rbac_with_domains_policy.csv");
let mut e = Enforcer::new("examples/rbac_with_domains_model.conf", "examples/rbac_with_domains_policy.csv").await?;
Enforcer e = new Enforcer("examples/rbac_with_domains_model.conf", "examples/rbac_with_domains_policy.csv");
GetUsersForRoleInDomain
返回在给定域中拥有指定角色的所有用户。
res := e.GetUsersForRoleInDomain("admin", "domain1")
const res = e.getUsersForRoleInDomain("admin", "domain1")
res = e.get_users_for_role_in_domain("admin", "domain1")
GetRolesForUserInDomain
返回在给定域中分配给该用户的所有角色。
res := e.GetRolesForUserInDomain("alice", "domain1")
const res = e.getRolesForUserInDomain("alice", "domain1")
res = e.get_roles_for_user_in_domain("alice", "domain1")
List<String> res = e.getRolesForUserInDomain("admin", "domain1");
GetPermissionsForUserInDomain
返回在给定域中该用户或角色的所有权限(策略规则)。
res := e.GetPermissionsForUserInDomain("alice", "domain1")
List<List<String>> res = e.getPermissionsForUserInDomain("alice", "domain1");
AddRoleForUserInDomain
在域中将角色分配给用户。如果分配已存在,则返回 false。
ok, err := e.AddRoleForUserInDomain("alice", "admin", "domain1")
ok = e.add_role_for_user_in_domain("alice", "admin", "domain1")
boolean ok = e.addRoleForUserInDomain("alice", "admin", "domain1");
DeleteRoleForUserInDomain
从域中的用户移除角色。如果链接不存在,则返回 false。
ok, err := e.DeleteRoleForUserInDomain("alice", "admin", "domain1")
boolean ok = e.deleteRoleForUserInDomain("alice", "admin", "domain1");
DeleteRolesForUserInDomain
移除域中用户的所有角色。如果用户在该域中没有角色,则返回 false。
ok, err := e.DeleteRolesForUserInDomain("alice", "domain1")
GetAllUsersByDomain
返回在给定域中至少拥有一个角色的所有用户。如果模型没有域,则返回空。
res := e.GetAllUsersByDomain("domain1")
DeleteAllUsersByDomain
移除给定域中的所有用户-角色分配。如果模型没有域,则返回 false。
ok, err := e.DeleteAllUsersByDomain("domain1")
DeleteDomains
移除给定域的所有用户和角色。如果没有参数,则清除所有域。
ok, err := e.DeleteDomains("domain1", "domain2")