Skip to content

Conversation

@RoundTable02
Copy link
Collaborator

CHANGELOG

[Unreleased] - Apple Server-to-Server Notification 구현

🎯 변경 의도

Apple에서 2025년 6월 30일부터 Sign in with Apple을 사용하는 앱에서 Server-to-Server Notification 엔드포인트 구현을 필수로 요구함에 따라 (Apple 공지), 사용자 계정 상태 변경 알림을 처리하는 기능을 구현합니다.

✨ 새로운 기능

Apple Server-to-Server Notification API

  • 엔드포인트: POST /webhook/apple/notifications
  • Apple이 전송하는 JWT 형식의 signed_payload를 수신하여 처리
  • application/x-www-form-urlencodedapplication/json 두 가지 Content-Type 지원

이벤트 처리

이벤트 처리 내용
consent-revoked 사용자가 앱 연결 해제 시 소프트 삭제 + 토큰 무효화 + Apple refresh token revoke
account-delete Apple 계정 영구 삭제 시 소프트 삭제 + 토큰 무효화
email-enabled 이메일 포워딩 활성화 시 emailForwardingStatusENABLED로 변경 + 새 이메일 업데이트
email-disabled 이메일 포워딩 비활성화 시 emailForwardingStatusDISABLED로 변경

보안 기능

  • JWKS 서명 검증: Apple의 공개키(https://appleid.apple.com/auth/keys)를 사용하여 JWT 서명 검증
  • JTI 중복 방지: Redis SETNX + TTL(24시간)을 사용한 원자적 중복 처리 방지

📁 새로 생성된 파일

Production 코드

  • adaptor/in/web/controller/AppleNotificationController.java - 웹훅 컨트롤러
  • adaptor/out/oidc/AppleNotificationValidator.java - JWT 검증 및 파싱
  • adaptor/out/redis/AppleNotificationJtiStore.java - Redis JTI 저장소
  • application/port/in/member/AppleNotificationUseCase.java - UseCase 인터페이스
  • application/service/member/AppleNotificationService.java - 비즈니스 로직 서비스
  • domain/value/type/EmailForwardingStatus.java - 이메일 포워딩 상태 Enum

테스트 코드

  • integration_test/AppleNotificationIntegrationTest.java - 컨트롤러 통합 테스트
  • adaptor/out/oidc/AppleNotificationValidatorTest.java - JWT 검증 단위 테스트
  • adaptor/out/redis/AppleNotificationJtiStoreTest.java - Redis 저장소 단위 테스트
  • service/AppleNotificationServiceTest.java - 서비스 단위 테스트
  • config/TestMockConfig.java - 테스트 환경 Mock 설정

🔧 수정된 파일

도메인/엔티티

  • domain/model/member/Member.java
    • emailForwardingStatus 필드 추가
    • updateEmailForwardingStatus() 메서드 추가
    • createMember() 시 기본값 ENABLED 설정
  • adaptor/out/persistence/entity/member/MemberEntity.java
    • emailForwardingStatus 컬럼 추가 (@Builder.Default로 기본값 ENABLED)
  • adaptor/out/persistence/mapper/MemberMapper.java
    • emailForwardingStatus 매핑 추가

Security 설정

  • config/SecurityConfig.java - /webhook/apple/** 경로 permitAll() 추가
  • config/TestSecurityConfig.java - 테스트용 Security 설정에도 동일하게 추가

🗃️ 데이터베이스 마이그레이션

-- member_entity 테이블에 email_forwarding_status 컬럼 추가
ALTER TABLE member_entity 
ADD COLUMN email_forwarding_status VARCHAR(20) DEFAULT 'ENABLED' NOT NULL;

📚 참고 문서

@RoundTable02 RoundTable02 merged commit 93813a8 into release Dec 27, 2025
2 checks passed
@RoundTable02 RoundTable02 deleted the hotfix/apple-notification-endpoint branch January 24, 2026 15:16
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