-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -85,7 +85,7 @@ void googleLogin_success_existingUser() { | |||||
|
|
||||||
| 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("google@test.com")).willReturn(Optional.of(user)); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 테스트는
Suggested change
|
||||||
|
|
||||||
| given(authService.issueTokens(userId)).willReturn( | ||||||
| Map.of( | ||||||
|
|
@@ -123,15 +123,15 @@ void googleLogin_success_newUser() { | |||||
|
|
||||||
| GoogleUserInfoResponse userInfo = new GoogleUserInfoResponse( | ||||||
| googleSub, | ||||||
| "new@test.com", | ||||||
| "google@test.com", | ||||||
| "newUser", | ||||||
| null, | ||||||
| true | ||||||
| ); | ||||||
|
|
||||||
| given(googleOauth.requestAccessToken(code)).willReturn(tokenResponse); | ||||||
| given(googleOauth.requestUserInfo("google-access-token")).willReturn(userInfo); | ||||||
| given(userRepository.findByGoogleSub(googleSub)).willReturn(Optional.empty()); | ||||||
| given(userRepository.findByEmail("google@test.com")).willReturn(Optional.empty()); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 테스트는
Suggested change
|
||||||
| given(passwordEncoder.encode(anyString())).willReturn("encoded-password"); | ||||||
|
|
||||||
| given(userRepository.save(any(User.class))) | ||||||
|
|
||||||
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)**로 이어질 수 있는 심각한 보안 취약점을 발생시킵니다. Googlesub를 사용하여 사용자를 먼저 조회하는 것이 더 안전합니다.