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

Using LoadFilteredPolicy loads all policies unfiltered #288

Closed thoraj closed 3 months ago

thoraj commented 1 year ago

We are using Casbin extensively in our system.

We're using Casbin.Net 1.12.2 and Casbin.NET.Adapter.EFCore 1.80

As the number of policies grows we are experiencing performance issues.

A while back we started filterering policies per tenant. So now we:

So the adapter has already loaded all policies when handed to the Enforcer constructor

However it seems all policies are still loaded when creating the enforcer. We have instrumented our code and it shows that:

The second non-filtered query is issued while the Enforcer is being constructed.

Is there some way we can prevent this from happening such that only policies for the tenant are loaded?

-- Thor A. Johansen

casbin-bot commented 1 year ago

@sagilio @sociometry @AsakusaRinne

hsluoyz commented 1 year ago

@AsakusaRinne

/cc @sagilio

sagilio commented 1 year ago

We plan to add the new option AutoLoadPolicy(#295) to control this behavior, the changes will also try implemented in the v1 version.

hsluoyz commented 3 months ago

Closed as resolved