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.16k stars 111 forks source link

Invalid policy size: expected 3, got 6. #215

Closed yaobo-lab closed 3 years ago

yaobo-lab commented 3 years ago

i use EFCore-Adapter

mysql table record is

image

acl_model.conf:

[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = r.sub == p.sub && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act)`

when is use _enforcer.EnforceAsync(uid, api, httpMethod);

it throw a err: Invalid policy size: expected 3, got 6.

casbin-bot commented 3 years ago

@Sagilio

sagilio commented 3 years ago

The reason for this problem is that the length of the array of each policy in the model is not 3. Can you confirm the content of this object?

e.GetModel().Model["p"]["p"].Policy[0]
hsluoyz commented 3 years ago

@yaobo-lab you should set values of V3, V4 and V5 to null in DB.

yaobo-lab commented 3 years ago

@yaobo-lab you should set values of V3, V4 and V5 to null in DB.

thx a lot!