casbin-net / efcore-adapter Goto Github PK
View Code? Open in Web Editor NEWEntity Framework Core Adapter for Casbin.NET
Home Page: https://github.com/casbin/Casbin.NET
License: Apache License 2.0
Entity Framework Core Adapter for Casbin.NET
Home Page: https://github.com/casbin/Casbin.NET
License: Apache License 2.0
Issue Description:
When using the EFCore adapter (Casbin.Adapter.EFCore) with Casbin.NET and PostgreSQL as the database, I noticed that after calling AddPolicy() and SavePolicy(), duplicate policy records are present in the database. I am certain that I am not calling AddPolicy() multiple times in my code.
Steps to Reproduce:
Configure Casbin.NET to use the Casbin.Adapter.EFCore adapter and connect to a PostgreSQL database.
Call AddPolicy() in the code to add a new policy.
Call SavePolicy() to save the changes.
Check the database and observe duplicate policy records.
Expected Behavior:
There should be only one new policy record in the database.
Actual Behavior:
There are two identical policy records in the database.
Environment Information:
Operating System: [e.g., MacOS]
.NET Version: [e.g., .NET 6.0]
Casbin.NET Version: [e.g., 1.14.0 ]
Casbin.NET.Adapter.EFCore Version: [e.g., 1.8.1]
Casbin.AspNetCore.Core Version : [e.g., 0.2.1]
PostgreSQL Version: [e.g., 14.4]
Any other libraries or frameworks that might be relevant
Code Sample:
public static class CasbinConfigurationExtensions
{
public static IServiceCollection AddCustomCasbinConfiguration(this IServiceCollection services, IConfiguration configuration)
{
var options = new DbContextOptionsBuilder<CasbinDbContext<long>>()
.UseNpgsql(configuration.GetConnectionString("DefaultConnection"))
.Options;
var context = new CasbinDbContext<long>(options, defaultSchemaName: "manage");
context.Database.EnsureCreated();
services.AddSingleton<Enforcer>(provider =>
{
var efCoreAdapter = new EFCoreAdapter<long>(context);
var e = new Enforcer("./CasbinConfigs/basic_model.conf", efCoreAdapter);
e.LoadPolicy();
return e;
});
return services;
}
}
builder.Services.AddCustomCasbinConfiguration(configuration);
public class XXXService : IXXXService
{
private readonly Enforcer _enforcer;
public XXXService( Enforcer enforcer)
{
_enforcer = enforcer;
}
}
_enforcer.AddPolicy(roleId, path, method);
_enforcer.SavePolicy();
Needing some help - finding quite some hard time to add it to a project with Top level statements.
What I am looking for is
dotnet ef migrations add CasbinSupport --context MYSQLCasbinDbContext --output-dir Migrations/MYSQLMigrations --verbose
What I am doing now
public class MYSQLCasbinDbContext : CasbinDbContext<int>
{
protected readonly IConfiguration _configuration;
public MYSQLCasbinDbContext(IConfiguration configuration)
{
_configuration = configuration;
}
public MYSQLCasbinDbContext(DbContextOptions<MYSQLCasbinDbContext> options, IConfiguration configuration) : base(options)
{
_configuration = configuration;
}
public MYSQLCasbinDbContext(DbContextOptions<MYSQLCasbinDbContext> options, IConfiguration configuration, string defaultSchemaName = null, string defaultTableName = "auth_casbin_rule")
: base(options, defaultSchemaName, defaultTableName)
{
_configuration = configuration;
}
protected MYSQLCasbinDbContext(DbContextOptions options, IConfiguration configuration, string defaultSchemaName = null, string defaultTableName = "auth_casbin_rule")
: base(options, defaultSchemaName, defaultTableName)
{
_configuration = configuration;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var connectionString = _configuration.GetConnectionString("MYSQL");
var serverVersion = new MariaDbServerVersion("10.9.4");
optionsBuilder.UseMySql(connectionString, serverVersion)
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging()
.EnableDetailedErrors();
base.OnConfiguring(optionsBuilder);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
Program.cs
builder.Services.AddDbContext<CasbinDbContext<int>, MYSQLCasbinDbContext>(optionsBuilder =>
{
}).AddScoped<IAdapter, EFCoreAdapter<int>>();
I have no idea if it is proper / creating other issues
services.AddDbContext<CasbinDbContext<int>>(options =>
{
DbContextOptionsBuilder optionsBuilder = null;
switch (type.ToLower())
{
case "mysql":
optionsBuilder = options.UseMySQL(connectionString);
break;
case "sqlite3":
default:
optionsBuilder = options.UseSqlite(connectionString);
break;
}
var context = new CasbinDbContext<int>(optionsBuilder.Options);
context.Database.EnsureCreated();
}, ServiceLifetime.Transient);
Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Casbin.Adapter.EFCore.CasbinDbContext`1[System.Int32] Lifetime: Transient ImplementationType: Casbin.Adapter.EFCore.CasbinDbContext`1[System.Int32]': Unable to activate type 'Casbin.Adapter.EFCore.CasbinDbContext`1[System.Int32]'. The following constructors are ambiguous:
Void .ctor(Microsoft.EntityFrameworkCore.DbContextOptions, System.String, System.String)
Void .ctor(Microsoft.EntityFrameworkCore.DbContextOptions`1[Casbin.Adapter.EFCore.CasbinDbContext`1[System.Int32]], System.String, System.String))
Mirror from casbin/Casbin.NET#176
1.I think calling AsNoTracking in Policy loading could improve performance.
2.Casbin.Net repo add two new adapter interfaces,need to be implemented
I'v add a new PR to solve this issue.
Hi Team,
I get the below exception when I call the method enforcer.LoadFilteredPolicy(filter) method.
I am filtering based on the below code, Please see is this correct?
NetCasbin.Persist.Filter filter = new NetCasbin.Persist.Filter()
{
P = new List<string> { "", "", "", "Edit" }
};
enforcer.LoadFilteredPolicy(filter);
in the DB, I have metnion "Edit" in the 3rd column i.e, V3
Id PType V0 V1 V2 V3 V4 V5
253 p Alice data2 Write Edit NULL NULL
254 p Alice data1 read Read NULL NULL
$exception {"filtered policies are not supported by this adapter"} System.Exception
{Casbin.NET.Adapter.EFCore.CasbinDbAdapter<int>}
/// <summary>
/// Returns true if the loaded policy has been filtered.
/// </summary>
/// <returns>if the loaded policy has been filtered.</returns>
public bool IsFiltered()
{
if (adapter is IFilteredAdapter filteredAdapter)
{
return filteredAdapter.IsFiltered;
}
return false;
}
Hello!
Once again, I apologize if there's information I overlooked, or if this is the wrong place to ask this question. As I understand things, Cosmos handles replication across regions, so any policies added or removed in one region will replicate to all other regions (assuming that's what we want and assuming we've configured things correctly).
Is there anything inherent in this adapter that facilitates this behavior? i.e. If I write a policy in Europe, Cosmos will replicate that policy to the US, Asia, etc. - does this adapter ensure that calls to Enforce() hit Cosmos if caching is disabled, absent a preceding call to LoadPolicy()?
Or do I need to watch for changes to the database/container separately, triggering calls to LoadPolicyAsync() in response?
Thanks for your patience!
John
I'm trying to load a subset of policies similar to the example shown here in the Casbin docs:
https://casbin.org/docs/en/policy-subset-loading
I have an RBAC model with domains and I want to do exactly what is shown in this example where I can load a filtered policy with everything from "domain1". I have 1 "g" group/role defined for "domain1" and then I've given that group permission to 2 objects also in "domain1"...so my casbin_rule table has 3 rows: 1 "g" row and 2 "p" rows.
After I was having issues, I stepped through the LoadFilteredPolicy code, and determined that
The reason is because in CasbinRuleExtension.ApplyQueryFilter, it performs the following code
if (filter.P is not null)
{
query = query.ApplyQueryFilter(PermConstants.DefaultPolicyType, 0, filter.P);
}
if (filter.G is not null)
{
query = query.ApplyQueryFilter(PermConstants.DefaultGroupingPolicyType, 0, filter.G);
}
This results in a query that takes the the P filter AND the G filter. This will never return any values. In order for both to work, there would have to be an OR instead of AND.
As I mentioned above, based on the example here: https://casbin.org/docs/en/policy-subset-loading, it seems like this should work as I've described where it does an OR between the 2 filters. Is this a bug? Is there a workaround you can provide?
Thanks!
This project depends on .net 2.2, now we should upgrade to .net core 3.1
Hi, we are evaluating casbin for a .NET project that we are starting out.
We want to store policies in a database (thinking about postgres) and using Casbin.NET.Adapter.EFCore v2.1.0
and Npgsql.EntityFrameworkCore.PostgreSQL v8.0.2
.
If we are a version of the package Casbin.NET
higher that 2.1.1
we get the following exception:
System.EntryPointNotFoundException: Entry point was not found.
at System.Collections.Generic.IReadOnlyCollection`1.get_Count()
at Casbin.Persist.Adapter.EFCore.EFCoreAdapter`3.AddPolicyAsync(String section, String policyType, IPolicyValues values)
at Casbin.Model.DefaultPolicyManager.AddPolicyAsync(IPolicyValues rule)
at Casbin.InternalEnforcerExtension.InternalAddPolicyAsync(IEnforcer enforcer, String section, String policyType, IPolicyValues values)
Of course we can evaluate the solution with a 5 month-old version, but that would be a showstopper to continue with casbin.
I am not sure what could be the solution for this problem.
Thanks for your help.
See: https://casbin.org/docs/en/overview#feature-set-for-different-languages
This adapter needs to implement the IAdapter interface with AddPolicies()
and RemovePolicies()
functions.
This issue is to track the progress of solving: #28
I have two projects, one in .Net and a Python project.
Both are going to point to the same DB, and share the same casbin table.
I just noticed that in .net the DB table is 'CasbinRule' and the python one is 'casbin_rule' - so the two projects aren't actually using the same table.
Is there a good way to set them both to the same table name?
I am using:
for Python, the SQLAlchemy adapter - https://github.com/pycasbin/sqlalchemy-adapter
for .NET, the EFCore adapter - https://github.com/casbin-net/EFCore-Adapter
Thank you
Hi Team,
I am using enforcer.LoadFilterPolicy with filter, it throws error " the data type text and varchar are incompatible".
I debugged further and the issue is the DB is text field and it takes nVarchar() for comparing and "=" is used. I have corrected the code locally to work and I can give the fix as given below>
// Error while locading:
enforcer.LoadFilteredPolicy(new Filter
{
P = new List<string> { "", "", "","domainname" },
});
Degug Query result:
((Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable<Casbin.NET.Adapter.EFCore.CasbinRule<int>>)query).DebugView.Query
DECLARE @__policyType_0 nvarchar(4000) = N'p';
DECLARE @__field_1 nvarchar(4000) = N'prledit';
DECLARE @__policyType_0 nvarchar(4000) = N'p';
DECLARE @__field_1 nvarchar(4000) = N'prledit';
**SELECT [c].[Id], [c].[PType], [c].[V0], [c].[V1], [c].[V2], [c].[V3], [c].[V4], [c].[V5]
FROM [CasbinRule] AS [c]
WHERE ([c].[PType] = @__policyType_0) AND ([c].[V3] = @__field_1)**
Error:
The data types text and varchar are incompatible in the equal to operator.
Corrected Query:
_**SELECT [c].[Id], [c].[PType], [c].[V0], [c].[V1], [c].[V2], [c].[V3], [c].[V4], [c].[V5]
FROM [CasbinRule] AS [c]
WHERE ((@__policyType_0 LIKE N'') OR (CHARINDEX(@__policyType_0, [c].[PType]) > 0)) AND ((@__field_1 LIKE N'') OR (CHARINDEX(@__field_1, [c].[V3]) > 0))**_
Code changes Required:
CasbinRulesExtension.cs file Line No 81.
Error causing line: query = query.Where(p => string.Equals(p.PType, policyType));
Corrected Code: query = query.Where(p => p.PType.Contains(policyType));
Similarly for other indexes as highlighted here:
if (fieldIndex <= 2 && lastIndex > 2)
{
string field = fieldValuesList[2 - fieldIndex];
if (string.IsNullOrWhiteSpace(field) is false)
{
**query = query.Where(p => p.V2.Contains(field));**
}
}
Actual error message:
Microsoft.Data.SqlClient.SqlException: 'The data types text and nvarchar are incompatible in the equal to operator.'
Thanks
siva
Hi,
I apologize if my question may sounds simple or if I have overlooked something, or if this is the wrong place to ask this question. We are using Casbin.Net for performing authorization library for our microservice project. We also use MassTransit and we need to perform authorization of commands. For that we are implemented custom filters where we make calls to the authorization service.
If we are regsitering the services as shown in the readme of this repo then a single DBContext and the enforcers are singleton for each request. In this scenario basically DBContext becomes singleton and after first query all policies from DB are loaded and cached in-memory. The first problem that we are facing is that in this scenario production use (100+ users) a lot of concurrent updates happen and we are getting EF errors saying that the DBContext cannot be used by different threads, which totally logical. If we change the service registration and a new DContext is constructed for each request we are hitting performance issues as each time it has to read all policies from the database.
To be honest I didn't find a proper place to hook in the caching in the EFCore adaptor, and that only leaves us with options to hook into EF Core's in-memeory "shared cache" or cache the command results at MassTransit level. Am I missing something? What production level best-practices are there for Casbin.net and EFCore Adapter in-terms of performance?
Thanks for your patience!
Hi efcore-adapter Team,
we would like to build our AuthZ custom solution based on Casbin.NET version 2. As we use the EFCoreAdapter to store/load the policies we are wondering if you could share with use the release date of the EFCoreAdapter v2.0.0. Is there any roadmap or additional information about the release date?
Best regards
George
This project is still under development, but basic RBAC functions have been tested on my own
projects, but still a lot of things need to be done, includes:
RemoveFilteredPolicy
apiSavePolicy
apiCasbinRule
model configurable from application code, which means the table name, the column names can be changed. see #6I'm a little busy in the day time but would try to optimize this project
Can anyone help fix the badge? @huazhikui @sagilio
https://coveralls.io/github/casbin-net/EFCore-Adapter?branch=master
In version 1.2.0,the dependency package "Microsoft.EntityFrameworkCore.Design" is replaced with "Microsoft.EntityFrameworkCore.SqlServer".the latter one only works with Microsoft sqlserver database. Is it possible to rollback to "Microsoft.EntityFrameworkCore.Design" which provide an enough support with design-time feature?
I think the issue raised by others before still exists. And that's the question:Casbin.Adapter.EFCore Results in Duplicate Policy Records in PostgreSQL Database #65.
I did not test PostgreSQL , but I tested SQLIite and SQLServer and found that AutoSave works normally. When AutoSave=false, the problem reappears. I am using it NET6+Casbin. NET Adapters EFCore 2.1.0.
Steps to reproduce the Issue:
Another detail issue is that I directly use Visual Studio to retrieve Cabin. NET from the Nuget repository Adapters EFCore 2.1.0, cannot use AutoSave=true (i.e. default). Nuget URL is https://www.nuget.org/packages/Casbin.NET.Adapter.EFCore/2.1.0?_src=template.
This will generate an exception when calling the AddPolicy method of Enforcer. The exception is: System.EntryPointNotFoundException:“Entry point was not found.”
The details of exception is:
| StackTrace | at System.Collections.Generic.IReadOnlyCollection1.get_Count() at Casbin.Persist.Adapter.EFCore.EFCoreAdapter
3.AddPolicy(String section, String policyType, IPolicyValues values)
at Casbin.Model.DefaultPolicyManager.AddPolicy(IPolicyValues values)
at Casbin.ManagementEnforcerExtension.AddPolicy(IEnforcer enforcer, String[] values)
at Casbin.NETDemo.Form1.Test2() in C:\ZData\mywork\VS2022\Casbin.NETDemo\Casbin.NETDemo\Form1.cs:line 59
at Casbin.NETDemo.Form1.button1_Click(Object sender, EventArgs e) in C:\ZData\mywork\VS2022\Casbin.NETDemo\Casbin.NETDemo\Form1.cs:line 22
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
But I downloaded the latest source code of Casbin. NET Adapters EFCore and compiled it to use in the project.
At this point, AutoSave=true can be used correctly and the above exception will not occur.
I noticed that the nuget package forced requires EF Core >=3.1.3 from v1.2.0.
I briefly checked the latest code and there's no conflict with EF Core 2.x.
As Casbin.NET package still support netstandard2.0(netcore 2.x),how about remain EF Core 2.x requirement until Casbin.NET package update? There is some breaking changes in ef core 3.x.some of old project is still based on netCore2.x LTS and ef core 2.x
model:
# Request definition
[request_definition]
r = sub, obj, act
# Policy definition
[policy_definition]
p = sub, obj, act
# Policy effect
[policy_effect]
e = some(where (p.eft == allow))
# Matchers
[matchers]
m = r.sub == p.sub && r.obj == p.obj && r.act == p.act
Hello,
I am trying to follow your example here and I get an exception on saving.
My code:
// You should build a DbContextOptions for CasbinDbContext<TKey>.
// The example use the SQLite database named "casbin_example.sqlite3".
var options = new DbContextOptionsBuilder<CasbinDbContext<int>>()
.UseSqlite("Data Source=casbin_example.sqlite3")
.Options;
var context = new CasbinDbContext<int>(options);
// If it doesn't exist, you can use this to create it automatically.
context.Database.EnsureCreated();
// Initialize a EF Core adapter and use it in a Casbin enforcer:
var efCoreAdapter = new EFCoreAdapter<int>(context);
var e = new Enforcer("files/acl.conf", efCoreAdapter);
// Load the policy from DB.
e.LoadPolicy();
e.AddPolicy("alice", "data1", "read");
// Save the policy back to DB.
e.SavePolicy();
xUnit.net 00:00:01.57] System.InvalidOperationException : Cannot save a filtered policy
[xUnit.net 00:00:01.57] Stack Trace:
[xUnit.net 00:00:01.57] at NetCasbin.CoreEnforcer.SavePolicy()
Hello!
First, I apologize if I've overlooked something in the examples or elsewhere, though I spent the better part of yesterday looking. Starting with the example in the readme, I've modified it to use Cosmos:
let options = DbContextOptionsBuilder<CasbinDbContext<int>>()
.UseCosmos("https://localhost:8081", "key","CasbinAuthorizationDB")
.Options
let context = new CasbinDbContext<int>(options)
let! _ = context.Database.EnsureCreatedAsync () |> Async.AwaitTask
let model = Model.CreateDefaultFromFile "examples/rbac_model.conf"
let efCoreAdapter = EFCoreAdapter<int>(context);
let e = Enforcer(model, efCoreAdapter);
This works correctly, in that I end up with a database and container. However, this next bit fails:
let! result = e.AddPolicyAsync ("alice", "data1", "admin") |> Async.AwaitTask
And it throws this:
The property 'CasbinRule<int>.Id' does not have a value set and no value generator is available for properties of type 'int'. Either set a value for the property before adding the entity or configure a value generator for properties of type 'int' in 'OnModelCreating'.
I can see from poking around some of the EF (which I am utterly unfamiliar with) and Cosmos documentation that something ought be generating the IDs - however, I assumed the adapter would do that, as it's providing the class (CasbinRule) to use.
Am I wrong in my assumptions? And can anyone suggest how to resolve this?
Thanks!
John
When we can use Casbin 1.4.0 into EFCore-Adapter code?
because whenever in NuGet package manager EF Core1.3.0 is the latest version, when will be the latest version comes?
I'm trying to use Casbin.Net with PostgreSQL persistence. We're trying to use efcore migrations to create the database and the table(s), and we're having some issues since efcore migrations does not work with database contexts with type parameters such as
CasbinDbContext<Guid>
The dotnet ef migration tooling simply will not detect/find the dbContext, and will fail with:
No DbContext named 'CasbinDbContext<Guid>' was found.
So I tried to create a derived type as shown under.
/// <summary>
/// Create Verji version of the CasbinDbContext without type parameters
/// </summary>
public class VerjiCasbinDbContext : CasbinDbContext<Guid>
{
/// <inheritdoc />
public VerjiCasbinDbContext(DbContextOptions<VerjiCasbinDbContext> options)
: base(options)
{
}
}
This does not work since the base class CasbinDbContext<Guid>
does not have a constructor which takes a non-generic DbContextOptions parameter.
Would it be possible to add such a constructor to CasbinDbContext<TKey>
?
Something like:
public class CasbinDbContext<TKey> : DbContext where TKey : IEquatable<TKey>
{
private readonly IEntityTypeConfiguration<Casbin.Adapter.EFCore.Entities.CasbinRule<TKey>> _casbinModelConfig;
private readonly string _defaultSchemaName;
public virtual DbSet<Casbin.Adapter.EFCore.Entities.CasbinRule<TKey>> CasbinRule { get; set; }
public CasbinDbContext2()
{
}
// New constructor
public CasbinDbContext(DbContextOptions options) : base(options) { }
...
}
Hey guys, what are your plans regarding upgrading to net6? Migration seems straightforward. I migrated locally (including tests) but could not push / create a PR. :)
Hi, I am using EFAdapter with cosmos DB, and seems the method DeleteRoleForUser is not working.
I am using SavePolicy after calling DeleteRoleForUser(user, role, domain);
is there something I can do?
Hello;
When using this adapter (code from master branch) and deleting policy, I am getting exception.
The same configuration and code is working as expected when using only in memory Enforcer and Model.
Any help would be much appreciated.
[request_definition]
r = sub, dom, obj, act
[policy_definition]
p = sub, dom, obj, act, eft
[role_definition]
g = _, _, _
g2 = _, _, _
[policy_effect]
e = some(where (p.eft == allow)) && !some(where (p.eft == deny))
[matchers]
m = g(r.sub, p.sub, r.dom) && g2(r.obj, p.obj, r.dom) && r.act == p.act && r.dom == p.dom
And test:
var policyAdded = enforcer.AddNamedPolicy("p", "alice", "orga1", "site1:orga1", "READ", "allow");
var policyRemoved = enforcer.RemoveNamedPolicy("p", "alice", "orga1", "site1:orga1", "READ", "allow");
I am getting ArgumentOutOfRange exception:
Message:
Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
StackTrace:
at System.ThrowHelper.ThrowArgumentOutOfRange_IndexException()
at System.SZArrayHelper.get_Item[T](Int32 index)
at Casbin.Adapter.EFCore.Extensions.CasbinRuleExtenstion.ApplyQueryFilter[TCasbinRule](IQueryable`1 query, String policyType, Int32 fieldIndex, IEnumerable`1 fieldValues) in C:\Repo\EFCore-Adapter-master\Casbin.Adapter.EFCore\Extensions\CasbinRuleExtenstion.cs:line 131
at Casbin.Adapter.EFCore.EFCoreAdapter`3.RemoveFilteredPolicyInMemory(String section, String policyType, Int32 fieldIndex, String[] fieldValues) in C:\Repo\EFCore-Adapter-master\Casbin.Adapter.EFCore\EFCoreAdapter.cs:line 320
at Casbin.Adapter.EFCore.EFCoreAdapter`3.RemoveFilteredPolicy(String section, String policyType, Int32 fieldIndex, String[] fieldValues) in C:\Repo\EFCore-Adapter-master\Casbin.Adapter.EFCore\EFCoreAdapter.cs:line 233
at Casbin.Adapter.EFCore.EFCoreAdapter`3.RemovePolicyInMemory(String section, String policyType, IEnumerable`1 rule) in C:\Repo\EFCore-Adapter-master\Casbin.Adapter.EFCore\EFCoreAdapter.cs:line 315
at Casbin.Adapter.EFCore.EFCoreAdapter`3.RemovePolicy(String section, String policyType, IList`1 rule) in C:\Repo\EFCore-Adapter-master\Casbin.Adapter.EFCore\EFCoreAdapter.cs:line 211
at NetCasbin.InternalEnforcer.InternalRemovePolicy(String sec, String ptype, List`1 rule)
at NetCasbin.ManagementEnforcer.RemoveNamedPolicy(String ptype, List`1 parameters)
at NetCasbin.ManagementEnforcer.RemoveNamedPolicy(String ptype, String[] parameters)
at Casbin.Adapter.EFCore.UnitTest.AdapterTest.TestAddRemoveNamedPolicy() in C:\Repo\EFCore-Adapter-master\Casbin.Adapter.EFCore.UnitTest\AdapterTest.cs:line 284
Code location:
Class CasbinRuleExtension.cs
Method
internal static IQueryable<TCasbinRule> ApplyQueryFilter<TCasbinRule>(this IQueryable<TCasbinRule> query,
string policyType , int fieldIndex, IEnumerable<string> fieldValues)
where TCasbinRule : ICasbinRule
Failing line (fieldValueList count is 5, index is 5-0):
if (lastIndex is 5)
{
string field = fieldValuesList[5 - fieldIndex]; //here
if (string.IsNullOrWhiteSpace(field) is false)
{
query = query.Where(p => p.V5 == field);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.