From 0b16b50d29d7c1483994ed661c740afd462bca17 Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn <91878695+uwoobeat@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:43:37 +0900 Subject: [PATCH] =?UTF-8?q?hotfix:=20=EC=86=8C=EC=85=9C=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EB=A6=AC=EB=8B=A4=EC=9D=B4=EB=A0=89?= =?UTF-8?q?=ED=8A=B8=20URI=EA=B0=80=20=EC=9E=91=EB=8F=99=ED=95=98=EC=A7=80?= =?UTF-8?q?=20=EC=95=8A=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=20(#689)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: 추가 파라미터에서 리다이렉트 URI로 수정 --- .../CustomOAuth2AuthorizationRequestResolver.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2AuthorizationRequestResolver.java b/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2AuthorizationRequestResolver.java index 1d3ae33e3..affbcf493 100644 --- a/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2AuthorizationRequestResolver.java +++ b/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2AuthorizationRequestResolver.java @@ -3,12 +3,11 @@ import static com.gdschongik.gdsc.global.common.constant.SecurityConstant.*; import jakarta.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.Map; import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; import org.springframework.security.oauth2.client.web.DefaultOAuth2AuthorizationRequestResolver; import org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestResolver; import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest; +import org.springframework.web.util.UriComponentsBuilder; public class CustomOAuth2AuthorizationRequestResolver implements OAuth2AuthorizationRequestResolver { @@ -35,15 +34,17 @@ private OAuth2AuthorizationRequest customizeAuthorizationRequest( HttpServletRequest request, OAuth2AuthorizationRequest authorizationRequest) { String referer = request.getHeader("Referer"); + if (referer == null || referer.isEmpty()) { return authorizationRequest; } - Map additionalParameters = new HashMap<>(); - additionalParameters.put(OAUTH_TARGET_URL_PARAM_NAME, referer); + String redirectUri = UriComponentsBuilder.fromHttpUrl(authorizationRequest.getRedirectUri()) + .queryParam(OAUTH_TARGET_URL_PARAM_NAME, referer) + .toUriString(); return OAuth2AuthorizationRequest.from(authorizationRequest) - .additionalParameters(additionalParameters) + .redirectUri(redirectUri) .build(); } }