You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error When Calling get_implicit_permissions_for_user
In the above scenario, calling the function get_implicit_permissions_for_user results in an error.
From the code, we can see:
defget_named_implicit_permissions_for_user(self, ptype, user, domain="", filter_policy_dom=True):
""" gets implicit permissions for a user or role by named policy. Compared to get_permissions_for_user(), this function retrieves permissions for inherited roles. For example: p, admin, data1, read p, alice, data2, read g, alice, admin get_permissions_for_user("alice") can only get: [["alice", "data2", "read"]]. But get_implicit_permissions_for_user("alice") will get: [["admin", "data1", "read"], ["alice", "data2", "read"]]. For given domain policies are filtered by corresponding domain matching function of DomainManager Inherited roles can be matched by domain. For domain neutral policies set: filter_policy_dom = False filter_policy_dom: bool - For given *domain*, policies will be filtered by domain as well. Default = True """roles=self.get_implicit_roles_for_user(user, domain)
roles.insert(0, user)
res= []
# policy domain should be matched by domain_match_fn of DomainManagerdomain_matching_func=self.get_role_manager().domain_matching_funcifdomainanddomain_matching_func!=None:
domain=partial(domain_matching_func, domain)
forroleinroles:
permissions=self.get_named_permissions_for_user_in_domain(
ptype, role, domainiffilter_policy_domelse""
)
res.extend(permissions)
returnres
This function calls get_role_manager, which is defined as follows:
defget_role_manager(self):
"""gets the current role manager."""returnself.rm_map["g"]
At this point, rm_map does not contain g, because g is in cond_rm_map.
zhou93
changed the title
### Error When Calling get_implicit_permissions_for_user
[Bug] Error When Calling get_implicit_permissions_for_userJun 25, 2024
Additionally, functions like get_implicit_roles_for_user do not return the correct results when g is defined with conditions. Is this the expected behavior?
For example:
defget_implicit_roles_for_user(self, name, domain=""):
""" gets implicit roles that a user has. Compared to get_roles_for_user(), this function retrieves indirect roles besides direct roles. For example: g, alice, role:admin g, role:admin, role:user get_roles_for_user("alice") can only get: ["role:admin"]. But get_implicit_roles_for_user("alice") will get: ["role:admin", "role:user"]. """res= []
queue= [name]
whilequeue:
name=queue.pop(0)
forrminself.rm_map.values():
roles=rm.get_roles(name, domain)
forrinroles:
ifrnotinres:
res.append(r)
queue.append(r)
returnres
In the above function, it only retrieves roles from rm_map and does not check cond_rm_map. I expect that the roles assigned under conditions should also be retrieved.
Error When Calling
get_implicit_permissions_for_user
In the above scenario, calling the function
get_implicit_permissions_for_user
results in an error.From the code, we can see:
This function calls
get_role_manager
, which is defined as follows:At this point,
rm_map
does not containg
, becauseg
is incond_rm_map
.Originally posted by @zhou93 in #350 (comment)
The text was updated successfully, but these errors were encountered: