class RooOnRails::Concerns::RequireApiKey::Authenticator

This functionality pulled out into a new class for testability

Public Class Methods

new(whitelisted_clients) click to toggle source
# File lib/roo_on_rails/concerns/require_api_key.rb, line 54
def initialize(whitelisted_clients)
  @whitelisted_clients = whitelisted_clients.map(&:to_s)
end

Public Instance Methods

valid?(service_name, client_key) click to toggle source
# 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

Private Instance Methods

whitelisted?(service_name) click to toggle source
# File lib/roo_on_rails/concerns/require_api_key.rb, line 66
def whitelisted?(service_name)
  return true if @whitelisted_clients.empty?
  @whitelisted_clients.include?(service_name)
end