I have a @Controller endpoint which I need to secure with a custom method, defined as a static method in another class, which I load into this project as a dependency (JAR). This is my code:
@PostMapping("/my-list")
@PreAuthorize("'#{securityUtil.isAuthorizedToQuery(principal.getJwtToken(),request.headers['Account-Public-Id'])}'")
public List<TradeList> getTradeList(@RequestBody QueriesRqtDto queriesDto, @RequestHeader("Account-Public-Id") String account) {
return tradeFinder.find(queriesDto,account);
}
But I get this error:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.expression.spel.SpelParseException: EL1041E: After parsing a valid expression, there is still more data in the expression: 'Account'
None of the solutions provided in Stack Overflow for similar problems worked for me.