-
Notifications
You must be signed in to change notification settings - Fork 0
[Feature] Oauth 유저 조회 방법 수정 #34
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: develop
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @seoahS01, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request modifies the method for retrieving user information during OAuth authentication. Instead of using the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
이 PR은 Google OAuth 사용자를 조회하는 방법을 sub에서 email로 변경하여 심각한 보안 취약점(계정 탈취)을 도입합니다. Google의 sub는 사용자에게 고유하고 변경되지 않는 식별자이므로, 이를 사용하여 사용자를 조회하는 것이 더 안전하고 올바른 방법입니다. 현재 로직은 한 사용자가 Google 계정의 이메일을 다른 기존 사용자의 이메일로 변경할 경우, 잘못된 사용자 계정을 반환할 수 있습니다. 따라서 sub를 통한 사용자 조회 로직을 복원하고, 관련 테스트 코드도 수정해야 합니다.
|
|
||
| private User findOrCreateGoogleUser(GoogleUserInfoResponse userInfo) { | ||
| return userRepository.findByGoogleSub(userInfo.sub()) | ||
| return userRepository.findByEmail(userInfo.email()) |
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.
이 변경은 Google OAuth 사용자를 이메일로 조회하도록 수정합니다. Google의 sub 필드는 사용자에게 고유하고 변경되지 않는 식별자인 반면, 이메일은 변경될 수 있습니다. 만약 한 사용자가 Google 계정의 이메일을 다른 기존 사용자의 이메일로 변경하는 경우, 이 로직은 잘못된 사용자 계정을 반환하여 **계정 탈취(account hijacking)**로 이어질 수 있는 심각한 보안 취약점을 발생시킵니다. Google sub를 사용하여 사용자를 먼저 조회하는 것이 더 안전합니다.
| return userRepository.findByEmail(userInfo.email()) | |
| return userRepository.findByGoogleSub(userInfo.sub()) |
| given(googleOauth.requestAccessToken(code)).willReturn(tokenResponse); | ||
| given(googleOauth.requestUserInfo("google-access-token")).willReturn(userInfo); | ||
| given(userRepository.findByGoogleSub(googleSub)).willReturn(Optional.of(user)); | ||
| given(userRepository.findByEmail("[email protected]")).willReturn(Optional.of(user)); |
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.
이 테스트는 userRepository.findByEmail을 사용하여 기존 사용자를 조회하도록 변경되었습니다. OauthService의 변경 사항이 보안 취약점을 야기하므로, 이 테스트는 Google sub를 사용하여 사용자를 조회하는 이전 로직을 반영하도록 수정되어야 합니다.
| given(userRepository.findByEmail("[email protected]")).willReturn(Optional.of(user)); | |
| given(userRepository.findByGoogleSub(googleSub)).willReturn(Optional.of(user)); |
| given(googleOauth.requestAccessToken(code)).willReturn(tokenResponse); | ||
| given(googleOauth.requestUserInfo("google-access-token")).willReturn(userInfo); | ||
| given(userRepository.findByGoogleSub(googleSub)).willReturn(Optional.empty()); | ||
| given(userRepository.findByEmail("[email protected]")).willReturn(Optional.empty()); |
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.
이 테스트는 userRepository.findByEmail을 사용하여 신규 사용자를 조회하도록 변경되었습니다. OauthService의 변경 사항이 보안 취약점을 야기하므로, 이 테스트는 Google sub를 사용하여 사용자를 조회하는 이전 로직을 반영하도록 수정되어야 합니다.
| given(userRepository.findByEmail("[email protected]")).willReturn(Optional.empty()); | |
| given(userRepository.findByGoogleSub(googleSub)).willReturn(Optional.empty()); |
jiminnimij
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.
고생하셨습니다!!
#️⃣ 연관된 이슈
#33
#️⃣ 작업 내용
#️⃣ 테스트 결과
#️⃣ 변경 사항 체크리스트
#️⃣ 스크린샷 (선택)
#️⃣ 리뷰 요구사항 (선택)
📎 참고 자료 (선택)