Skip to content

Commit

Permalink
Merge pull request #143 from Yanabada/feature/137
Browse files Browse the repository at this point in the history
refactor: Cookie 설정 domain추가
  • Loading branch information
tjdtn0219 authored Jan 22, 2024
2 parents ce36b19 + fb4981a commit 2862875
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ public void onAuthenticationSuccess(
LoginRequest loginRequest = new LoginRequest(email, oauthPassword);
LoginResponse loginResponse
= authService.loginOauth(response, loginRequest, ProviderType.valueOf(provider));

String loginResponseJson = objectMapper.writeValueAsString(loginResponse);
response.setStatus(OK.value());
response.getWriter().write(loginResponseJson);
} else {
/* 회원 가입 필요 */
//todo: url 변경 예정
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class AuthService {
String oauthPassword;
@Value("${spring.cookie.secure}")
boolean secure;
@Value("${spring.cookie.domain}")
String domain;

private final MemberRepository memberRepository;
private final YanoljaPayRepository yanoljaPayRepository;
Expand Down Expand Up @@ -155,12 +157,14 @@ private void setTokenInCookie(
private void setValueInCookie(
HttpServletResponse response, String key, String value
) {
log.info("domain={}", domain);
ResponseCookie cookie = ResponseCookie
.from(key, value)
.httpOnly(true)
.secure(true)
.secure(secure)
.path("/")
.sameSite("None")
.domain(domain)
.build(); //todo: domain 서브도메인 맞추기
response.addHeader("Set-Cookie", cookie.toString());
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ spring:

cookie:
secure: false
domain: yanabada-fe-1r96.vercel.app

jwt:
secretKey: yanabadaSecretKeyyanabadaSecretKeyyanabadaSecretKey
Expand Down

0 comments on commit 2862875

Please sign in to comment.