casbin / Casbin.NET

An authorization library that supports access control models like ACL, RBAC, ABAC in .NET (C#)

Home Page:https://casbin.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does using Casbin.NET support defining multiple M's in matchers? For example, m1 m2

qq1176914912 opened this issue · comments

When I configure the following figure in the conf file:
image
Error will be displayed: can not find the assertion at the section m and policy type m. 。
I don't know if. net temporarily doesn't support defining multiple M's in matchers, or if my writing is wrong.
image

Casbin,NET supports this feature, you can see the example here:

public void TestMultipleTypeModel()
{
Enforcer e = new(_testModelFixture.GetNewMultipleTypeTestModel());
e.BuildRoleLinks();
// Use default types
EnforceContext context = e.CreateContext();
Assert.True(e.Enforce(context, "alice", "data1", "read"));
Assert.False(e.Enforce(context, "alice", "data1", "write"));
Assert.True(e.Enforce(context, "bob", "data2", "read"));
Assert.False(e.Enforce(context, "bob", "data2", "write"));
// Use r2 p2 and m2 type
context = e.CreateContext
(
PermConstants.RequestType2,
PermConstants.PolicyType2,
PermConstants.DefaultPolicyEffectType,
PermConstants.MatcherType2
);
Assert.True(e.Enforce(context, "alice", "domain1", "data2", "read"));
Assert.False(e.Enforce(context, "alice", "domain1", "data2", "write"));
Assert.True(e.Enforce(context, "bob", "domain1", "data1", "read"));
Assert.False(e.Enforce(context, "bob", "domain1", "data1", "write"));
// Use r3 p3 and m3 type
context = e.CreateContext
(
PermConstants.RequestType3,
PermConstants.PolicyType3,
PermConstants.DefaultPolicyEffectType,
PermConstants.MatcherType3
);
Assert.True(e.Enforce(context, new { Age = 30 }, "data2", "read"));
Assert.False(e.Enforce(context, new { Age = 70 }, "data2", "read"));
}

close by #194