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.13k stars 110 forks source link

[WIP] feat: change lazyLoadPolicy to AutoLoadPolicy. #290

Closed AsakusaRinne closed 1 year ago

AsakusaRinne commented 1 year ago

Change lazyLoadPolicy to AutoLoadPolicy to avoid ignore the filter when using filtered adapter.

Since it needs to be verified with efcore-adapter, it's currently in process now.

casbin-bot commented 1 year ago

@sagilio please review

AsakusaRinne commented 1 year ago

plz add it as an option like:

https://github.com/casbin/Casbin.NET/blob/8c8105d356abc887ddcde02f9ebb2ed57ff32d58/Casbin/Enforcer.cs#L46-L55

We should avoid many parameters in the ctor method. Users can use like:

var e = new Enforcer(model, adapter){
     AutoLoadPolicy = false;
};

If we use the code above to initialize an enforcer, the assignment will be executed after the constructor. However, the LoadPolicy behavior occurs in the constructor, which will ignore the assignment in the initializer list.

AsakusaRinne commented 1 year ago

This feature is supposed to be submitted to preview branch, as shown in #295 . This PR will be closed.