Skip to content

Commit

Permalink
feat: cookie same site none 설정 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
pjm2571 committed Oct 22, 2024
1 parent 3a2e778 commit 6414d32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/github-action-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy Spring Application to EC2
# test/dev에 대한 브랜치 push가 수행되었을 때 동작
on:
push:
branches: [ "dev-be" ]
branches: [ "dev-be", "test/dev" ]

# 워크플로우가 저장소의 콘텐츠를 읽을 수 있는 권한을 갖도록 설정
permissions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,20 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
// 4. JWT 토큰을 쿠키에 저장
Cookie accessTokenCookie = new Cookie("accessToken", accessToken);
accessTokenCookie.setHttpOnly(false);
accessTokenCookie.setSecure(true);
accessTokenCookie.setPath("/");
accessTokenCookie.setMaxAge(60 * 60);
accessTokenCookie.setSecure(true); // HTTPS 연결에서만 쿠키가 전송되도록 설정
accessTokenCookie.setPath("/"); // 쿠키가 모든 경로에서 유효하도록 설정
accessTokenCookie.setMaxAge(60 * 60); // 1시간 동안 유효

// SameSite=None으로 설정하여 크로스 도메인에서 쿠키가 전송될 수 있도록 설정
accessTokenCookie.setAttribute("SameSite", "None");

// refreshToken도 동일하게 설정
Cookie refreshTokenCookie = new Cookie("refreshToken", refreshToken);
refreshTokenCookie.setHttpOnly(true);
refreshTokenCookie.setSecure(true);
refreshTokenCookie.setPath("/");
refreshTokenCookie.setMaxAge(7 * 24 * 60 * 60);
refreshTokenCookie.setAttribute("SameSite", "None");

// 5. 응답에 쿠키 추가
response.addCookie(accessTokenCookie);
Expand Down

0 comments on commit 6414d32

Please sign in to comment.