Conversation
📝 WalkthroughWalkthroughGoogle OAuth 인증 흐름을 구현하는 변경입니다. 새로운 Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 주요 검토 포인트보안 고려사항:
구현 안정성:
설계 확장성:
테스트 관점:
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
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: RawMap타입 대신 제네릭 타입 또는 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
📒 Files selected for processing (2)
src/main/java/com/ureca/unity/domain/auth/service/oauth/GoogleOAuthClient.javasrc/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 클라이언트 추가 시 일관된 계약을 유지할 수 있습니다.
|
로그인 |
Key Changes
GoogleClient 작성 후 OAuthClient 생성
작업 내역
#10
💬 공유사항 to 리뷰어
없습니다
비고
Summary by CodeRabbit
릴리스 노트
✏️ Tip: You can customize this high-level summary in your review settings.