Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 쿠키 value 한글 인코딩 추가 #145

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading