Skip to content

Commit

Permalink
Merge pull request #16 from Hooking-CEOS/jiwon
Browse files Browse the repository at this point in the history
[fix] referer 변경
  • Loading branch information
JiwonKim08 authored Feb 4, 2024
2 parents acef507 + 2f3252e commit d7f4619
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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 shop.hooking.hooking.entity.User;
import shop.hooking.hooking.repository.UserRepository;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -71,11 +72,10 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
// targetUrl ="https://hooking.me/oath-processor"; // 로컬 환경
// }

writeTokenResponse(response, accessToken, refreshToken, targetUrl);
writeTokenResponse(request, response, accessToken, refreshToken, targetUrl);
}

private void writeTokenResponse(HttpServletResponse response, String accessToken, String refreshToken, String targetUrl) throws IOException {
// 쿠키 설정
private void writeTokenResponse(HttpServletRequest request, HttpServletResponse response, String accessToken, String refreshToken, String targetUrl) throws IOException {
Cookie accessTokenCookie = new Cookie("accessToken", accessToken);
accessTokenCookie.setSecure(false);
accessTokenCookie.setHttpOnly(false);
Expand All @@ -86,9 +86,11 @@ private void writeTokenResponse(HttpServletResponse response, String accessToken
refreshTokenCookie.setPath("/");
response.addCookie(refreshTokenCookie);

// 리다이렉트 수행
response.sendRedirect(targetUrl);
log.info("타켓URl, 쿠키정보: " + targetUrl + ", " + accessTokenCookie + ", " + refreshTokenCookie);
targetUrl = UriComponentsBuilder.fromUriString(targetUrl)
.build().toUriString();

log.info("타켓URl, 쿠키정보: " + targetUrl, accessTokenCookie, refreshTokenCookie);
getRedirectStrategy().sendRedirect(request,response, targetUrl);
}

}
Expand Down

0 comments on commit d7f4619

Please sign in to comment.