advancedAuthorization: Roles, Authorities (RBAC) & Custom Filters

What is an AuthorizationDeniedEvent, and how is it different from an authentication failure event?

AuthorizationDeniedEvent fires when an ALREADY-authenticated user is denied access to a specific resource or method they lack permission for (e.g., a failed @PreAuthorize check) — the identity check succeeded, but the permission check failed. This is a distinct and arguably more serious signal than an authentication failure event (Chapter 5), since it represents a known, logged-in identity attempting an action outside their granted permissions, which is a stronger indicator of insider threat or privilege escalation attempts.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Why doesn't an @EventListener for AuthorizationDeniedEvent fire even though the code compiles fine?← Back to all Spring Security questions