feat: Apple 소셜 로그인(네이티브 id_token 검증) 추가#36
Open
jhyoo1203 wants to merge 2 commits into
Open
Conversation
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 와 동일하게 맞췄다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
작업 내용
POST /api/auth/oauth/apple추가 — iOS Apple 로그인 SDK 가 발급한 identity token 을 검증해 로그인/가입을 처리signupRequired=false)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 검증 방식으로 구현했다.
확인 사항
AppleIdTokenVerifierTest7건 통과 (정상 검증 / email 없음 / aud 불일치 / iss 불일치 / 만료 / 위조 서명 / 알 수 없는 kid). RSA 키쌍 생성 → JWKS 를MockRestServiceServer로 응답 → 실제 검증하는 방식.compileKotlin/compileTestKotlin성공참고
APPLE_CLIENT_ID환경변수 설정 필요 (id_token 의aud와 일치해야 하는 앱 Bundle ID / Services ID)