-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Casbin.net Breaking changes while migrating from V1.13.0 to V2.9.1 - GetModel and GetPolicy #367
Comments
Would you like to provide a valid model and policy text sample?
For example:
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == r.obj.Owner You can get the tokens count like this: var assertion = e.Model.Sections.GetPolicyAssertion(PermConstants.DefaultPolicyType);
var tokensCount = assertion.Tokens.Count;
|
permission model:
permission policy sample:
the above code was used to validate if policy is setup as per the model. can we validate using any other way in the latest version? |
any update here? |
Here is the sample: private bool IsValidPermissionPolicySetup(string model, string policy)
{
CustomEnforcer enforcer = new CustomEnforcer(model, policy);
return enforcer.GetPolicy().All(p =>
{
string last = p.Last();
return last is "allow" or "deny";
});
} |
I am trying to migrate Casbin.net package from V1.13.0 to V2.9.1. I was validating my permission setup with this function in the earlier version.
in the wiki, it says that
enforcer.GetModel()
is now replaced byenforcer.Model
. but I couldn't find a way to get this count as theIModel
interface doesn't explicitly have any property. Also, the wiki doesn't mention the alternative ofenforcer.GetPolicy()
so not sure how to convert the above function to the latest version. Can someone help here?The text was updated successfully, but these errors were encountered: