Performance: Securing endpoints by role
MEDIUM IMPACT
This affects the server response time and user experience by controlling access before processing requests.
@PreAuthorize("hasRole('ADMIN')") public String getAdminData() { return adminService.getData(); }
public String getAdminData() {
if (!user.hasRole("ADMIN")) {
throw new AccessDeniedException("Forbidden");
}
return adminService.getData();
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual role checks inside controller methods | 0 | 0 | 0 | [OK] |
| Declarative role checks with @PreAuthorize annotations | 0 | 0 | 0 | [OK] Good |