Summary
Defined a bean as: @Component(value="accessBean") public class AccessCheckBean { public String getPermision(){ /* * return the api permision / String scope = "#oauth2.hasScope('resource.Update')"; return scope; } }
and in controller: @PreAuthorize("accessBean.getPermision()") @GetMapping("/perm") public @ResponseBody String getPerm(){ return "Perm"; }
Failed to evaluate expression 'accessBean.getPermision()'
How to use this annotation with SpEL with the version of 4.1.4?
Actual Behavior
Failed to evaluate expression 'accessBean.getPermision()'
Expected Behavior
Authorized
Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true) in security configure class
Version
Spring security 4.1.4, Spring boot 1.4.3.RELEASE
Sample
Like above.
Comment From: simplicii
@PreAuthorize("{@accessBean.getPermision()}")
Comment From: eleftherias
The above comment is correct.