Skip to content

Commit

Permalink
feat: 쿠키 설정 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
tjdwns5063 committed Feb 19, 2024
1 parent c48eb05 commit 62590c3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/java/com/strcat/config/oauth/OAuthSuccessHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseCookie;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
Expand All @@ -36,14 +38,17 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
String provider = request.getRequestURI().split("/")[4];
User user = oAuthUserService.signIn(authentication.getName(), provider);
String token = jwtUtils.createJwtToken(user.getId().toString());
Cookie cookie = new Cookie("token", token);
String cookie = ResponseCookie.from("token", token)
.httpOnly(true)
.secure(true)
.sameSite("None")
.domain(".strcat.me")
.build()
.toString();

log.info("token: " + token);
cookie.setSecure(true);
cookie.setMaxAge(60 * 60);
cookie.setDomain(".strcat.me");


response.addHeader(HttpHeaders.SET_COOKIE, cookie);
response.sendRedirect(String.format("%s?token=%s", REDIRECT_URI, token));
}
}

0 comments on commit 62590c3

Please sign in to comment.