I am trying to find a way to add more token validation with @preauthorize annotation. meaning that I need to validate the issuedAt field in the token against a field in the database every time a request happens, but I need to do it while spring boot checks the token validity to avoid parsing the token again which is terrible for performance... any solutions?
here is the function I want to add the validation to it
@PostMapping("/add")
@PreAuthorize("hasAuthority('user_add')")
public void addUser(@RequestBody User user,HttpServletRequest request){
userService.addNewUser(user,request);
}
and here is the logic I want to perform at each request
String tokenIssuedAt= getIssuedAtDateFromToken(token,secretKey);
if(!tokenIssuedAt.equals(sessionID) ){ // token is not validated as it is not up-to-date
throw new ResponseStatusException(HttpStatus.FORBIDDEN,"Session not up-to-date!!");
}