Skip to content

Commit

Permalink
Merge pull request #145 from Yanabada/feature/137
Browse files Browse the repository at this point in the history
refactor: 쿠키 value 한글 인코딩 추가
  • Loading branch information
tjdtn0219 authored Jan 22, 2024
2 parents 2862875 + 92a79e5 commit 8b39885
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import static kr.co.fastcampus.yanabada.domain.member.entity.RoleType.ROLE_USER;

import jakarta.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Random;
import kr.co.fastcampus.yanabada.common.exception.EmailDuplicatedException;
import kr.co.fastcampus.yanabada.common.jwt.dto.TokenIssueResponse;
Expand Down Expand Up @@ -157,16 +159,19 @@ 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(secure)
.path("/")
.sameSite("None")
.domain(domain)
.build(); //todo: domain 서브도메인 맞추기
response.addHeader("Set-Cookie", cookie.toString());
try {
ResponseCookie cookie = ResponseCookie
.from(key, URLEncoder.encode(value, "UTF-8"))
.httpOnly(true)
.secure(secure)
.path("/")
.sameSite("None")
.domain(domain)
.build();
response.addHeader("Set-Cookie", cookie.toString());
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}

@Transactional
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ spring:

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

jwt:
secretKey: yanabadaSecretKeyyanabadaSecretKeyyanabadaSecretKey
Expand Down

0 comments on commit 8b39885

Please sign in to comment.