Skip to content

[URECA-25] Feat: Google - #12

Closed
Zoo2-bi wants to merge 1 commit into
developfrom
URECA-25/Feat/googlelogin
Closed

Zoo2-bi wants to merge 1 commit into
developfrom
URECA-25/Feat/googlelogin

Conversation

@Zoo2-bi

@Zoo2-bi Zoo2-bi commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

Key Changes

GoogleClient 작성 후 OAuthClient 생성

작업 내역

#10

  • close:

💬 공유사항 to 리뷰어

없습니다

비고

Summary by CodeRabbit

릴리스 노트

  • New Features
    • Google OAuth를 통한 사용자 인증 및 프로필 정보 조회 기능 완전 구현
    • 승인 코드를 이용한 접근 토큰 획득 및 사용자 정보 자동 매핑
    • HTTP 기반 OAuth 통신 및 오류 처리 로직 포함
    • 다중 OAuth 제공자(Google, Naver, Kakao) 지원을 위한 클라이언트 인터페이스 기반 구조 도입

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 8, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Google OAuth 인증 흐름을 구현하는 변경입니다. 새로운 OAuthClient 인터페이스를 정의하고, GoogleOAuthClient가 이를 구현하도록 변경했습니다. 구현체는 인증 코드를 받아 RestTemplate을 통해 Google의 토큰 엔드포인트에 요청하여 액세스 토큰을 획득하고, 이를 사용해 사용자 정보를 조회한 후 OAuthUserInfo로 매핑합니다. 설정값(@Value)을 통해 클라이언트 ID, 시크릿, 엔드포인트 URI들을 주입받습니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes


주요 검토 포인트

보안 고려사항:

  • 클라이언트 시크릿이 애플리케이션 설정에 평문으로 노출되지 않는지 확인하세요 (환경 변수 또는 보안 저장소 권장)
  • 토큰 요청 시 HTTPS 통신이 강제되는지, 그리고 인증서 검증이 이루어지는지 확인 필요
  • 사용자 정보 응답의 유효성 검증이 충분한지 검토하세요

구현 안정성:

  • RestTemplate의 에러 응답 처리 로직이 명확한지 확인 (400, 401, 5xx 시나리오별 대응)
  • OAuthUserInfo 매핑 시 필수 필드 누락 여부 검증이 필요한지 검토
  • 토큰 요청 타임아웃, 재시도 정책 설정 여부 확인

설계 확장성:

  • Naver, Kakao 등 추가 OAuth 제공자를 위해 유사한 클래스를 정의할 예정이라면, 공통 로직(토큰 요청, 에러 처리)을 추상 클래스로 추출하는 것을 권고합니다
  • 각 제공자별 응답 형식이 다를 수 있으니, 매핑 로직의 일관성 관리 방안을 미리 준비하세요

테스트 관점:

  • RestTemplate이 목(Mock)화되어 여러 시나리오(성공, 토큰 오류, 네트워크 오류)에 대한 단위 테스트가 있는지 확인하세요
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive PR 제목이 매우 모호하고 구체적인 변경 사항을 설명하지 않습니다. 'URECA-25 Feat: Google'은 무엇을 구현했는지 명확하지 않아 히스토리에서 스캔할 때 의도를 파악하기 어렵습니다. 제목을 구체적으로 개선하세요. 예: 'URECA-25 Feat: Google OAuth 클라이언트 구현' 또는 'URECA-25 Feat: OAuthClient 인터페이스 및 GoogleOAuthClient 구현'
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In
@src/main/java/com/ureca/unity/domain/auth/service/oauth/GoogleOAuthClient.java:
- Around line 14-16: GoogleOAuthClient currently creates a RestTemplate inline
which prevents DI, configuration of timeouts, and easy testing; create a
RestTemplate bean (e.g., RestTemplateConfig with a @Bean method that configures
timeouts via HttpComponentsClientHttpRequestFactory) and change
GoogleOAuthClient to accept a final RestTemplate via constructor injection
(remove any inline new RestTemplate() and let @RequiredArgsConstructor inject
the bean), so tests can mock the RestTemplate and timeouts are applied.
- Around line 63-65: Replace the inappropriate IllegalArgumentException and
unhandled RestClientException usages in GoogleOAuthClient by introducing a
runtime OAuthException and wrapping external API failures: create an
OAuthException class (constructors with message and message+cause), then in
GoogleOAuthClient methods that call restTemplate.exchange (notably
getAccessToken and the method handling user info retrieval) wrap the exchange
calls in try-catch(RestClientException) and throw new OAuthException("Google 토큰
API 호출 실패", e) or similar; also replace the current checks that throw
IllegalArgumentException when response.getBody() or access_token/user info is
missing with throws new OAuthException("Google access token 조회 실패") /
OAuthException("Google 사용자정보 조회 실패") to provide correct semantics and include
the original cause when available.
- Around line 90-95: The GoogleOAuthClient mapping treats email as nullable but
not name; update the builder call in GoogleOAuthClient (where
OAuthUserInfo.builder() uses body.get("email") and body.get("name")) to document
name as nullable the same way as email, and then review/adjust the OAuthUserInfo
DTO (its fields/constructor or builder) to safely handle nulls for both email
and name (either accept nulls or provide a safe default such as empty string) to
avoid NPEs when body.get("email") or body.get("name") returns null.
🧹 Nitpick comments (1)
src/main/java/com/ureca/unity/domain/auth/service/oauth/GoogleOAuthClient.java (1)

56-61: Raw Map 타입 대신 제네릭 타입 또는 DTO를 사용하세요.

ResponseEntity<Map>은 raw type으로 컴파일러 경고가 발생하고 타입 안전성이 떨어집니다.

♻️ 개선 방안

방법 1: ParameterizedTypeReference 사용

-        ResponseEntity<Map> response = restTemplate.exchange(
+        ResponseEntity<Map<String, Object>> response = restTemplate.exchange(
                 tokenUri,
                 HttpMethod.POST,
                 request,
-                Map.class
+                new ParameterizedTypeReference<Map<String, Object>>() {}
         );

방법 2 (권장): 응답 DTO 클래스 정의

@Getter
public class GoogleTokenResponse {
    @JsonProperty("access_token")
    private String accessToken;
    @JsonProperty("token_type")
    private String tokenType;
    // ...
}

DTO를 사용하면 응답 구조가 명확해지고, 필드 누락 시 빠르게 감지할 수 있습니다.

Also applies to: 77-82

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 218f057 and 94982a4.

📒 Files selected for processing (2)
  • src/main/java/com/ureca/unity/domain/auth/service/oauth/GoogleOAuthClient.java
  • src/main/java/com/ureca/unity/domain/auth/service/oauth/OAuthClient.java
🔇 Additional comments (1)
src/main/java/com/ureca/unity/domain/auth/service/oauth/OAuthClient.java (1)

5-14: 깔끔한 인터페이스 설계입니다! 👍

OAuth 제공자별 구현을 추상화한 좋은 설계입니다. 단일 메서드로 책임이 명확하고, 추후 Naver, Kakao 클라이언트 추가 시 일관된 계약을 유지할 수 있습니다.

@Zoo2-bi Zoo2-bi closed this Jan 9, 2026
@Zoo2-bi

Zoo2-bi commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

로그인

@Zoo2-bi Zoo2-bi reopened this Jan 9, 2026
@Zoo2-bi Zoo2-bi closed this Jan 9, 2026
@40food
40food deleted the URECA-25/Feat/googlelogin branch January 12, 2026 07:04
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.

1 participant