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

Is Casbin.NET v2 incompatible with EFCore Adapter and AspNetCore? #243

Closed shayura closed 3 months ago

shayura commented 2 years ago

I'm using Casbin.NET v2 in order to take advantage of EnforcerContext (please see #240 for reference.) I've noticed that neither EFCore Adapter nor the AspNetCore extension work with this version of the tool because the assembly name change from CasbinNet to just Casbin.

This is the specific error the compiler is spewing out:

[CS0012] The type 'IFilteredAdapter' is defined in an assembly that is not referenced. 
You must add a reference to assembly 'NetCasbin, Version=1.12.1.0, Culture=neutral, PublicKeyToken=null'.

I'm still new to Microsoft's .NET stack and the C# language. It's completely possible that I misunderstood the meaning of this error, but I did notice the namespace change.

Unless there's a way to query query the enforcer for pN rules, I can't afford to downgrade to the previous version of Casbin.NET. Do you have any advice?

The error is happening with this code

var enforcer = new Enforcer(
    DefaultModel.CreateFromFile(Path.Combine("CasbinConfig", "model.conf"), 
    new EFCoreAdapter<int>(_casbinDbContext));

when using the following versions of the Casbin packages:

casbin-bot commented 2 years ago

@sagilio @xcaptain @huazhikui

sagilio commented 2 years ago

The release of Casbin.Adapter.EFCore and Casbin.AspNetCore is only work for Casbin.NET v1.

I will release 2.x versions of them that are compatible with the Casbin.NET v2 this year.

hsluoyz commented 3 months ago

@shayura Casbin.AspNetCore and Casbin.Adapter.EFCore latest versions have supported Casbin.NET 2.x now.