diff --git a/src/main/java/com/umc/naoman/global/security/repository/OAuth2AuthorizationRequestBasedOnCookieRepository.java b/src/main/java/com/umc/naoman/global/security/repository/OAuth2AuthorizationRequestBasedOnCookieRepository.java index f4e7c5c..93b4da9 100644 --- a/src/main/java/com/umc/naoman/global/security/repository/OAuth2AuthorizationRequestBasedOnCookieRepository.java +++ b/src/main/java/com/umc/naoman/global/security/repository/OAuth2AuthorizationRequestBasedOnCookieRepository.java @@ -4,11 +4,13 @@ import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; import org.springframework.security.oauth2.client.web.AuthorizationRequestRepository; import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest; import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames; import org.springframework.web.util.WebUtils; +@Slf4j public class OAuth2AuthorizationRequestBasedOnCookieRepository implements AuthorizationRequestRepository { public final static String OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME = "OAuth2_AUTHORIZATION_REQUEST"; @@ -18,6 +20,7 @@ public class OAuth2AuthorizationRequestBasedOnCookieRepository public OAuth2AuthorizationRequest loadAuthorizationRequest(HttpServletRequest request) { String stateParameter = request.getParameter(OAuth2ParameterNames.STATE); if (stateParameter == null) { + log.debug("loadAuthorizationRequest() - state 파라미터 부재"); return null; } @@ -29,9 +32,11 @@ public OAuth2AuthorizationRequest loadAuthorizationRequest(HttpServletRequest re if (stateParameter.equals(authorizationRequest.getState())) { return authorizationRequest; } else { + log.debug("loadAuthorizationRequest() - state 파라미터 불일치"); return null; } } else { + log.debug("loadAuthorizationRequest() - OAuth2_AUTHORIZATION_REQUEST 키의 쿠키 존재하지 않음"); return null; } } @@ -41,10 +46,12 @@ public void saveAuthorizationRequest(OAuth2AuthorizationRequest authorizationReq HttpServletResponse response) { if (authorizationRequest == null) { removeAuthorizationRequest(request, response); + log.debug("saveAuthorizationRequest() - 파라미터로 전달된 authorizationRequest가 null"); return; } if (authorizationRequest.getState() == null) { + log.debug("saveAuthorizationRequest() - authorization.getState() 값 null"); throw new IllegalArgumentException("authorizationRequest.state cannot be empty"); } CookieUtils.addCookie(response, OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME, @@ -57,6 +64,8 @@ public OAuth2AuthorizationRequest removeAuthorizationRequest(HttpServletRequest OAuth2AuthorizationRequest authorizationRequest = loadAuthorizationRequest(request); if (authorizationRequest != null) { CookieUtils.deleteCookie(request, response, OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME); + } else { + log.debug("removeAuthorizationRequest() - loadAuthorizationREquest() 리턴값 null"); } return authorizationRequest; }