Skip to content

Commit 62968cb

Browse files
authored
fix/OPS-402: 오류 수정 #3 (#179)
1 parent dae7963 commit 62968cb

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/main/java/org/tuna/zoopzoop/backend/domain/auth/controller/ApiV1AuthController.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import io.swagger.v3.oas.annotations.tags.Tag;
55
import jakarta.servlet.http.HttpServletResponse;
66
import lombok.RequiredArgsConstructor;
7+
import org.springframework.beans.factory.annotation.Value;
78
import org.springframework.http.HttpHeaders;
89
import org.springframework.http.HttpStatus;
910
import org.springframework.http.ResponseCookie;
@@ -15,6 +16,7 @@
1516
import org.tuna.zoopzoop.backend.domain.auth.entity.RefreshToken;
1617
import org.tuna.zoopzoop.backend.domain.auth.service.refresh.RefreshTokenService;
1718
import org.tuna.zoopzoop.backend.domain.member.entity.Member;
19+
import org.tuna.zoopzoop.backend.global.config.jwt.JwtProperties;
1820
import org.tuna.zoopzoop.backend.global.rsData.RsData;
1921
import org.tuna.zoopzoop.backend.global.security.jwt.JwtUtil;
2022

@@ -23,10 +25,14 @@
2325
@RequestMapping("api/v1/auth")
2426
@Tag(name = "ApiV1AuthController", description = "인증/인가 REST API 컨트롤러")
2527
public class ApiV1AuthController {
28+
private final JwtProperties jwtProperties;
2629
private final JwtUtil jwtUtil;
2730
private final RefreshTokenService refreshTokenService;
2831
private final AuthResult authResult;
2932

33+
@Value("${front.main_domain}")
34+
private String main_domain;
35+
3036
/**
3137
* 사용자 로그아웃 API
3238
* @param response Servlet 기반 웹에서 server -> client로 http 응답을 보내기 위한 객체, 자동 주입.
@@ -46,14 +52,18 @@ public ResponseEntity<RsData<Void>> logout(
4652
.httpOnly(true)
4753
.path("/")
4854
.maxAge(0)
49-
.sameSite("Lax")
55+
.domain(main_domain)
56+
.secure(true)
57+
.sameSite("None")
5058
.build();
5159

5260
ResponseCookie sessionCookie = ResponseCookie.from("sessionId", "")
5361
.httpOnly(true)
5462
.path("/")
55-
.maxAge(0)
56-
.sameSite("Lax")
63+
.maxAge(0) // RefreshToken 유효기간과 동일하게
64+
.domain(main_domain)
65+
.secure(true)
66+
.sameSite("None")
5767
.build();
5868

5969
response.addHeader(HttpHeaders.SET_COOKIE, accessCookie.toString());
@@ -113,8 +123,10 @@ public ResponseEntity<RsData<Void>> refreshToken(
113123
ResponseCookie accessCookie = ResponseCookie.from("accessToken", newAccessToken)
114124
.httpOnly(true)
115125
.path("/")
116-
.maxAge(jwtUtil.getAccessTokenValiditySeconds())
117-
.sameSite("Lax")
126+
.maxAge(jwtProperties.getAccessTokenValidity() / 1000)
127+
.domain(main_domain)
128+
.secure(true)
129+
.sameSite("None")
118130
.build();
119131

120132
response.addHeader(HttpHeaders.SET_COOKIE, accessCookie.toString());

0 commit comments

Comments
 (0)