I'm trying to write a custom spring security expression with PreAuthorize. I want to achieve this:
@PreAuthorize(customAuthCheck(param1, param2))
@RestController
public String getRestrictedInfo(HttpServletRequest request) {
//
}
where param1, param2 depends on the business logic.
In my AuthSecurityExpressionRoot class:
public class CustomMethodSecurityExpressionRoot extends SecurityExpressionRoot implements MethodSecurityExpressionOperations {
public boolean customAuthCheck(String param1, String param2) {
// check authorization
}
}
The problem is, I want to access the http request (specifically, the "Authorization" header, and the httpMethod) inside the customAuthCheck method. How can I implement that?