Open zhou93 opened 4 months ago
@techoner @Nekotoxin
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:
def get_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]
while queue:
name = queue.pop(0)
for rm in self.rm_map.values():
roles = rm.get_roles(name, domain)
for r in roles:
if r not in res:
res.append(r)
queue.append(r)
return res
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.
@leeqvip
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 https://github.com/casbin/pycasbin/issues/350#issuecomment-2188033094