Module: Rack::Firebase

Defined in:
lib/rack/firebase.rb,
lib/rack/firebase/error.rb,
lib/rack/firebase/version.rb,
lib/rack/firebase/middleware.rb,
lib/rack/firebase/test_helpers.rb,
lib/rack/firebase/configuration.rb,
lib/rack/firebase/token_decoder.rb,
lib/rack/firebase/authorization_header.rb

Defined Under Namespace

Modules: TestHelpers Classes: AuthorizationHeader, Configuration, InvalidAuthTimeError, InvalidSubError, Middleware, TokenDecoder

Constant Summary collapse

ALG =
"RS256".freeze
CERTIFICATE_URL =
"https://www.googleapis.com/robot/v1/metadata/x509/[email protected]".freeze
FIREBASE_KEY_LOADER =
lambda do |options|
  if options[:kid_not_found] || (@refresh_cache_by.to_i < Time.now.to_i + 3600)
    @cached_keys = nil
  end

  @cached_keys ||= begin
    response = ::Net::HTTP.get_response(URI(CERTIFICATE_URL))
    cache_control = response["Cache-Control"]

    expires_in = cache_control.match(/max-age=([0-9]+)/).captures.first.to_i
    @refresh_cache_by = Time.now.to_i + expires_in

    json = JSON.parse(response.body)
    json.map do |kid, cert_string|
      key = OpenSSL::X509::Certificate.new(cert_string).public_key
      JWT::JWK::RSA.new(key, kid: kid)
    end
  end
end
VERSION =
"0.3.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



10
11
12
# File 'lib/rack/firebase.rb', line 10

def self.configuration
  @configuration ||= Configuration.new
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



14
15
16
# File 'lib/rack/firebase.rb', line 14

def self.configure
  yield configuration
end