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

Updating Policies directly on the IPolicyStore model not reflected in Enforcer #313

Closed amopitt closed 3 months ago

amopitt commented 1 year ago

I am modifying the group policies dynamically listening to event messages using syntax below (this is on 2.0.0-preview.4, still need to update here):

    public static bool AddGroupPolicy(this IPolicyStore model, GroupPolicy policy)
    {
        return model.AddGroupPolicies(new[] { policy });
    }

I see that the PolicyManager reflects the changes, nothing errors. However when I call EnforceAsync I still get a Forbidden error. I am just asking generically is there something else that needs to be done that I am missing? AutoSave is set to true. Inspecting through breakpoints shows that my group policy is valid. If I were to call LoadPolicy on the exact same model it will then work as expected so something is off with what I'm doing.

casbin-bot commented 1 year ago

@sagilio @sociometry @AsakusaRinne

sagilio commented 1 year ago

@amopitt It needs not some work else to do, I think the wrong may be caused by BuildIncrementalRoleLink or cache logic. Could you get me a sample or test to reproduce this case?

hsluoyz commented 5 months ago

@amopitt any update?

hsluoyz commented 3 months ago

Closed as stale.