-
-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove_grouping_policy: link between string and string does not exist #250
Comments
@ffyuanda @Zxilly @techoner @elfisworking |
@wu-clan please show all your code, including the model, policy, request and response. |
# remove_policy
@casbin.delete('/del_policy', summary='Remove access rights based on role (primary) or user (secondary)')
def delete_policy(p: PolicyDelete):
enforcer = rbac.get_casbin_enforcer()
data = enforcer.remove_policy(p.sub, p.path, p.method)
if data:
return Response200(data=data)
else:
return Response404(msg='Deletion failed, access rights do not exist', data=data)
# remove_grouping_policy
@casbin.delete('/del_group', summary='remove group based access rights')
def delete_group(p: UserRole):
enforcer = rbac.get_casbin_enforcer()
data = enforcer.remove_grouping_policy(p.uid, p.role)
if data:
return Response200(data=data)
else:
return Response404(msg='Deletion failed, access rights do not exist', data=data)
This should be a classic RBAC when i send request delete_policy api, when the parameter does not exist, it can return False but when i send request delete_group api like delete_policy, it happend:
Is there a mistake in my method of use? |
The model is here:
|
@wu-clan Try get_policy() and get_grouping_policy() to see if the policy is loaded successfully. |
@leeqvip it's OK @casbin.get('/get_policy', summary='get p policy')
def get_policy():
enforcer = rbac.get_casbin_enforcer()
data = enforcer.get_policy()
if data:
return Response200(data=data)
@casbin.get('/get_group', summary='get g policy')
def get_group():
enforcer = rbac.get_casbin_enforcer()
data = enforcer.get_grouping_policy()
if data:
return Response200(data=data) INFO: 127.0.0.1:50624 - "GET /v1/rbac/get_policy HTTP/1.1" 200 OK |
@wu-clan can you cross-verify that the arguments you are passing are correct according to the grouping policy you have because I guess the error raised should show the grouping terms you are trying to remove rather than |
@Shivansh-yadav13 Yes, string is just the parameter I passed, if the parameter are 'data2_admin' and 'alice', it raise:
but, when params are not in db, is it should be return False like remove_policy()? Not throwing an exception, and g have only two params, why need link between params? Or am I used it the wrong way? |
not sure if we should be returning False for it like |
It seems that there is no problem. Based on this situation, g is complex. If you add a parameter to specify the situation, for example: use_policy=Ture, or create a new func? |
When I use remove_grouping_policy as I use remove_policy, it happend raise: RuntimeError: error: link between string and string does not exist, but g only have two values, so, how i need to do or is this a question?
The text was updated successfully, but these errors were encountered: