Class: Firebase::Admin::Auth::CertificatesFetcher
- Inherits:
-
Object
- Object
- Firebase::Admin::Auth::CertificatesFetcher
- Includes:
- Utils
- Defined in:
- lib/firebase/admin/auth/certificates_fetcher.rb
Overview
Fetches public key certificates used for signature verification.
Constant Summary
Constants included from Utils
Utils::AUTH_EMULATOR_HOST_VAR, Utils::HOSTNAME_PATTERN, Utils::INVALID_CHARS_PATTERN, Utils::PATHNAME_PATTERN
Instance Method Summary collapse
-
#fetch_certificates! ⇒ Hash
Fetches certificates.
-
#initialize(url) ⇒ CertificatesFetcher
constructor
Constructs a new certificates fetcher.
Methods included from Utils
get_emulator_host, get_emulator_v1_url, is_emulated?, #to_boolean, #validate_display_name, #validate_email, #validate_password, #validate_phone_number, #validate_photo_url, #validate_uid, validate_url
Constructor Details
#initialize(url) ⇒ CertificatesFetcher
Constructs a new certificates fetcher.
15 16 17 18 19 20 21 22 |
# File 'lib/firebase/admin/auth/certificates_fetcher.rb', line 15 def initialize(url) raise ArgumentError "url is invalid" unless validate_url(url) @url = url @certificates = {} @certificates_expire_at = Time.now @monitor = Monitor.new @client = Firebase::Admin::Internal::HTTPClient.new end |
Instance Method Details
#fetch_certificates! ⇒ Hash
Note:
Certificates are cached in memory and refreshed according to the cache-control header if present in the response.
Fetches certificates.
31 32 33 34 35 36 37 38 |
# File 'lib/firebase/admin/auth/certificates_fetcher.rb', line 31 def fetch_certificates! @monitor.synchronize do return @certificates unless should_refresh? keys, ttl = refresh @certificates_expire_at = Time.now + ttl @certificates = keys end end |