casbin / Casbin.NET

An authorization library that supports access control models like ACL, RBAC, ABAC in .NET (C#)
https://casbin.org
Apache License 2.0
1.14k stars 110 forks source link

[Question] How to to call Enforce in Casbin.NET 2.0.0 preview? #240

Closed shayura closed 2 years ago

shayura commented 2 years ago

I can't find any examples in the UnitTest projects, so I'm not sure how to migrate Enforce(Async) calls from the previous version. I would like to use EnforcerContext to switch between p and p2 rules.

casbin-bot commented 2 years ago

@sagilio @xcaptain @huazhikui

shayura commented 2 years ago

Please forgive me for the silly question. I have just found out about the extension methods inside NetCasbin/Extensions/Enforcer/EnforcerExtension.cs. I'll try using this newfound knowledge to call the enforcer to check p2 rules.

sagilio commented 2 years ago

Maybe this is helpful to you: https://github.com/casbin/Casbin.NET/blob/e0af5c3bea91e9aa011eae85ff582ca7d0a2ca82/NetCasbin.UnitTest/ModelTests/ModelTest.cs#L564-L604