-
Notifications
You must be signed in to change notification settings - Fork 2
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: token과 유저 정보를 쿠키에 담아 반환하도록 수정 #64
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
인증이 헤더 토큰에서 쿠키로 바뀌었군요 고생하셨습니다
Cookie cookie = new Cookie(JWT_COOKIE_NAME, jwtToken); | ||
cookie.setPath("/"); | ||
cookie.setMaxAge((int) EXPIRED_TIME); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://coyagi.tistory.com/entry/%EC%8B%9C%ED%81%90%EC%96%B4%EC%BD%94%EB%94%A9-%EC%BF%A0%ED%82%A4-%EB%B0%8F-%EC%84%B8%EC%85%98%EA%B4%80%EB%A6%AC
쿠키 보안관련 cookie.setHttpOnly(true); 등이 필요할까요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 한번도 써본 적 없는데 jwt 쿠키에는 설정해도 좋겠다는 생각이 드네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
쿠키!
String token = jwtUtil.createToken(requestDTO.getUsername()); | ||
response.setHeader(JwtUtil.AUTHORIZATION_HEADER, token); | ||
Cookie tokenCookie = jwtUtil.createTokenCookie(requestDTO.getUsername()); | ||
Cookie userInfoCookie = jwtUtil.createUserInfoCookie(userInfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tokenCookie.setPath("/~~");
같이 쿠키의 경로를 지정해주는 건 어떨까요?
Cookie userInfoCookie = jwtUtil.createUserInfoCookie(userInfo); userInfoCookie.setPath("/api");
이런 느낌?
누출도 최소화해주고 범위도 제한해주기 때문에 보안적인 측면에서 이렇게하는게 좀 더 나을 것 같은데, 어떻게 생각하시나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋은 의견이라고 생각합니다!
@@ -30,7 +35,14 @@ public class JwtUtil { | |||
public static final String AUTHORIZATION_HEADER = "Authorization"; | |||
|
|||
// Token 식별자 | |||
public static final String BEARER_PREFIX = "Bearer "; | |||
public static final String BEARER_PREFIX = "Bearer%"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 이 때 까지 "Bearer "을 사용했는데, 왜 상수를 Bearer%로 설정하셨는지 알 수 있을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
쿠키 값에는 몇가지 특수문자가 들어갈 수 없는데 그 중 하나가 공백이더라구요.
Bearer을 안 넣어주는 방법, 공백을 인코딩해서 %20으로 바꾸는 방법 등등이 있었는데 substring 7 을 최대한 바꾸고 싶지 않아 저렇게 수정했습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
뭐야 왜 승인이 아니지
No description provided.