Class: FirebaseAuth::PublicKeys
- Inherits:
-
Object
- Object
- FirebaseAuth::PublicKeys
- Defined in:
- lib/firebase_auth/public_keys.rb
Constant Summary collapse
- URL =
'https://www.googleapis.com/robot/v1/metadata/x509/[email protected]'- EXPIRES_HEADER =
'expires'
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize ⇒ PublicKeys
constructor
A new instance of PublicKeys.
- #look_up(kid) ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ PublicKeys
Returns a new instance of PublicKeys.
10 11 12 |
# File 'lib/firebase_auth/public_keys.rb', line 10 def initialize @response = fetch end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/firebase_auth/public_keys.rb', line 6 def response @response end |
Instance Method Details
#data ⇒ Object
18 19 20 |
# File 'lib/firebase_auth/public_keys.rb', line 18 def data @parsed_body ||= JSON.parse(response.body) end |
#look_up(kid) ⇒ Object
22 23 24 25 |
# 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? ⇒ Boolean
14 15 16 |
# File 'lib/firebase_auth/public_keys.rb', line 14 def valid? Time.now.utc < time_to_expire end |