Auth 세션 인프라와 live 조립 추가 - #12
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughAuth 도메인 계약과 Data 인증 계층을 추가했습니다. 로그인, 세션 저장, 로그아웃, 토큰 갱신, OAuth stub을 구현했습니다. ChangesAuth 도메인 계약
인증 데이터 계층
Live 조립과 App 등록
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 11
🧹 Nitpick comments (3)
Projects/Data/Sources/Auth/Datasource/AuthRemoteDatasource.swift (1)
5-6: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDatasource 프로퍼티에
Auth접두사를 추가하십시오.
plainClient와authedClient는 Auth 도메인 소속을 이름에 표시하지 않습니다.authPlainClient와authAuthedClient처럼 변경하고 모든 참조를 함께 변경하십시오.As per path instructions,
Datasource 프로퍼티는 도메인 prefix 를 붙인다.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Projects/Data/Sources/Auth/Datasource/AuthRemoteDatasource.swift` around lines 5 - 6, Rename the AuthRemoteDatasource properties plainClient and authedClient to authPlainClient and authAuthedClient, respectively, and update every reference within the datasource to use the new domain-prefixed names.Source: Path instructions
Projects/Domain/Sources/Auth/AuthSession.swift (1)
3-3: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value공개 Auth 타입에
///문서를 추가하십시오.공개 API의 목적과 사용 계약을 문서화하지 않았습니다.
Projects/Domain/Sources/Auth/AuthSession.swift#L3-L3:AuthSession의 세션 데이터 계약을 설명하는 type-level///문서를 추가하십시오.Projects/Data/Sources/Auth/DTO/TokenResponseDTO.swift#L4-L4: refresh 응답 DTO의 용도와 세션 적용 의미를 설명하는 type-level///문서를 추가하십시오.Projects/Data/Sources/Auth/Datasource/AuthRemoteDatasource.swift#L4-L4: 원격 Auth 요청의 책임과 client 분리를 설명하는 type-level///문서를 추가하십시오.Projects/Data/Sources/Auth/Service/AuthTokenRefresher.swift#L5-L5: token rotation과 실패 처리 책임을 설명하는 type-level///문서를 추가하십시오.As per path instructions,
공개 타입·포트에는 ///를 적용하십시오.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Projects/Domain/Sources/Auth/AuthSession.swift` at line 3, 공개 Auth 타입과 포트에 type-level /// 문서를 추가하십시오. Projects/Domain/Sources/Auth/AuthSession.swift의 AuthSession에는 세션 데이터 계약을, Projects/Data/Sources/Auth/DTO/TokenResponseDTO.swift의 TokenResponseDTO에는 refresh 응답의 용도와 세션 적용 의미를, Projects/Data/Sources/Auth/Datasource/AuthRemoteDatasource.swift의 AuthRemoteDatasource에는 원격 Auth 요청 책임과 client 분리를, Projects/Data/Sources/Auth/Service/AuthTokenRefresher.swift의 AuthTokenRefresher에는 token rotation 및 실패 처리 책임을 각각 설명하십시오.Source: Path instructions
Projects/Data/Sources/Auth/DTO/LoginResponseDTO.swift (1)
4-4: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win공개 타입에
///문서 주석을 추가하세요.새 공개 타입에 역할과 모듈 경계를 설명하는 한국어
///문서 주석이 없습니다.
Projects/Data/Sources/Auth/DTO/LoginResponseDTO.swift#L4-L4: 로그인 응답 DTO와 Domain 매핑 역할을 설명하세요.Projects/Data/Sources/Auth/Datasource/AuthLocalDatasource.swift#L6-L6: Keychain 기반 세션 저장소 및TokenProviding역할을 설명하세요.Projects/Data/Sources/Auth/Repository/AuthRepositoryImpl.swift#L6-L6: 인증 원격/로컬 datasource 조정 역할을 설명하세요.Projects/Data/Sources/Auth/Client/AuthClientFactory.swift#L4-L4: DomainAuthClient생성 역할을 설명하세요.As per path instructions, "공개 타입·포트에는 ///".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Projects/Data/Sources/Auth/DTO/LoginResponseDTO.swift` at line 4, 각 공개 타입 선언에 한국어 /// 문서 주석을 추가하세요: Projects/Data/Sources/Auth/DTO/LoginResponseDTO.swift 4-4의 LoginResponseDTO에는 로그인 응답 DTO 및 Domain 매핑 역할을, Projects/Data/Sources/Auth/Datasource/AuthLocalDatasource.swift 6-6의 AuthLocalDatasource에는 Keychain 기반 세션 저장소 및 TokenProviding 역할을, Projects/Data/Sources/Auth/Repository/AuthRepositoryImpl.swift 6-6의 AuthRepositoryImpl에는 인증 원격/로컬 datasource 조정 역할을, Projects/Data/Sources/Auth/Client/AuthClientFactory.swift 4-4의 AuthClientFactory에는 Domain AuthClient 생성 역할을 설명하세요.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/ARCHITECTURE.md`:
- Around line 66-67: Update the registration flow diagram around
InfraContainer.live() in ARCHITECTURE.md to match the implementation:
InfraContainer.live() should lead to Dependencies.register, with
AuthClient.live(...) registration represented as occurring inside
Dependencies.register rather than directly before it. Verify the ordering
against Dependencies.register in Dependencies.swift.
In `@Projects/Data/Sources/Auth/Client/AuthClient`+Live.swift:
- Around line 9-46: Enforce HTTPS for every authentication request, not only
through the tokenProvider path. Update the NetworkConfiguration used by the
plain and authenticated DefaultNetworkClient instances to reject non-HTTPS URLs,
and ensure redirect handling does not forward OAuth credentials or refresh
tokens to HTTP or a different origin. Apply this across AuthClient’s
plainClient, authedNetworkClient, and their shared authentication flows.
In `@Projects/Data/Sources/Auth/Client/AuthClientFactory.swift`:
- Around line 13-20: Update the login closure in AuthClientFactory so errors
thrown by credentialProvider(provider) are caught and converted to AuthError
before reaching AuthRepositoryImpl’s mapping; preserve the existing
provider-specific repository login calls and add coverage for the
credential-fetch failure path.
In `@Projects/Data/Sources/Auth/Datasource/AuthRemoteDatasource.swift`:
- Around line 16-38: Update AuthRemoteDatasource methods loginWithKakao,
loginWithApple, and refresh so credential-bearing requests enforce HTTPS,
validate the base URL against the configured allowed host, and reject redirects
to other origins. Apply the same transport protections through the relevant
NetworkConfiguration/DefaultNetworkClient request path, while preserving
existing request bodies and response handling.
In `@Projects/Data/Sources/Auth/Repository/AuthRepositoryImpl.swift`:
- Around line 15-17: Update AuthRepositoryImpl’s restoreSession and logout
methods to wrap local.load and local.clear in do/catch blocks, converting caught
KeychainError values through the existing error mapper into AuthError.storage
before rethrowing. Preserve successful results and add tests covering failures
from both load and clear.
In `@Projects/Data/Sources/Auth/Service/AuthTokenRefresher.swift`:
- Around line 41-44: Update the error handling in AuthTokenRefresher so only
NetworkError.unauthorized clears the local session and maps to .unauthorized.
Handle NetworkError.badRequest separately by preserving the session and
returning the appropriate non-unauthorized error mapping.
- Around line 29-30: Update both unauthorized-handling paths in
AuthTokenRefresher so failures from local.clear are not swallowed by try?.
Propagate an explicit AuthError for the clear failure, or route it through a
persistent retry mechanism, while preserving the unauthorized result when
clearing succeeds. Add coverage for Keychain deletion failure and verify the
invalid refresh token is not silently retained.
- Around line 15-17: Update the session-loading flow around local.load() in
AuthTokenRefresher so datasource failures are handled within a do-catch block.
Catch KeychainError thrown by AuthLocalDatasource.load() and map it to
AuthError.storage, while preserving the unauthorized result when load returns
nil.
In `@Projects/Data/Sources/Auth/Service/OAuth/OAuthServiceFactory.swift`:
- Around line 4-30: Document the public OAuthServices and OAuthServiceFactory
types with triple-slash comments describing their roles, and update makeStub()
documentation to state that its returned services throw AuthError.notConfigured
during login. Remove the PR-status wording from the API documentation and record
future SDK integration separately using a // TODO: comment.
In `@Projects/Data/Tests/Auth/OAuthServiceFactoryTests.swift`:
- Line 6: Rename the test method test_stub_kakao는_notConfigured to follow the
Korean test_<상황>_<기대결과> format, describing the Kakao provider and login
condition in Korean while preserving only the enum case notConfigured as an
identifier.
In `@Projects/Domain/Sources/Auth/AuthClient.swift`:
- Around line 4-10: Document all public Auth contracts with `///` comments: in
Projects/Domain/Sources/Auth/AuthClient.swift lines 4-10, describe each session
operation and its error behavior; in
Projects/Domain/Sources/Auth/AuthError.swift lines 1-9, document the error
categories and `message` purpose; in
Projects/Domain/Sources/Auth/AuthProvider.swift lines 1-4, document supported
providers and case meanings; and in
Projects/Data/Sources/Auth/Service/OAuth/OAuthService.swift lines 4-6, document
returned credential semantics and error conditions.
---
Nitpick comments:
In `@Projects/Data/Sources/Auth/Datasource/AuthRemoteDatasource.swift`:
- Around line 5-6: Rename the AuthRemoteDatasource properties plainClient and
authedClient to authPlainClient and authAuthedClient, respectively, and update
every reference within the datasource to use the new domain-prefixed names.
In `@Projects/Data/Sources/Auth/DTO/LoginResponseDTO.swift`:
- Line 4: 각 공개 타입 선언에 한국어 /// 문서 주석을 추가하세요:
Projects/Data/Sources/Auth/DTO/LoginResponseDTO.swift 4-4의 LoginResponseDTO에는
로그인 응답 DTO 및 Domain 매핑 역할을,
Projects/Data/Sources/Auth/Datasource/AuthLocalDatasource.swift 6-6의
AuthLocalDatasource에는 Keychain 기반 세션 저장소 및 TokenProviding 역할을,
Projects/Data/Sources/Auth/Repository/AuthRepositoryImpl.swift 6-6의
AuthRepositoryImpl에는 인증 원격/로컬 datasource 조정 역할을,
Projects/Data/Sources/Auth/Client/AuthClientFactory.swift 4-4의
AuthClientFactory에는 Domain AuthClient 생성 역할을 설명하세요.
In `@Projects/Domain/Sources/Auth/AuthSession.swift`:
- Line 3: 공개 Auth 타입과 포트에 type-level /// 문서를 추가하십시오.
Projects/Domain/Sources/Auth/AuthSession.swift의 AuthSession에는 세션 데이터 계약을,
Projects/Data/Sources/Auth/DTO/TokenResponseDTO.swift의 TokenResponseDTO에는
refresh 응답의 용도와 세션 적용 의미를,
Projects/Data/Sources/Auth/Datasource/AuthRemoteDatasource.swift의
AuthRemoteDatasource에는 원격 Auth 요청 책임과 client 분리를,
Projects/Data/Sources/Auth/Service/AuthTokenRefresher.swift의
AuthTokenRefresher에는 token rotation 및 실패 처리 책임을 각각 설명하십시오.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: ff80b1cc-0e62-4c82-a790-6e401775a7f1
📒 Files selected for processing (37)
Projects/App/Sources/DI/Dependencies.swiftProjects/App/Sources/DI/InfraContainer.swiftProjects/Data/Project.swiftProjects/Data/README.mdProjects/Data/Sources/Auth/Client/AuthClient+Live.swiftProjects/Data/Sources/Auth/Client/AuthClientFactory.swiftProjects/Data/Sources/Auth/DTO/AppleLoginRequestDTO.swiftProjects/Data/Sources/Auth/DTO/DevLoginRequestDTO.swiftProjects/Data/Sources/Auth/DTO/KakaoLoginRequestDTO.swiftProjects/Data/Sources/Auth/DTO/LoginResponseDTO.swiftProjects/Data/Sources/Auth/DTO/RefreshRequestDTO.swiftProjects/Data/Sources/Auth/DTO/TokenResponseDTO.swiftProjects/Data/Sources/Auth/Datasource/AuthLocalDatasource.swiftProjects/Data/Sources/Auth/Datasource/AuthRemoteDatasource.swiftProjects/Data/Sources/Auth/Endpoint/AuthEndpoint.swiftProjects/Data/Sources/Auth/Repository/AuthRepositoryImpl.swiftProjects/Data/Sources/Auth/Service/AuthTokenRefresher.swiftProjects/Data/Sources/Auth/Service/OAuth/OAuthService.swiftProjects/Data/Sources/Auth/Service/OAuth/OAuthServiceFactory.swiftProjects/Data/Tests/Auth/AuthClientFactoryTests.swiftProjects/Data/Tests/Auth/AuthLocalDatasourceTests.swiftProjects/Data/Tests/Auth/AuthRepositoryImplTests.swiftProjects/Data/Tests/Auth/AuthTokenRefresherTests.swiftProjects/Data/Tests/Auth/LoginResponseDTOMappingTests.swiftProjects/Data/Tests/Auth/OAuthServiceFactoryTests.swiftProjects/Data/Tests/Support/AuthURLProtocolStub.swiftProjects/Data/Tests/Support/InMemoryKeychainStorage.swiftProjects/Domain/Project.swiftProjects/Domain/README.mdProjects/Domain/Sources/Auth/AuthClient.swiftProjects/Domain/Sources/Auth/AuthError.swiftProjects/Domain/Sources/Auth/AuthProvider.swiftProjects/Domain/Sources/Auth/AuthSession.swiftProjects/Domain/Sources/Placeholder.swiftProjects/Domain/Tests/Auth/AuthSessionTests.swiftdocs/ARCHITECTURE.mddocs/CONVENTIONS.md
💤 Files with no reviewable changes (1)
- Projects/Domain/Sources/Placeholder.swift
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Projects/Data/Tests/Support/FailingKeychainStorage.swift`:
- Around line 5-11: Update the Operation enum in FailingKeychainStorage to
conform to Hashable so it can be used as the element type of failingOperations:
Set<Operation>, while preserving its existing Sendable conformance and cases.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 4d7b77e3-d4d7-4e73-8e3f-16493099b76b
📒 Files selected for processing (9)
Projects/Data/README.mdProjects/Data/Sources/Auth/Repository/AuthRepositoryImpl.swiftProjects/Data/Sources/Auth/Service/AuthTokenRefresher.swiftProjects/Data/Tests/Auth/AuthClientFactoryTests.swiftProjects/Data/Tests/Auth/AuthRepositoryImplTests.swiftProjects/Data/Tests/Auth/AuthTokenRefresherTests.swiftProjects/Data/Tests/Auth/OAuthServiceFactoryTests.swiftProjects/Data/Tests/Support/FailingKeychainStorage.swiftdocs/ARCHITECTURE.md
🚧 Files skipped from review as they are similar to previous changes (6)
- Projects/Data/Tests/Auth/OAuthServiceFactoryTests.swift
- Projects/Data/Tests/Auth/AuthClientFactoryTests.swift
- Projects/Data/Sources/Auth/Repository/AuthRepositoryImpl.swift
- docs/ARCHITECTURE.md
- Projects/Data/Sources/Auth/Service/AuthTokenRefresher.swift
- Projects/Data/README.md
📌 변경 요약
AuthClient/AuthSession) 추가📌 변경 내용
Domain
AuthSession,AuthError,AuthProvider,AuthClient포트 추가@DependencyClient기반authClientdependency 정의Data
AuthLocalDatasource,AuthTokenRefresher, OAuth stub 추가AuthClientFactory+AuthClient.live조립 경로 추가struct로 구성App
InfraContainer를 설정/로컬 저장소 중심으로 유지Dependencies에서AuthClient.live등록Docs