From 873aeef70a08b029be14da62d98f96865ec461a7 Mon Sep 17 00:00:00 2001 From: YoungJun Park Date: Sun, 3 Oct 2021 23:23:10 +0900 Subject: [PATCH] =?UTF-8?q?[#4]=20OAuth2.0=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=20=EC=8B=9C=EB=8F=84=20=EC=8B=A4=ED=8C=A8=20Handler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/handler/OAuth2FailureHandler.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 api/src/main/java/com/teamnexters/lazy/api/config/auth/handler/OAuth2FailureHandler.java diff --git a/api/src/main/java/com/teamnexters/lazy/api/config/auth/handler/OAuth2FailureHandler.java b/api/src/main/java/com/teamnexters/lazy/api/config/auth/handler/OAuth2FailureHandler.java new file mode 100644 index 0000000..0bd3ff8 --- /dev/null +++ b/api/src/main/java/com/teamnexters/lazy/api/config/auth/handler/OAuth2FailureHandler.java @@ -0,0 +1,33 @@ +package com.teamnexters.lazy.api.config.auth.handler; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.authentication.AuthenticationFailureHandler; +import org.springframework.stereotype.Component; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Slf4j +@RequiredArgsConstructor +@Component +public class OAuth2FailureHandler implements AuthenticationFailureHandler { + + /** + * Called when an authentication attempt fails. + * + * @param request the request during which the authentication attempt occurred. + * @param response the response. + * @param exception the exception which was thrown to reject the authentication + */ + @Override + public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) + throws IOException, ServletException { + log.info(">>> Failure Request : {}", request); + log.info(">>> Failure Response : {}", response); + log.error(">>> Error ", exception); + } +} \ No newline at end of file