Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TSK-59] 테스트 samesite #139

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,21 @@ public void sendAccessAndRefreshToken(HttpServletResponse response, String acces
setAccessTokenHeader(response, accessToken);

// Refresh Token을 HttpOnly 쿠키로 설정
Cookie refreshTokenCookie = new Cookie("Authorization-refresh", refreshToken);
refreshTokenCookie.setHttpOnly(true);
refreshTokenCookie.setSecure(true); // HTTPS에서만 전송
refreshTokenCookie.setPath("/");
// refreshTokenCookie.setDomain("localhost");
// refreshTokenCookie.setMaxAge(300); // 5분 동안 유효
refreshTokenCookie.setMaxAge(7 * 24 * 60 * 60); // 일주일 동안 유효
response.addCookie(refreshTokenCookie);
// Cookie refreshTokenCookie = new Cookie("Authorization-refresh", refreshToken);
// refreshTokenCookie.setHttpOnly(true);
// refreshTokenCookie.setSecure(true); // HTTPS에서만 전송
// refreshTokenCookie.setPath("/");
//// refreshTokenCookie.setDomain("localhost");
//// refreshTokenCookie.setMaxAge(300); // 5분 동안 유효
// refreshTokenCookie.setMaxAge(7 * 24 * 60 * 60); // 일주일 동안 유효
// response.addCookie(refreshTokenCookie);

// Refresh Token을 HttpOnly 쿠키로 설정하고, SameSite=None을 적용
String cookieValue = String.format(
"Authorization-refresh=%s; Path=/; HttpOnly; Secure; Max-Age=%d; SameSite=None",
refreshToken, 7 * 24 * 60 * 60 // 일주일 유효
);
response.setHeader("Set-Cookie", cookieValue);
}

@Override
Expand Down