Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

"ABAC with policy rule" doesn't work #145

Closed
uPagge opened this issue Feb 17, 2021 · 8 comments
Closed

"ABAC with policy rule" doesn't work #145

uPagge opened this issue Feb 17, 2021 · 8 comments
Assignees
Labels

Comments

@uPagge
Copy link

uPagge commented Feb 17, 2021

I have a policy like this, in the editor it works

изображение

But in java it refuses to work

изображение

изображение
изображение

изображение

What could be the problem?

@uPagge uPagge changed the title Pilicy not work Policy not work Feb 17, 2021
@hsluoyz hsluoyz self-assigned this Feb 17, 2021
@hsluoyz hsluoyz changed the title Policy not work "ABAC with policy rule" doesn't work Feb 17, 2021
@hsluoyz hsluoyz added the dependencies Pull requests that update a dependency file label Feb 17, 2021
@hsluoyz hsluoyz added enhancement bug and removed dependencies Pull requests that update a dependency file enhancement labels Feb 17, 2021
@hsluoyz
Copy link
Member

hsluoyz commented Feb 17, 2021

@shy1st please take a look.

@shy1st
Copy link
Contributor

shy1st commented Feb 18, 2021

I think there is something wrong with the way you use it.You should create a class and then create a property named "name" in the class and ensure that the class has the "Name" attribute of the get method and to ensure that the access permissions of this class and this property are "public". Then calling the enforce method of Enforcer, the first parameter is an instantiated object of this class. Please look at the example I wrote:
捕获

@shy1st shy1st removed the bug label Feb 18, 2021
@hsluoyz hsluoyz added the bug label Feb 18, 2021
@uPagge
Copy link
Author

uPagge commented Feb 18, 2021

@shy1st I tried your example and everything turned out in a separate file. But as soon as I returned to Spring Boot it stopped working.

изображение

@uPagge
Copy link
Author

uPagge commented Feb 18, 2021

@shy1st I think I found what the problem is. The entity I am using has lazy initialized fields (Hibernate). And apparently because of them this problem occurs. I created another entity with only one Name field in the Srpting Boot project I wrote about above and it worked. But it's very sad how to do without lazy fields.

@shy1st
Copy link
Contributor

shy1st commented Feb 18, 2021

You can try to wake up this fields before using enforcer method.Maybe you can call one method of the field(try to use the field) to initial the field.Do you think it's alright? @uPagge

@shy1st
Copy link
Contributor

shy1st commented Mar 3, 2021

@uPagge We use janino instead of beanShell to implement eval function of BuiltInFunctions in jcasbin v1.7..It's possible that your problem has solved.Please try again and let us know if you still have problems.

@hsluoyz
Copy link
Member

hsluoyz commented Mar 3, 2021

@uPagge plz check if it's fixed in latest v1.7.1: https://github.com/casbin/jcasbin/releases/tag/v1.7.1

@hsluoyz
Copy link
Member

hsluoyz commented Mar 13, 2021

Closed as resolved.

@hsluoyz hsluoyz closed this as completed Mar 13, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants