From f1005f330c33fb0f60a282f48fa49a83691ca79b Mon Sep 17 00:00:00 2001 From: Dongmin Kim Date: Thu, 28 Dec 2023 19:42:47 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=EC=86=8C=EC=85=9C=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EA=B8=B0=EB=8A=A5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 인증과 관련된 정보를 쿼리 파라미터에 포함시켜 응답하도록 수정 --- .../security/oauth/OAuthSuccessHandler.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/api/trip/common/security/oauth/OAuthSuccessHandler.java b/src/main/java/com/api/trip/common/security/oauth/OAuthSuccessHandler.java index 8f3e953..83e27bc 100644 --- a/src/main/java/com/api/trip/common/security/oauth/OAuthSuccessHandler.java +++ b/src/main/java/com/api/trip/common/security/oauth/OAuthSuccessHandler.java @@ -17,6 +17,7 @@ import org.springframework.security.oauth2.core.user.OAuth2User; import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; import org.springframework.stereotype.Component; +import org.springframework.web.util.UriComponentsBuilder; import java.io.IOException; import java.util.Optional; @@ -58,12 +59,16 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo // OAuth2User 객체에서 권한 가져옴 JwtToken jwtToken = jwtTokenProvider.createJwtToken(member.getEmail(), member.getRole().getValue()); - response.addHeader(HttpHeaders.SET_COOKIE, createCookie("accessToken", jwtToken.getAccessToken())); - response.addHeader(HttpHeaders.SET_COOKIE, createCookie("refreshToken", jwtToken.getRefreshToken())); - response.addHeader(HttpHeaders.SET_COOKIE, createCookie("memberId", String.valueOf(member.getId()))); - response.addHeader(HttpHeaders.SET_COOKIE, createCookie("profileImgUrl", member.getProfileImg())); - - response.sendRedirect("https://dkoqktaeu3tic.cloudfront.net/home"); + String targetUrl = UriComponentsBuilder.fromUriString("https://dkoqktaeu3tic.cloudfront.net/home") + .queryParam("accessToken", jwtToken.getAccessToken()) + .queryParam("refreshToken", jwtToken.getRefreshToken()) + .queryParam("memberId", String.valueOf(member.getId())) + .queryParam("profileImgUrl", member.getProfileImg()) + .build().toUriString(); + + getRedirectStrategy().sendRedirect(request, response, targetUrl); + + } private static String createCookie(String name, String value) {