Class: TrainPlugins::Rest::Basic

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

Overview

Authentication via Basic Authentication.

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



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

def auth_parameters
  {
    headers: {
      "Authorization" => format("Basic %s", Base64.encode64(options[:username] + ":" + options[:password]).chomp),
    },
  }
end

#check_optionsObject

Raises:

  • (ArgumentError)


11
12
13
14
# File 'lib/train-rest/auth_handler/basic.rb', line 11

def check_options
  raise ArgumentError.new("Need :username for Basic authentication") unless options[:username]
  raise ArgumentError.new("Need :password for Basic authentication") unless options[:password]
end