Skip to content

Feature/#12 - SwiftData 기반 Secret CRUD 및 보안 계층 구성#16

Open
dlguszoo wants to merge 61 commits into
developfrom
feature/#12/Secret_ORM
Open

Feature/#12 - SwiftData 기반 Secret CRUD 및 보안 계층 구성#16
dlguszoo wants to merge 61 commits into
developfrom
feature/#12/Secret_ORM

Conversation

@dlguszoo
Copy link
Copy Markdown
Contributor

@dlguszoo dlguszoo commented May 23, 2026

✨ What’s this PR?

📌 관련 이슈 (Related Issue)


📁새로 생긴 폴더링과 파일

Domain

Projects/DVDomain/Sources
├── Entity
│   ├── Secret.swift
│   ├── SecretMetadata.swift
│   └── SecretPayload.swift
├── Repository
│   ├── Error
│   │   └── SecretRepositoryError.swift
│   ├── Interface
│   │   └── SecretRepository.swift
│   ├── SecretPatch.swift
│   └── SecretQuery.swift
├── SecretContent
│   ├── Metadata
│   │   ├── Interface
│   │   │   └── SecretMetadataContent.swift
│   │   ├── APIKeyMetadata.swift
│   │   ├── DatabaseMetadata.swift
│   │   ├── LicenseKeyMetadata.swift
│   │   ├── OAuthClientMetadata.swift
│   │   ├── SSHKeyMetadata.swift
│   │   ├── SSLCertMetadata.swift
│   │   └── ServiceAccountMetadata.swift
│   └── Payload
│       ├── Interface
│       │   └── SecretPayloadData.swift
│       ├── APIKeyPayload.swift
│       ├── CustomPayload.swift
│       ├── DatabasePayload.swift
│       ├── EnvSetPayload.swift
│       ├── LicenseKeyPayload.swift
│       ├── OAuthClientPayload.swift
│       ├── SSHKeyPayload.swift
│       ├── SSLCertPayload.swift
│       └── ServiceAccountPayload.swift
├── Service
│   ├── Error
│   │   ├── SecretCryptoError.swift
│   │   └── UserAuthenticationError.swift
│   └── Interface
│       ├── SecretCryptoService.swift
│       └── UserAuthenticationService.swift
└── UseCase
   ├── Draft
   │   └── SecretDraft.swift
   ├── Error
   │   └── SecretUseCaseError.swift
   ├── Impl
   │   └── Secret
   │       ├── CreateSecretUseCaseImpl.swift
   │       ├── DeleteSecretUseCaseImpl.swift
   │       ├── FetchSecretUseCaseImpl.swift
   │       ├── PatchSecretUseCaseImpl.swift
   │       └── SecretUseCaseHelper.swift
   └── Interface
       └── Secret
           ├── CreateSecretUseCase.swift
           ├── DeleteSecretUseCase.swift
           ├── FetchSecretUseCase.swift
           └── PatchSecretUseCase.swift

Data

Projects/DVData/Sources
├── RepositoryImpl
│   └── Secret
│       ├── InMemorySecretQueryFilter.swift
│       ├── SecretFetchDescriptorBuilder.swift
│       └── SecretRepositoryImpl.swift
├── ServiceImpl
│   ├── Authentication
│   │   └── LocalUserAuthenticationServiceImpl.swift
│   └── Security
│       ├── SecretCryptoServiceImpl.swift
│       ├── JSONCoder
│       │   ├── SecretMetadataJSONCoder.swift
│       │   └── SecretPayloadJSONCoder.swift
│       └── Keychain
│           └── KeychainKeyStore.swift
└── Storage
   └── Local
       ├── LocalStorage.swift
       └── Models

Presentation

Projects/DVPresentation/Sources
└── SecretUseCaseDemoView.swift

App

Projects/Devault/Sources
└── ContentView.swift

🧶 주요 변경 내용 (Summary)

Task 1. Tuist 모듈 의존성 정리

  • Presentation -> Domain/Core
  • Domain -> Core
  • Data -> Domain/Core
  • Design -> Core
  • Core -> 의존 없음
  • Clean Architecture + TCA 기준으로 모듈 책임을 정리

Task 2. Secret Domain Entity 정의

  • Secret, SecretPayload, SecretMetadata Domain Entity 추가
  • payload는 필수, metadata는 optional 구조로 정리
  • SwiftData 모델과 Domain 모델의 역할 분리

Task 3. Repository Interface 정의

  • SecretRepository 프로토콜 추가
  • SecretQuery, SecretPatch, SecretRepositoryError 정의
  • Repository는 순수 CRUD 중심, 비즈니스 정책은 UseCase로 분리

