Skip to content

feat: Apple 소셜 로그인(네이티브 id_token 검증) 추가#36

Open
jhyoo1203 wants to merge 2 commits into
developfrom
feature/36
Open

feat: Apple 소셜 로그인(네이티브 id_token 검증) 추가#36
jhyoo1203 wants to merge 2 commits into
developfrom
feature/36

Conversation

@jhyoo1203

Copy link
Copy Markdown
Member

작업 내용

  • POST /api/auth/oauth/apple 추가 — iOS Apple 로그인 SDK 가 발급한 identity token 을 검증해 로그인/가입을 처리
    • 기존 회원: access·refresh 토큰 쿠키 발급 (signupRequired=false)
    • 신규 사용자: 가입 세션(signup-token) 쿠키 발급 (signupRequired=true) → 이후 /signup/complete 로 연결
  • AppleIdTokenVerifier — Apple JWKS 로 서명 검증 + iss/aud/exp 클레임 검증 후 sub·email 추출
  • ApplePublicKeyClient — Apple JWKS 조회·캐시 (kid 회전 시 강제 갱신)
  • 쿠키 세팅은 웹 리다이렉트 플로우의 OAuth2AuthenticationSuccessHandler 와 동일하게 미러링
  • ErrorCode.APPLE_TOKEN_INVALID(401) 추가, POST /api/auth/oauth/apple 를 SecurityConfig public 등록

배경

Apple 로그인은 기존 카카오/네이버의 웹 리다이렉트 OAuth2 방식과 맞지 않는다 (userinfo 엔드포인트 없음, client_secret 을 개인키 서명 JWT 로 매번 생성). 모바일 앱에 적합한 네이티브 id_token 검증 방식으로 구현했다.

확인 사항

  • 테스트를 실행했거나, 실행하지 못한 이유를 적었습니다. → AppleIdTokenVerifierTest 7건 통과 (정상 검증 / email 없음 / aud 불일치 / iss 불일치 / 만료 / 위조 서명 / 알 수 없는 kid). RSA 키쌍 생성 → JWKS 를 MockRestServiceServer 로 응답 → 실제 검증하는 방식. compileKotlin/compileTestKotlin 성공
  • 관련 문서를 업데이트했거나, 업데이트가 필요 없음을 확인했습니다. → 갭분석 계획 문서 P0-1 갱신 (docs 는 .gitignore 대상이라 로컬 반영)

참고

Apple 네이티브 로그인의 identity token 을 검증하는 컴포넌트를 추가한다.
ApplePublicKeyClient 가 Apple JWKS 를 조회·캐시(kid 회전 시 강제 갱신)하고,
AppleIdTokenVerifier 가 서명·issuer·audience·만료를 검증해 sub·email 을 추출한다.
검증 실패 시 APPLE_TOKEN_INVALID 로 매핑한다.
POST /api/auth/oauth/apple 로 iOS 가 보낸 identity token 을 검증해
기존 회원이면 access·refresh 토큰 쿠키를, 신규면 가입 세션(signup-token)
쿠키를 발급한다. 쿠키 세팅은 웹 OAuth2 SuccessHandler 와 동일하게 맞췄다.
@jhyoo1203 jhyoo1203 self-assigned this Jun 20, 2026
@jhyoo1203 jhyoo1203 added the feat label Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant