Skip to content
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

Error encountered when creating an Enforcer based on the ABAC model: extraneous or missing "in quoted field" #63

Open
Harris-H opened this issue Jan 19, 2024 · 2 comments
Assignees
Labels

Comments

@Harris-H
Copy link

I found that the first time I created an Enforcer when the database was empty and checked if the request was fulfilled without any issues, but when the database included these policies, creating an Enforcer would result in an error message: extraneous or missing "in quoted field". What is the problem? Please help me.

I am using an adapter based on MongoDB

	a, err := mongodbadapter.NewAdapterWithClientOption(mongoClientOption, databaseName)
	if err != nil {
		panic(err)
	}

	e, err := casbin.NewEnforcer("../conf/abac_model.conf", a)

My model:

[request_definition]
r = sub, obj, act

[policy_definition]
p = sub_rule, obj, act

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

[matchers]
m = eval(p.sub_rule) && r.obj == p.obj && r.act == p.act

My policy:
image

My request(s):

models.UserRole{
		Role: "test_admin",
	}, index, read ---> true
@hsluoyz
Copy link
Member

hsluoyz commented Jan 19, 2024

@Harris-H can you provide a full example? Which API did you call? and paste the IDE error directly

@Harris-H
Copy link
Author

@Harris-H can you provide a full example? Which API did you call? and paste the IDE error directly

image
When I call the NewEnforcer() function API, I will report an error: extraneous or missing "in quoted field". However, I will not report an error when I do not have a policy in the database. Testing with request also runs normally, and creating an Enforcer again after adding a policy will report an error.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants