From e8c6eb951851e0443eefa94fe79ef87d26950535 Mon Sep 17 00:00:00 2001 From: diddnwjd Date: Mon, 11 Mar 2024 21:46:46 +0900 Subject: [PATCH] =?UTF-8?q?#10=20Fix:=20=ED=86=A0=ED=81=B0=EC=9D=84=20?= =?UTF-8?q?=EC=BF=A0=ED=82=A4=EB=A1=9C=20=EB=B3=B4=EB=82=B4=EA=B2=8C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ixxp/culpop/service/AdminService.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/ixxp/culpop/service/AdminService.java b/src/main/java/com/ixxp/culpop/service/AdminService.java index bf9fd4c..4f7ada5 100644 --- a/src/main/java/com/ixxp/culpop/service/AdminService.java +++ b/src/main/java/com/ixxp/culpop/service/AdminService.java @@ -8,6 +8,7 @@ import com.ixxp.culpop.util.jwtutil.JwtUtil; import javax.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseCookie; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.crypto.password.PasswordEncoder; @@ -50,7 +51,15 @@ public void loginAdmin(AdminLoginRequest adminLoginRequest, HttpServletResponse // accessToken 생성 String accessToken = jwtUtil.createAdminToken(email, admin.getRole()); - // Header 로 토큰 반환 - response.addHeader(JwtUtil.AUTHORIZATION_HEADER, accessToken); + // Cookie 로 accessToken 반환 + ResponseCookie cookie = ResponseCookie.from("AccessToken", accessToken) + .path("/") + .maxAge(7 * 24 * 60 * 60) // 7일 + .httpOnly(true) + .secure(true) + .sameSite("None") +// .domain("culpop.shop") + .build(); + response.addHeader("Set-Cookie", cookie.toString()); } }