Skip to content

Commit 45ac08b

Browse files
authored
Merge pull request #73 from studio-recoding/feat-oauth-duplex
[🚀feat] oauth 리다이렉션 URI 이중화
2 parents 283e8ac + 4ee5019 commit 45ac08b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/main/java/Ness/Backend/domain/auth/oAuth/OAuthSuccessHandler.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import jakarta.servlet.http.HttpServletResponse;
88
import lombok.RequiredArgsConstructor;
99
import lombok.extern.slf4j.Slf4j;
10+
import org.springframework.beans.factory.annotation.Value;
1011
import org.springframework.security.core.Authentication;
1112
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
1213
import org.springframework.web.util.UriComponentsBuilder;
@@ -19,6 +20,12 @@
1920
public class OAuthSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
2021
private final JwtTokenProvider jwtTokenProvider;
2122

23+
@Value("frontend.redirect-url")
24+
private String frontRedirectUrl;
25+
26+
@Value("backend.server-name")
27+
private String backServerName;
28+
2229
@Override
2330
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
2431

@@ -46,12 +53,12 @@ private String setRedirectUrl(String url) {
4653
if (url.equals("localhost")) {
4754
redirect_url = "http://localhost:8080/oauth/google/success";
4855
}
49-
/* 프론트 개발 환경 */
50-
if (url.equals("api.nessplanning.com")) {
51-
redirect_url = "http://localhost:3000/oauth/google/success/ing";
56+
/* 프론트 개발 또는 프로덕션 환경 */
57+
if (url.equals(backServerName)) {
58+
log.info("backServerName: " + backServerName);
59+
log.info("frontRedirectUrl: " + frontRedirectUrl);
60+
redirect_url = frontRedirectUrl + "/oauth/google/success/ing";
5261
}
53-
//TODO: 프론트 프로덕션 환경만 지원하는 백엔드 구축
54-
5562
return redirect_url;
5663
}
5764
}

0 commit comments

Comments
 (0)