Skip to content

Conversation

@seoahS01
Copy link
Contributor

#️⃣ 연관된 이슈

관련된 이슈 번호를 적어주세요. 예: #이슈번호

#33

#️⃣ 작업 내용

이번 PR에서 작업한 내용을 간략히 설명해주세요. (이미지 첨부 가능)

  • 유저 조회 시 기존 sub()로 조회 -> email() 조회로 방법 수정

#️⃣ 테스트 결과

코드 변경에 대해 테스트를 수행한 결과를 요약해주세요. 예: 모든 테스트 통과 여부, 새로 작성한 테스트 케이스 등

스크린샷 2026-01-27 오후 6 44 07

#️⃣ 변경 사항 체크리스트

  • 코드에 영향이 있는 모든 부분에 대한 테스트를 작성하고 실행했나요?
  • 문서를 작성하거나 수정했나요? (필요한 경우)
  • 코드 컨벤션에 따라 코드를 작성했나요?
  • 본 PR에서 발생할 수 있는 모든 의존성 문제가 해결되었나요?

#️⃣ 스크린샷 (선택)

관련된 스크린샷이 있다면 여기에 첨부해주세요.

#️⃣ 리뷰 요구사항 (선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요.
예시: 이 부분의 코드가 잘 작동하는지 테스트해 주실 수 있나요?

📎 참고 자료 (선택)

관련 문서, 스크린샷, 또는 예시 등이 있다면 여기에 첨부해주세요

@seoahS01 seoahS01 linked an issue Jan 27, 2026 that may be closed by this pull request
6 tasks
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 sub (subject) field, the system now uses the user's email address to find or create user accounts. This change is reflected in the service logic, repository interface, and associated tests.

Highlights

  • User Lookup Method: The primary change involves modifying the user lookup method from using sub() to using email() when querying user information.
  • Repository Update: The findByGoogleSub method has been removed from the UserRepository interface.
  • Test Adjustment: The test cases in OauthServiceTest.java have been updated to reflect the change in user lookup, now using findByEmail instead of findByGoogleSub.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-critical critical

이 변경은 Google OAuth 사용자를 이메일로 조회하도록 수정합니다. Google의 sub 필드는 사용자에게 고유하고 변경되지 않는 식별자인 반면, 이메일은 변경될 수 있습니다. 만약 한 사용자가 Google 계정의 이메일을 다른 기존 사용자의 이메일로 변경하는 경우, 이 로직은 잘못된 사용자 계정을 반환하여 **계정 탈취(account hijacking)**로 이어질 수 있는 심각한 보안 취약점을 발생시킵니다. Google sub를 사용하여 사용자를 먼저 조회하는 것이 더 안전합니다.

Suggested change
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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-critical critical

이 테스트는 userRepository.findByEmail을 사용하여 기존 사용자를 조회하도록 변경되었습니다. OauthService의 변경 사항이 보안 취약점을 야기하므로, 이 테스트는 Google sub를 사용하여 사용자를 조회하는 이전 로직을 반영하도록 수정되어야 합니다.

Suggested change
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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-critical critical

이 테스트는 userRepository.findByEmail을 사용하여 신규 사용자를 조회하도록 변경되었습니다. OauthService의 변경 사항이 보안 취약점을 야기하므로, 이 테스트는 Google sub를 사용하여 사용자를 조회하는 이전 로직을 반영하도록 수정되어야 합니다.

Suggested change
given(userRepository.findByEmail("[email protected]")).willReturn(Optional.empty());
given(userRepository.findByGoogleSub(googleSub)).willReturn(Optional.empty());

Copy link
Contributor

@jiminnimij jiminnimij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] 구글 로그인 유저 조회 과정 수정

3 participants