Skip to content

Commit

Permalink
Merge pull request #27 from 9oormthon-univ/dev
Browse files Browse the repository at this point in the history
[#2]🐛Fix: 쿠키 수정
  • Loading branch information
sumin220 authored Nov 22, 2024
2 parents 75a0428 + 9211498 commit a09b997
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/java/univ/yesummit/global/oauth/OAuth2SuccessHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,23 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
int accessTokenMaxAge = jwtUtils.getAccessExpiration().intValue() / 1000; // 밀리초를 초로 변환
int refreshTokenMaxAge = jwtUtils.getRefreshExpiration().intValue() / 1000;

// Access Token 쿠키
Cookie accessTokenCookie = new Cookie("accessToken", accessToken);
// accessTokenCookie.setHttpOnly(true); // js 접근 불가
// accessTokenCookie.setSecure(false);
accessTokenCookie.setPath("/");
accessTokenCookie.setHttpOnly(true); // JavaScript 접근 불가
accessTokenCookie.setSecure(false); // HTTPS가 아닌 경우 false
accessTokenCookie.setDomain("localhost"); // 로컬 환경 도메인 설정
accessTokenCookie.setPath("/"); // 모든 경로에서 유효
accessTokenCookie.setMaxAge(accessTokenMaxAge);

// Refresh Token 쿠키
Cookie refreshTokenCookie = new Cookie("refreshToken", refreshToken);
// refreshTokenCookie.setHttpOnly(true); // js 접근 불가
// refreshTokenCookie.setSecure(false);
refreshTokenCookie.setHttpOnly(true);
refreshTokenCookie.setSecure(false);
refreshTokenCookie.setDomain("localhost");
refreshTokenCookie.setPath("/");
refreshTokenCookie.setMaxAge(refreshTokenMaxAge);


response.addCookie(accessTokenCookie);
response.addCookie(refreshTokenCookie);

Expand Down

0 comments on commit a09b997

Please sign in to comment.