Task 4. Secret Content 모델 정의

  • payload/metadata content protocol 추가
  • API Key, OAuth, Service Account, Database, SSH, SSL Cert, Env Set, License, Custom payload 구조 정의
  • schemaVersion 기반으로 payload/metadata 구조 변경 대응 가능하도록 설계

Task 5. Secret UseCase 구성

  • Create / Fetch / Patch / Delete UseCase 분리
  • SecretDraft 도입
  • reveal, restore, soft delete, permanent delete 등 작업 단위 정리
  • UseCase error와 Repository error 분리

Task 6. SwiftData RepositoryImpl 구현

  • SecretRepositoryImpl을 @Modelactor 기반 actor로 구현
  • SwiftData model과 Domain entity mapping 처리
  • SecretFetchDescriptorBuilder로 DB fetch 조건 구성
  • InMemorySecretQueryFilter로 searchText 후처리

Task 7. 암호화/Keychain/JSON 처리 구현

  • SecretCryptoService Domain interface 추가
  • SecretCryptoServiceImpl Data 구현체 추가
  • AES-GCM 기반 payload 암복호화
  • metadata JSON encode/decode 처리
  • Keychain 기반 master key 저장/조회 처리

Task 8. 사용자 인증 책임 분리

  • UserAuthenticationService Domain interface 추가
  • LocalUserAuthenticationServiceImpl Data 구현체 추가
  • KeychainKeyStore는 key 저장/조회만 담당하도록 정리
  • reveal 전 LocalAuthentication 인증을 UseCase에서 수행
  • SecretCryptoError와 UserAuthenticationError 분리

Task 9. 임시 Demo View 추가

  • Presentation에 Secret 생성/조회/reveal 확인용 임시 View 추가
  • App composition root에서 Repository/Crypto/Auth 구현체 주입
  • 실제 앱 실행으로 create / refresh / reveal 흐름 확인 가능

📸 스크린샷 (Optional)

2026-05-23.11.38.10.mov

🧪 테스트 / 검증 내역

  • tuist generate 성공
  • 앱 실행 후 Demo View에서 Secret 생성 / 조회 / payload reveal 흐름 수동 확인

💬 기타 공유 사항

  • Entity 네이밍 고민 -> SecretEntity와 같은 접미사를 붙일 수도 있음.

  • UseCase 단위 고민 -> 지금 구현한 방식은 “사용자 의도 하나의 작업 단위”로 보는 관점으로.

  • 앞으로 localAuth를 쓰는 곳은 많지만 정해져 있을 테니, authenticate의 reason 파라미터를 String이 아닌 AuthenticationPurpose enum으로 정의해서 받아야 할 것

  • Metadata, payload의 각 content들은 notion DB설계 페이지에서 미리 정의하고 구현한 내용입니다.

  • Service 관련

    • 현재는 UseCase에서 LocalAuthentication을 먼저 수행한 뒤 Keychain key를 조회하는 구조
    • kSecAttrAccessibleWhenUnlockedThisDeviceOnly는 LocalAuth와 별개로 “현재 기기 + 잠금 해제 상태”에서만 key 접근 가능하게 하는 Keychain 접근성 옵션

🙇🏻‍♀️ 리뷰 가이드 (선택)

  • secret CRUD라 repository(기본crud) / usecase(crud 활용한 softDelete, reveal 등) / 보안계층 까지 얽혀있는 것들이 많아 task와 코드 줄/파일 수가 많아졌습니다.. 적당히 이슈 분배하지 못한 점 죄송하고 양해 부탁드립니다.🥲

Summary by CodeRabbit

  • New Features
    • 비밀(시크릿) 저장·관리: 생성, 조회, 수정, 삭제 전반 지원
    • 민감 데이터 암호화 및 안전한 키 관리(키체인 활용)
    • 로컬 사용자 인증(기기 인증)으로 페이로드 노출 보호
    • 검색/필터링(키워드, 타입, 서비스, 환경 등) 개선
    • 메타데이터·다양한 페이로드 타입(예: API 키, DB 자격증명, SSH 등) 지원
    • 데모 UI 추가: 시크릿 생성/조회 및 페이로드 공개 흐름 체험 가능

Review Change Stack

dlguszoo added 29 commits May 23, 2026 15:34
@dlguszoo dlguszoo linked an issue May 23, 2026 that may be closed by this pull request
9 tasks
dlguszoo added 28 commits May 24, 2026 23:43
@doyeonk429 doyeonk429 force-pushed the feature/#12/Secret_ORM branch from 9ab75e8 to 9faeab4 Compare May 24, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 새로운 기능 개발

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: SwiftData Secret 모델 CRUD 메서드 구현

2 participants