From 384e2b3b547b0f29fd0a01ab109fb2298bc7c076 Mon Sep 17 00:00:00 2001 From: gkim Date: Sat, 23 Dec 2023 17:03:17 +0900 Subject: [PATCH] :ambulance: fix: Add cookie domain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 쿠키 도메인 정보 추가 Related: #42 --- .../java/com/ceos/vote/auth/controller/AuthController.java | 6 ++++++ src/main/resources/application.yml | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/ceos/vote/auth/controller/AuthController.java b/src/main/java/com/ceos/vote/auth/controller/AuthController.java index a42269f..2195c9b 100644 --- a/src/main/java/com/ceos/vote/auth/controller/AuthController.java +++ b/src/main/java/com/ceos/vote/auth/controller/AuthController.java @@ -9,6 +9,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.web.server.Cookie; import org.springframework.http.*; import org.springframework.web.bind.annotation.*; @@ -18,6 +19,9 @@ @RequiredArgsConstructor public class AuthController { + @Value("${domain}") + private String domain; + private final long COOKIE_EXPIRATION = 7776000; // 90일 private final AuthService authService; @@ -38,6 +42,7 @@ public ResponseEntity login(@RequestBody LoginRequestDto loginRequest) { HttpCookie httpCookie = ResponseCookie.from("refresh-token", tokenDto.getRefreshToken()) .maxAge(COOKIE_EXPIRATION) .path("/") + .domain(domain) .httpOnly(true) .secure(true) .sameSite(Cookie.SameSite.NONE.attributeValue()) //서드파티 쿠키 사용 허용 @@ -76,6 +81,7 @@ public ResponseEntity reissue(@CookieValue("refresh-token") String requestRef ResponseCookie responseCookie = ResponseCookie.from("refresh-token", newAuthToken.getRefreshToken()) .maxAge(COOKIE_EXPIRATION) .path("/") + .domain(domain) .httpOnly(true) .secure(true) .sameSite(Cookie.SameSite.NONE.attributeValue()) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index e3c8639..3725fc4 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -42,4 +42,6 @@ server: springdoc: swagger-ui: - path: /swagger-vote.html \ No newline at end of file + path: /swagger-vote.html + +domain: ENC(wtMoW4E5IOZgq215uWHzGsBlrqecbyNr9lsrql5da0LFtz4cywsN8Fap3bhNqVYQ0RuvblLIewQZo+u8pBCaFA==) \ No newline at end of file