-
Notifications
You must be signed in to change notification settings - Fork 10
[6주차]강태이/[feat]카카오 회원가입 및 로그인 기능 구현 #123
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
base: 강태이/main
Are you sure you want to change the base?
The head ref may contain hidden characters: "\uAC15\uD0DC\uC774/6\uC8FC\uCC28"
Conversation
sxvxnxwt
left a comment
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.
클라이언트로부터 AccessToken을 먼저 받지 말고 인가코드를 먼저 받아 그 코드로 카카오 API와 통신해서 AccessToken을 받도록 로직을 수정하면 401 에러는 해결될 거 같습니다!! 😸
sispo3314
left a comment
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.
수고하셨습니다!! 저와 다르게 구현하신 부분이 많아서 잘 읽었습니당ㅎㅎ
그리고 JwtEntryPoint를 따로 구현하신 것 같은데 이렇게 했을 때 어떤 점이 좋은 지 궁금합니다!!
| // 로그아웃 | ||
| @PostMapping("/logout") | ||
| public ResponseEntity<ApiResponse<Void>> logout(@RequestParam String email) { | ||
| authService.logout(email); | ||
| return ResponseEntity.ok(ApiResponse.onSuccess("Logged out")); | ||
| } | ||
| } |
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.
현재 로그아웃을 할 때 URL 쿼리 파라미터로 이메일을 받고 있는데, 이 코드는 현재 로그인한 사용자가 아닌 파라미터로 넘어온 다른 사용자를 로그아웃 시킬 수 있는 보안상의 위험이 있다고 합니다!! 로그아웃은 현재 인증된 사용자를 기준으로 처리해주시면 좋을 것 같아요 👍🏻👍🏻
| Jwts.parser().setSigningKey(key).build().parseClaimsJws(token); | ||
| return true; | ||
| } catch (JwtException | IllegalArgumentException ex) { | ||
| return false; |
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.
지금 validationToken 메서드에서 예외 발생 시 false만 반환하고 있는데, 어떤 이유로 토큰 검증에 실패했는지 로그에 남기면 디버깅에 도움이 된다고 합니다!
} catch (JwtException | IllegalArgumentException ex) {
log.warn("Invalid JWT token: {}", ex.getMessage());
return false;
}
이런식으로 하는 게 좋다고 하네요 저도 몰랐는데 알아갑니당 👀👀
#122
1. 어떤 이유로 코드를 변경했나요?
-> 카카오 OAuth 2.0 인증을 도입하여 사용자가 별도 회원가입 없이 간편하게 로그인할 수 있도록 개선했습니다.
Authentication을 생성할 수 있도록 개선했습니다.RefreshToken,User)를 추가해, 로그인/재발급 과정에서 토큰이 DB에 안전하게 저장 및 검증되도록 했습니다.2. 어떤 위험이나 장애를 발견했나요?
-> 카카오 API 호출 시 401 Unauthorized가 반복 발생
-> 로그인 성공 시 토큰이 발급되지만 DB에 저장되지 않음
-> 클라이언트에서 전달한 refreshToken이 DB 저장값과 일치하지 않아 서버 에러 발생
3. 스크린 샷