Module: RooOnRails::Concerns::RequireApiKey::ClassMethods
- Defined in:
- lib/roo_on_rails/concerns/require_api_key.rb
Instance Method Summary collapse
-
#require_api_key(only_services: nil, **options) ⇒ Object
Declares that routes on the controller must have access credentials specified in the request that match the approparite environment variables.
Instance Method Details
#require_api_key(only_services: nil, **options) ⇒ Object
Declares that routes on the controller must have access credentials specified in the request that match the approparite environment variables.
41 42 43 44 45 46 47 48 49 |
# File 'lib/roo_on_rails/concerns/require_api_key.rb', line 41 def require_api_key(only_services: nil, **) before_action(**) do authenticate_or_request_with_http_basic('Authenitcation required') do |service_name, client_key| Authenticator.new([*only_services]).valid?(service_name, client_key).tap do |is_valid| @current_client = OpenStruct.new(name: service_name).freeze if is_valid end end end end |