class AppleAuth::UserIdentity
Constants
- APPLE_KEY_URL
Attributes
jwt[R]
user_identity[R]
Public Class Methods
new(user_identity, jwt)
click to toggle source
# File lib/apple_auth/user_identity.rb, line 9 def initialize(user_identity, jwt) @user_identity = user_identity @jwt = jwt end
Public Instance Methods
validate!()
click to toggle source
# File lib/apple_auth/user_identity.rb, line 14 def validate! token_data = decoded_jwt JWTConditions.new(user_identity, token_data).validate! token_data.symbolize_keys end
Private Instance Methods
apple_key_hash()
click to toggle source
# File lib/apple_auth/user_identity.rb, line 30 def apple_key_hash response = Net::HTTP.get(URI.parse(APPLE_KEY_URL)) certificate = JSON.parse(response) matching_key = certificate['keys'].select { |key| key['kid'] == jwt_kid } ActiveSupport::HashWithIndifferentAccess.new(matching_key.first) end
decoded_jwt()
click to toggle source
# File lib/apple_auth/user_identity.rb, line 24 def decoded_jwt key_hash = apple_key_hash apple_jwk = JWT::JWK.import(key_hash) JWT.decode(jwt, apple_jwk.public_key, true, algorithm: key_hash['alg']).first end
jwt_kid()
click to toggle source
# File lib/apple_auth/user_identity.rb, line 37 def jwt_kid header = JSON.parse(Base64.decode64(jwt.split('.').first)) header['kid'] end