Closed tanasecucliciu closed 11 months ago
@techoner @Nekotoxin
I tried both in pycasbin and asynccasbin with the provided model and policies and it returns different result. It seems that it is not caused by the adapter since I didn't import it.
import casbin
e = casbin.Enforcer('examples/rbac_model.conf', 'examples/rbac_policy.csv')
sub = "0d959490-a8bb-4ad7-9616-58f0d15eac38" # the user that wants to access a resource.
obj = "0d959490-a8bb-4ad7-9616-58f0d15eac38" # the resource that is going to be accessed.
act = "read" # the operation that the user performs on the resource.
if e.enforce(sub, obj, act):
# permit alice to read data1
print('allow')
else:
# deny the request, show an error
print("deny")
In pycasbin, it prints allow, but in async it prints deny.
Thank you! In retrospect I should have tried that before posting. It doesn't seem like asynccasbin has an issue board so I don't know what to do next in regards to properly reporting this issue. I just switched to SQLAlchemy Adapter for my project. Guess this will just get closed.
@BustDot can this issue be resolved after merging PR: https://github.com/pycasbin/async-sqlalchemy-adapter/pull/11 ?
@BustDot can this issue be resolved after merging PR: #11 ?
Yes. After I test with the given model and policy, it print "allow" as expected.
mport asyncio
import casbin
e = casbin.AsyncEnforcer('tests/rbac_model.conf', 'tests/rbac_policy.csv')
sub = "0d959490-a8bb-4ad7-9616-58f0d15eac38" # the user that wants to access a resource.
obj = "0d959490-a8bb-4ad7-9616-58f0d15eac38" # the resource that is going to be accessed.
act = "read" # the operation that the user performs on the resource.
async def main():
await e.load_policy()
if e.enforce(sub, obj, act):
# permit alice to read data1
print('allow')
else:
# deny the request, show an error
print("deny")
asyncio.run(main())
Thanks!
@tanasecucliciu plz use v1.3.0 and later: https://github.com/pycasbin/async-sqlalchemy-adapter/pull/11#issuecomment-1667151660
I have a model that I created using the online editor. I was surprised to see that even though I used the same policies and the same requests I would get different results in the online editor vs using this adapter. In order to double check I switched the adapter for SQLAlchemy Adapter and that fixed the problem. I'm unsure if the issue is with this adapter or the asynccasbin projects it uses as a dependency.
Model:
Policies:
Request:
0d959490-a8bb-4ad7-9616-58f0d15eac38, 0d959490-a8bb-4ad7-9616-58f0d15eac38, read
For some context, my goals with this model were:
Thanks for your time and consideration.