From c22448144ed52d9480c5729cb47fb85a0035a508 Mon Sep 17 00:00:00 2001 From: ajeong Date: Thu, 26 Dec 2024 23:31:21 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=EC=BF=A0=ED=82=A4=20=ED=97=A4=EB=8D=94?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95=20#149?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/KakaoLoginController.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/WELLET/welletServer/kakaologin/controller/KakaoLoginController.java b/src/main/java/WELLET/welletServer/kakaologin/controller/KakaoLoginController.java index 6be149e..354f6c2 100644 --- a/src/main/java/WELLET/welletServer/kakaologin/controller/KakaoLoginController.java +++ b/src/main/java/WELLET/welletServer/kakaologin/controller/KakaoLoginController.java @@ -92,12 +92,21 @@ public String callback(@RequestParam("code") String code, HttpServletResponse re String jwtToken = jwtService.generateToken(member); // 생성된 또는 업데이트된 사용자로 JWT 생성 // //// // 5. 쿠키에 JWT 저장 - Cookie jwtCookie = new Cookie("Set-Cookie", jwtToken); - jwtCookie.setHttpOnly(true); // JavaScript로 쿠키에 접근 불가 - jwtCookie.setSecure(true); // HTTPS에서만 전송 +// Cookie jwtCookie = new Cookie("Set-Cookie", jwtToken); +// jwtCookie.setHttpOnly(true); // JavaScript로 쿠키에 접근 불가 +// jwtCookie.setSecure(true); // HTTPS에서만 전송 +// jwtCookie.setMaxAge(60 * 60 * 24); // 쿠키 유효 시간 설정 +// jwtCookie.setPath("/"); // 쿠키를 모든 경로에 적용 +// jwtCookie.setDomain("wellet"); + + Cookie jwtCookie = new Cookie("jwtToken", jwtToken); + jwtCookie.setHttpOnly(true); + jwtCookie.setSecure(true); // HTTPS에서만 전송 jwtCookie.setMaxAge(60 * 60 * 24); // 쿠키 유효 시간 설정 - jwtCookie.setPath("/"); // 쿠키를 모든 경로에 적용 - jwtCookie.setDomain("wellet"); + jwtCookie.setPath("/"); + response.addCookie(jwtCookie); + + response.addHeader("Set-Cookie", "jwtToken=" + jwtToken + "; Path=/; HttpOnly; Secure; Max-Age=" + (60 * 60 * 24) + "; SameSite=None"); // response.setHeader("Set-Cookie","token=" + jwtToken +. ;Path=/; Domain=localhost; HttpOnly; Max-Age=604800; SameSite=None; Secure;");