Class: TrainPlugins::Rest::Header

Inherits:
AuthHandler show all
Defined in:
lib/train-rest/auth_handler/header.rb

Overview

Authentication via additional Header.

Header name defaults to “X-API-Key”

Instance Attribute Summary

Attributes inherited from AuthHandler

#connection, #options

Instance Method Summary collapse

Methods inherited from AuthHandler

#auth_headers, descendants, #initialize, #login, #logout, name, #process, #process_error, #renew_session, #renewal_needed?, #signature_based?

Constructor Details

This class inherits a constructor from TrainPlugins::Rest::AuthHandler

Instance Method Details

#auth_parametersObject



15
16
17
18
19
20
21
# File 'lib/train-rest/auth_handler/header.rb', line 15

def auth_parameters
  {
    headers: {
      options[:header] => options[:apikey],
    },
  }
end

#check_optionsObject

Raises:

  • (ArgumentError)


9
10
11
12
13
# File 'lib/train-rest/auth_handler/header.rb', line 9

def check_options
  raise ArgumentError.new("Need :apikey for Header-based authentication") unless options[:apikey]

  options[:header] = "X-API-Key" unless options[:header]
end