I thought PostAuthorize decorated method should return an object having an attribute that is a part of authorization(e.g, 'username'). I put the annotation on getOrder() method show below. Why the annotation is not functioning?
@GetMapping("/read")
public String showOrderDetail(Model model, HttpServletRequest request,
        Principal principal) {
    String idStr = request.getParameter("id");
    var corder = new Corder();
    corder.setId(35);
    if (idStr != null) {
        Integer id = Integer.parseInt(idStr);
        corder = this.getOrder(id, principal);
    }
    model.addAttribute("corder", corder);
    return "orderDetails";
}
@PostAuthorize("hasRole('ADMIN') || " +
    "authentication.name == returnObject.username")
private Corder getOrder(Integer id, Principal principal) {
    Corder corder = repository.findById(id).orElseThrow();
    User user = userRepository.findById(corder.getUserId()).get();
    corder.setUsername(user.getUsername());
    return corder;
}
 
    