Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional Statements in Spring @preauthorize EL

Hi here my problem is to add conditional statements in @preauthorize spring annotation ,I need to give Users_view and Users_manage permission for principal but i cant add both permission like below @PreAuthorize("hasPermission(#id, 'com.foo', 'USERS_VIEW','USERS_MANAGE')") in @preauthorize ,I have an idea like below

@PreAuthorize("hasPermission(#id, 'com.foo', 'USERS_VIEW') OR hasPermission(#id, 'com.foo', 'USERS_VIEW')")

Will spring support conditional clauses in @preauthorize so if not what is the solution for this.(Here I need to use only @preauthorize rather than hasroles[])

Thanks in advance

like image 780
Shabarinath Volam Avatar asked Jan 28 '26 19:01

Shabarinath Volam


1 Answers

Of course it will. But I have not tried in uppercase, in lowercase it is sure (I mean or instead of OR). See Logical operators section of the official documentation.

like image 127
Maksym Demidas Avatar answered Jan 30 '26 20:01

Maksym Demidas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!