casbin-net / casbin-aspnetcore

Casbin.NET integration middleware and sample code for ASP.NET Core
https://github.com/casbin/Casbin.NET
Apache License 2.0
64 stars 20 forks source link

Best way to use EF core adapter with filter #53

Closed kostazol closed 1 year ago

kostazol commented 1 year ago

Hi. I saw some questions: https://github.com/casbin-net/casbin-aspnetcore/issues/17 , https://github.com/casbin-net/casbin-aspnetcore/issues/34 , https://github.com/casbin-net/casbin-aspnetcore/issues/36 , https://github.com/casbin-net/casbin-aspnetcore/issues/37 , https://github.com/casbin-net/casbin-aspnetcore/issues/41 . Also I saw example https://github.com/casbin-net/casbin-aspnetcore/tree/preview/samples/WebApplicationWithEfcoreSample (thank you for it).

But if I understand all correct, now a default provider not use filters. As I saw in source code a default behaviour for adapters are to load all policies on initialization. But not for optimization the EF core adapter has a lazy loading (when we load zero policies on initialization). Will I need to implement a custom provider for this variant if I want to load policies with a filter before call enforce?

casbin-bot commented 1 year ago

@sagilio @sociometry @AsakusaRinne

hsluoyz commented 1 year ago

@kostazol yes, the EF core adapter is a filtered adapter, so you can do sharding by calling LoadFilteredPolicy()

hsluoyz commented 1 year ago

Closed for now, ping it back if you have any further issues