casbin / casbin-rs

An authorization library that supports access control models like ACL, RBAC, ABAC in Rust.
https://casbin.org
Apache License 2.0
828 stars 67 forks source link

Casbin Io Error #312

Closed Lausebengel closed 1 year ago

Lausebengel commented 1 year ago

Hello, I have an error with casbin.rs DefaultModel::from_file. Independently to what I change in the CSV-file I get this Error :

2023-07-25T10:21:05.763527Z ERROR e_label_api: Failed to load casbin model: "Casbin Io Error: Custom { kind: Other, error: \"parse content error, line=p,*,/api/login,POST\" }"

It occurs in my main.rs file in the place where I call DefaultModel::from_file with the path to my CSV-file ( The file exists and is accessible).

This is the CSV-file content:

p,*,/api/login,POST
p,*,/api/register,POST
p,User,/api/addresses,GET
p,Admin,/api/*,(GET)|(POST)

This is the model:

[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[role_definition]
g =  _, _

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

[matchers]
m = (g(r.sub, p.sub) || p.sub == "*") && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act)

It worked some hours ago and now I get this error.

Thanks in advance for any advice how to solve this.

Lausebengel commented 1 year ago

Easy solution: I accidentally loaded the CSV file as the model ...

hsluoyz commented 1 year ago

@oliver13 plz close the issue if resolved