diff --git a/src/main/java/univ/yesummit/global/oauth/OAuth2SuccessHandler.java b/src/main/java/univ/yesummit/global/oauth/OAuth2SuccessHandler.java index 4b5014b..3202a46 100644 --- a/src/main/java/univ/yesummit/global/oauth/OAuth2SuccessHandler.java +++ b/src/main/java/univ/yesummit/global/oauth/OAuth2SuccessHandler.java @@ -47,18 +47,23 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo int accessTokenMaxAge = jwtUtils.getAccessExpiration().intValue() / 1000; // 밀리초를 초로 변환 int refreshTokenMaxAge = jwtUtils.getRefreshExpiration().intValue() / 1000; + // Access Token 쿠키 Cookie accessTokenCookie = new Cookie("accessToken", accessToken); -// accessTokenCookie.setHttpOnly(true); // js 접근 불가 -// accessTokenCookie.setSecure(false); - accessTokenCookie.setPath("/"); + accessTokenCookie.setHttpOnly(true); // JavaScript 접근 불가 + accessTokenCookie.setSecure(false); // HTTPS가 아닌 경우 false + accessTokenCookie.setDomain("localhost"); // 로컬 환경 도메인 설정 + accessTokenCookie.setPath("/"); // 모든 경로에서 유효 accessTokenCookie.setMaxAge(accessTokenMaxAge); + // Refresh Token 쿠키 Cookie refreshTokenCookie = new Cookie("refreshToken", refreshToken); -// refreshTokenCookie.setHttpOnly(true); // js 접근 불가 -// refreshTokenCookie.setSecure(false); + refreshTokenCookie.setHttpOnly(true); + refreshTokenCookie.setSecure(false); + refreshTokenCookie.setDomain("localhost"); refreshTokenCookie.setPath("/"); refreshTokenCookie.setMaxAge(refreshTokenMaxAge); + response.addCookie(accessTokenCookie); response.addCookie(refreshTokenCookie);