class FirebaseAuth::PublicKeys

Constants

EXPIRES_HEADER
URL

Attributes

response[R]

Public Class Methods

new() click to toggle source
# File lib/firebase_auth/public_keys.rb, line 10
def initialize
  @response = fetch
end

Public Instance Methods

data() click to toggle source
# File lib/firebase_auth/public_keys.rb, line 18
def data
  @parsed_body ||= JSON.parse(response.body)
end
look_up(kid) click to toggle source
# File lib/firebase_auth/public_keys.rb, line 22
def look_up(kid)
  @certificate_hash ||= Hash[data.map { |k, v| [k, OpenSSL::X509::Certificate.new(v)] }]
  @certificate_hash[kid]
end
valid?() click to toggle source
# File lib/firebase_auth/public_keys.rb, line 14
def valid?
  Time.now.utc < time_to_expire
end

Private Instance Methods

fetch() click to toggle source
# File lib/firebase_auth/public_keys.rb, line 35
def fetch
  HTTParty.get(URL)
end
time_to_expire() click to toggle source
# File lib/firebase_auth/public_keys.rb, line 29
def time_to_expire
  @time_to_expire ||= Time.parse(
    response.headers[EXPIRES_HEADER]
  )
end