Class: IAMSSOeOAuth::Configuration

Inherits:
Common::Client::Configuration::REST show all
Defined in:
lib/iam_ssoe_oauth/configuration.rb

Overview

Configuration for the IAMSSOeOAuth::Service. A singleton class that returns a connection that can make signed requests

Examples:

set the configuration in the service

configuration IAMSSOeOAuth::Configuration

Constant Summary collapse

CERT_PATH =
Settings.iam_ssoe.client_cert_path
KEY_PATH =
Settings.iam_ssoe.client_key_path

Instance Attribute Summary

Attributes inherited from Common::Client::Configuration::Base

#base_request_headers, #open_timeout, #read_timeout, #request_types, #user_agent

Instance Method Summary collapse

Methods inherited from Common::Client::Configuration::Base

#breakers_error_threshold, #breakers_exception_handler, #breakers_matcher, #breakers_service, #create_new_breakers_service, #current_module, #request_options, #service_exception

Instance Method Details

#base_pathObject

Override the parent’s base path

Returns:

  • String the service base path from the environment settings



21
22
23
# File 'lib/iam_ssoe_oauth/configuration.rb', line 21

def base_path
  Settings.iam_ssoe.oauth_url
end

#connectionObject

Faraday connection object with breakers, snakecase and json response middleware

Returns:

  • Faraday::Connection connection to make http calls



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/iam_ssoe_oauth/configuration.rb', line 35

def connection
  @connection ||= Faraday.new(
    base_path, headers: base_request_headers, request: request_options, ssl: ssl_options
  ) do |conn|
    conn.use :breakers
    conn.use Faraday::Response::RaiseError
    conn.response :snakecase
    conn.response :json, content_type: /\bjson$/
    conn.adapter Faraday.default_adapter
  end
end

#service_nameObject

Service name for breakers integration

Returns:

  • String the service name



28
29
30
# File 'lib/iam_ssoe_oauth/configuration.rb', line 28

def service_name
  'IAMSSOeOAuth'
end

#ssl_certObject (private)



58
59
60
# File 'lib/iam_ssoe_oauth/configuration.rb', line 58

def ssl_cert
  OpenSSL::X509::Certificate.new(File.read(CERT_PATH))
end

#ssl_keyObject (private)



62
63
64
# File 'lib/iam_ssoe_oauth/configuration.rb', line 62

def ssl_key
  OpenSSL::PKey::RSA.new(File.read(KEY_PATH))
end

#ssl_optionsObject (private)



49
50
51
52
53
54
55
56
# File 'lib/iam_ssoe_oauth/configuration.rb', line 49

def ssl_options
  if ssl_cert && ssl_key
    {
      client_cert: ssl_cert,
      client_key: ssl_key
    }
  end
end