Conditional Statements in Spring @preauthorize EL

spring, spring-security

Solution

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.

Problem

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

Original source