Class: AppleIdToken::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/apple_id_token.rb

Constant Summary collapse

APPLE_ISSUER =
'https://appleid.apple.com'
APPLE_JWKS_URI =
'https://appleid.apple.com/auth/keys'
HTTP_OK =
200
JWT_RS256 =
'RS256'

Class Method Summary collapse

Class Method Details

.validate(token:, aud:) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/apple_id_token.rb', line 23

def validate(token:, aud:)
  public_keys = get_public_keys
  if public_keys
    payload = check_against_certs(token, aud, public_keys)

    unless payload
      raise JWTSignatureError, 'Token not verified as issued by Apple'
    end
  else
    raise PublicKeysError, 'Unable to retrieve Apple public keys'
  end

  payload
end