Interview questions
Question 250 of 254
FreeWhat is the difference between AuthenticationEntryPoint and AccessDeniedHandler?
Spring Security Internals & Testing
AuthenticationEntryPoint handles the case where an unauthenticated request tries to access a protected resource — it's responsible for producing the response that tells the client how to authenticate (e.g., a 401 with a `WWW-Authenticate` header, or a redirect to a login page). AccessDeniedHandler handles the case where a request IS authenticated but lacks the required authority for the resource — producing a 403 response. Both are configurable via `exceptionHandling()` on the SecurityFilterChain, and mixing them up is a common source of returning the wrong status code (401 vs 403) for the wrong failure reason.
Advanced7 min
