-
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
feat: Cookie 제거 및 개발용 로그인 개선 #293
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.
소현님이랑 최종적으로 얘기된 정책으로 바뀐 거 같아 좋네요!!
끝나지 않은 로그인 개선 계속 맡아서 하시느라 고생 많으셨어요 ㅎㅎ
궁금한 부분 몇가지만 코멘트 남겨놓아서 답장해주시고 판단하에 merge 해주시면 감사하겠습니다!
src/main/java/com/listywave/auth/application/domain/kakao/KakaoOauthClient.java
Show resolved
Hide resolved
jwtManager.getAccessTokenValidTimeDuration(), | ||
jwtManager.getRefreshTokenValidTimeDuration(), | ||
jwtManager.getAccessTokenValidTimeUnit(), | ||
jwtManager.getRefreshTokenValidTimeUnit() |
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.
이제 응답에 유효기간은 필요 없어졌나보네요!
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.
다시 살펴보니 처음부터 불필요하더라구요? ㅎ
필요에 의해서 포함시켰었는데 불필요해보여서 제거했습니다!
ResponseEntity<LoginResponse> login(@RequestParam("code") String authCode) { | ||
LoginResponse response = authService.login(authCode); | ||
return ResponseEntity.ok().body(response); |
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.
그럼 쿠키에 담아서 안보내고 본문에만 담아서 보내면 프론트단이 편하게 처리할 수 있는 거죠?
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.
넵! 서버 입장에선 로그인이 성공적으로 이뤄지면 액세스, 리프레시 토큰을 만들고 Body에만 담아주면 됩니다.
그리고 클라이언트에서 토큰을 Authorization 헤더에 담아주면 그 값을 읽어서 처리하면 됩니다.
void 로그인에_성공하면_Body와_Authorization헤더에_액세스_토큰과_리프레시_토큰을_담아_응답한다() { | ||
// when | ||
var 로그인_응답 = 로그인을_시도한다(expectedKakaoTokenResponse, expectedKakaoMember); | ||
var 로그인_응답 = 로그인(EXPECTED_KAKAO_TOKEN_RESPONSE, EXPECTED_KAKAO_MEMBER); | ||
var 로그인_결과 = 로그인_응답.as(LoginResponse.class); | ||
|
||
// then | ||
assertAll( | ||
() -> assertThat(로그인_응답.cookie("accessToken")).isNotNull(), | ||
() -> assertThat(로그인_응답.cookie("accessToken")).isNotBlank(), | ||
() -> assertThat(로그인_응답.cookie("refreshToken")).isNotNull(), | ||
() -> assertThat(로그인_응답.cookie("refreshToken")).isNotBlank(), | ||
() -> assertThat(로그인_결과.accessToken()).isNotNull(), | ||
() -> assertThat(로그인_결과.accessToken()).isNotBlank(), | ||
() -> assertThat(로그인_결과.refreshToken()).isNotNull(), | ||
() -> assertThat(로그인_결과.refreshToken()).isNotBlank() | ||
() -> assertThat(로그인_결과.accessToken()).isNotNull().isNotBlank(), | ||
() -> assertThat(로그인_결과.refreshToken()).isNotNull().isNotBlank() |
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.
수정된 로직보면 body에만 엑세스 토큰, 리프레시 토큰 담아서 응답하는 거 같은데 별도에 Authorization 헤더에도 담는 로직이 있는 건가요?
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.
아 실수로 메서드명을 수정하지 않았네요!
감사합니다 🙂
public class DevAccount { | ||
|
||
@Id | ||
@Column(name = "user_id", nullable = false, unique = true) | ||
private Long id; | ||
|
||
@MapsId | ||
@OneToOne(fetch = LAZY) | ||
@JoinColumn(name = "user_id", nullable = false, unique = true) | ||
private User user; | ||
|
||
@Column(nullable = false, unique = true) | ||
private String account; | ||
|
||
@Column(nullable = false) | ||
private String password; | ||
|
||
public void validatePassword(String password) { | ||
if (this.password.equals(password)) { | ||
return; | ||
} | ||
throw new IllegalArgumentException("비밀번호가 틀렸습니다."); | ||
} | ||
|
||
public Long getUserId() { | ||
return user.getId(); | ||
} | ||
} |
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.
오우 개발용 계정을 관리하는 테이블이 추가되는거군요
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.
개발용 DB에만 추가할 예정입니다!
작업 내용
Merge 전 DB 작업 내용
Relation Issues