-
Notifications
You must be signed in to change notification settings - Fork 3
UsernamePasswordAuthenticationFilter
Carol edited this page Aug 28, 2024
·
1 revision
AuthenticationException
-
AuthenticationException
사용:- Spring Security는
AuthenticationException
을 통해 인증 실패를 처리합니다. 따라서, 이 예외를 던지면unsuccessfulAuthentication
메서드가 정상적으로 호출됩니다.
- Spring Security는
-
구체적인 예외 처리:
-
IOException
등 예상되는 예외에 대해 구체적인 메시지를 포함한AuthenticationException
을 던집니다. 이로 인해 사용자가 로그인 실패의 원인을 명확하게 알 수 있습니다. - 마지막
catch
블록에서 발생한 모든 다른 예외도AuthenticationException
으로 래핑하여 던집니다. 이를 통해 예상하지 못한 예외도unsuccessfulAuthentication
메서드에서 처리될 수 있습니다.
-
*super.successfulAuthentication(request, response, chain, authResult);*
→ /로 redirect된다.
만약 다른 경로로 redirect 하고 싶다면
response.sendRedirect("/owner?message=" + Const.***LOGIN_COMPLETED***);
위와 같이 직접 redirect 시켜주면 된다.