Programming/iOS

[iOS] Apple Login(2) Verifying a User

devssun 2020. 7. 2. 22:22
728x90
반응형

애플 공식 문서

https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api/verifying_a_user

사용자의 identity token 유효성과 무결성 체크

Overview

앱이 사용자 정보를 수신 한 후 서버와 연관된 자격 증명 토큰을 확인하여 토큰이 만료되지 않았는지 확인하고 앱이 변조되거나 재생되지 않았는지 확인할 수 있다.
identity token을 받는 법은 Authenticating Users with Sign in with Apple 공식 문서에서 확인

Verify the Identity Token

  • 서버의 공개 키를 사용해서 JWS E256 서명을 검증한다.
  • 인증을 위한 nonce 를 검증한다.
  • iss 필드가 https://appleid.apple.com 를 포함하는 지 검증한다.
  • aud 필드가 개발자의 client_id 인지 검증한다.
  • 현재 시간이 exp 값보다 빠른지 검증한다.

Obtain a Refresh Token

서버에서 identity token 검증이 완료되면 client_id, client_secret, nonce 정보와 함께 'Generate and Validate token' endpoint를 호출한다.

성공하면 서버는 refresh token을 생성하여 나중에 access token을 얻을 수 있다.
해당 기기에서 사용자의 Apple ID가 여전히 Apple 서버와 양호한 상태인지 확인하기 위해 하루에 한 번 refresh token을 확인할 수 있다.
사용자의 Apple ID를 하루에 두 번 이상 확인하려고하면 Apple 서버 제한할 수 있다.

토큰 검증 단계가 실패하면 앱이 새로운 identity token을 가져오도록 해야한다.

Manage the User Session

identity token 검증이 완료된 후에 앱은 사용자 세션 관리를 담당한다.
추가 설명은 이해가 가지않아 공식 문서 참고.

반응형