Skip to main content

Security Errors and API Hardening

Learn Security Errors and API Hardening (Spring Security, Spring Boot) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Why Your @RestControllerAdvice Does Not See Security Errors Security runs in servlet filters , before the request reaches Spring MVC. An unauthenticated or forbidden request is rejected inside the filter chain, so your controller advice never sees it. Without extra setup the client gets a plain empty 401/403 (or, for browsers, a redirect to a login page) - not the JSON error your API returns everywhere else.

More lessons in Spring Security