Class: RooOnRails::Concerns::RequireApiKey::Authenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/roo_on_rails/concerns/require_api_key.rb

Overview

This functionality pulled out into a new class for testability

Instance Method Summary collapse

Constructor Details

#initialize(whitelisted_clients) ⇒ Authenticator

Returns a new instance of Authenticator.



54
55
56
# File 'lib/roo_on_rails/concerns/require_api_key.rb', line 54

def initialize(whitelisted_clients)
  @whitelisted_clients = whitelisted_clients.map(&:to_s)
end

Instance Method Details

#valid?(service_name, client_key) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
61
62
# File 'lib/roo_on_rails/concerns/require_api_key.rb', line 58

def valid?(service_name, client_key)
  return false unless whitelisted?(service_name)

  ClientApiKeys.instance.valid?(service_name, client_key)
end