Skip to content

fix: 애플(iCloud) 캘린더 연동을 JWT+쿠키 방식으로 재정렬 (#54) - #55

Merged
kokkumong merged 1 commit into
devfrom
fix/54-icloud-calendar-cookie-auth
Jun 10, 2026
Merged

fix: 애플(iCloud) 캘린더 연동을 JWT+쿠키 방식으로 재정렬 (#54)#55
kokkumong merged 1 commit into
devfrom
fix/54-icloud-calendar-cookie-auth

Conversation

@kokkumong

@kokkumong kokkumong commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

🚀 작업 내용 (What)

  • 애플(iCloud) 캘린더 연동을 구글/네이버와 동일한 HttpOnly 쿠키 저장 방식으로 재정렬
  • src/lib/caldav/connection-cookie.ts 신설: 앱 전용 암호를 AES-256-GCM 암호화 후 쿠키 저장/조회/삭제
  • icloud 라우트 5개(connect/calendars/events·query/create/disconnect)에서 requireSession+Supabase 제거 → 쿠키 기반 전환
  • events 라우트 계약 calendarId(UUID) → calendarUrl (호출부 없어 안전)
  • calendar/status를 쿠키 조회로 전환 (구글 분기도 빈 테이블 조회로 깨져 있어 함께 수정)
  • .env.exampleENCRYPTION_SECRET 추가

📣 핵심 변경 이유 (Why)

⚠️ 배포 주의

  • 운영/Preview 환경에 ENCRYPTION_SECRET(64 hex) 환경변수 등록 필수. 없으면 연동 시 서버 오류 발생.
  • 검증 근거: 단위 테스트 57개 통과, 변경 파일 lint clean, E2E는 API 모킹이라 무영향.

⚠️ 체크리스트 (Checklist)

  • 브랜치 컨벤션(feature/00-name)을 지켰나요?
  • 커밋 컨벤션(feat:, fix: 등)을 지켰나요?
  • 작업 전에 관련 이슈를 생성하고 연결했나요?
  • 내 코드가 팀의 기존 코드를 망가뜨리지 않았는지 확인했나요?

🔗 관련 이슈 (Issue)

Close #54

🤖 Generated with Claude Code

애플 연동만 앱이 채택하지 않은 Supabase Auth 중심 설계 위에 구현되어
일반 로그인(커스텀 JWT) 유저는 connect에서 401, profiles FK 미충족으로
저장 실패했다. 구글/네이버와 동일하게 HttpOnly 쿠키 저장으로 전환한다.

- src/lib/caldav/connection-cookie.ts 신설: 앱 전용 암호를 AES-256-GCM으로
  암호화해 icloud_connection 쿠키에 저장/조회/삭제
- icloud 라우트 5개(connect/calendars/events·query/create/disconnect)에서
  requireSession+Supabase 제거, 쿠키 기반으로 전환
- events 라우트 계약 calendarId(UUID) → calendarUrl로 변경
- calendar/status: Supabase/세션 게이트 제거, 쿠키 존재로 판단
  (구글 분기도 빈 테이블 조회로 깨져 있어 함께 수정)
- .env.example에 ENCRYPTION_SECRET 추가 (배포에 필수)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
moim-app Ready Ready Preview, Comment Jun 10, 2026 8:32am

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

Summary by CodeRabbit

릴리스 노트

  • New Features

    • iCloud 캘린더 연결 정보에 암호화 기능 추가
  • Improvements

    • iCloud 캘린더를 실시간으로 동기화하도록 개선
    • 세션 인증 방식을 더 안전한 방식으로 업그레이드
  • Security

    • 환경 변수에 AES-256-GCM 암호화 키 설정 추가

Walkthrough

Supabase 세션 의존을 제거하고 HttpOnly 쿠키 기반 저장으로 iCloud 캘린더 연동 전체를 재정렬. connection-cookie 모듈로 암호화된 인증정보 관리, 모든 API의 입력을 calendarUrl(https) 기반으로 변경, 상태/캘린더/이벤트 조회/생성 라우트 통합.

Changes

iCloud CalDAV 쿠키 기반 저장 전환

Layer / File(s) Summary
쿠키 저장 계층 및 타입 정의
src/lib/caldav/connection-cookie.ts, src/types/icloud.ts
ICloudConnection(공개), ICloudConnectionAuth(서버 전용) 타입을 분리 정의. saveConnection()으로 앱 암호 AES-256-GCM 암호화 후 httpOnly 쿠키(30일 유효, sameSite: "lax")에 저장. getConnection(), getConnectionAuth()로 조회/복호화. clearConnection()으로 삭제. DB row 타입(ICloudConnectionRow, ICloudCalendarRow) 제거.
연결 생명주기 (connect/disconnect)
src/app/api/icloud/connect/route.ts, src/app/api/icloud/disconnect/route.ts
/api/icloud/connect: 입력 검증(zod) → CalDAV discovery → saveConnection()으로 쿠키 저장(성공 응답은 appleId 중심). Supabase 세션 인증, 암호화, DB upsert 로직 전부 제거. /api/icloud/disconnect: clearConnection() 호출로 쿠키 삭제, 세션 인증 제거로 단순화.
연결 상태 조회 (status/calendars)
src/app/api/calendar/status/route.ts, src/app/api/icloud/calendars/route.ts
/api/calendar/status: 쿠키 존재 여부(google_tokens 쿠키, getConnection())로 연동 상태 판단. 세션 강제/Supabase 조회 제거, googleEmail 항상 undefined. /api/icloud/calendars: GET 파라미터 제거(무인증), getConnectionAuth() 호출로 쿠키 복호화 후 CalDAV 실시간 discovery. DB 캐시 반환(cached: true/false) 제거, 응답은 calendars 배열만(calendarUrl/displayName/color).
이벤트 조회/생성 (query/create)
src/app/api/icloud/events/query/route.ts, src/app/api/icloud/events/create/route.ts
입력 계약 변경: calendarId(UUID) → calendarUrl(https URL). 둘 다 getConnectionAuth()로 쿠키 복호화, 연결 없으면 404 반환. query: CalDAV REPORT 후 ICS 파싱 (uid/title/startAt/endAt/location/description/isAllDay/etag). create: buildIcs → CalDAV PUT (uid/eventUrl/etag 201 반환). 세션 인증, Supabase 소유권 검증 제거. 오류 로깅시 appleId를 maskEmail로 마스킹.
환경 설정
.env.example
AES-256-GCM 암호화용 ENCRYPTION_SECRET(64자리 hex) 추가. 생성 명령어(openssl rand -hex 32) 주석.

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Estimated code review effort: Coherent one-pattern migration (session auth removal + cookie substitution) across 6 files, with repetitive structural edits (import reorg, getConnectionAuth() call insertion, calendarUrl substitution, maskEmail logging). High individual route complexity offset by consistent refactoring pattern and no cross-file type ripples (DB row types removed cleanly). New connection-cookie module (116 LoC) introduces crypto/cookie handling—medium density but straightforward encryption/decryption logic. Moderate heterogeneity due to different CalDAV operations (discover, REPORT, PUT), but unified input contract change and consistent error handling. No new tests/docs observed.

bug, feature

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 제목이 'fix:' 접두사로 시작하며, 주요 변경사항(iCloud 캘린더 쿠키 방식 재정렬)을 명확히 설명한다.
Description check ✅ Passed 설명이 작업 내용, 핵심 변경 이유, 배포 주의, 관련 이슈 등 변경사항과 밀접한 세부정보를 포함한다.
Linked Issues check ✅ Passed 모든 변경사항이 #54의 요구사항(쿠키 기반 저장, requireSession 제거, connection-cookie.ts 신설, 5개 라우트 전환, calendarUrl 계약 변경, 상태 조회 전환)을 완전히 충족한다.
Out of Scope Changes check ✅ Passed 모든 변경이 #54 범위 내: 쿠키 저장 구현, Supabase 의존 제거, 라우트 재정렬, 계약 변경이며 무관한 수정은 없다.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/54-icloud-calendar-cookie-auth

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@kokkumong
kokkumong merged commit b96f121 into dev Jun 10, 2026
4 of 6 checks passed
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