Project

General

Profile

Revision db2196de

Added by Christine Fouant about 7 years ago

Fixes #13187 - Adds certification authentication to runcible

View differences:

lib/runcible/base.rb
43 43
      client_options[:verify_ssl] =  clone_config[:verify_ssl] unless clone_config[:verify_ssl].nil?
44 44

  
45 45
      if clone_config[:oauth]
46
        headers = add_oauth_header(method, path, headers) if clone_config[:oauth]
46
        headers = add_oauth_header(method, path, headers)
47 47
        headers['pulp-user'] = clone_config[:user]
48
        client = RestClient::Resource.new(clone_config[:url], client_options)
48
      elsif clone_config[:cert_auth]
49
        if !clone_config[:cert_auth][:ssl_client_cert] || !clone_config[:cert_auth][:ssl_client_key]
50
          fail Runcible::ConfigurationUndefinedError, "Missing SSL certificate or key configuration."
51
        end
52
        client_options[:ssl_client_cert] = clone_config[:cert_auth][:ssl_client_cert]
53
        client_options[:ssl_client_key] = clone_config[:cert_auth][:ssl_client_key]
49 54
      else
50 55
        client_options[:user] =  clone_config[:user]
51 56
        client_options[:password] = config[:http_auth][:password]
52
        client = RestClient::Resource.new(clone_config[:url], client_options)
53 57
      end
54 58

  
59
      client_options[:ca_file] = config[:ca_cert_file] unless config[:ca_cert_file].nil?
60
      client = RestClient::Resource.new(clone_config[:url], client_options)
61

  
55 62
      args = [method]
56 63
      args << generate_payload(options) if [:post, :put].include?(method)
57 64
      args << headers
......
164 171
                          :authorize_path     => '',
165 172
                          :access_token_path  => '' }
166 173

  
167
      default_options[:ca_file] = config[:ca_cert_file] unless config[:ca_cert_file].nil?
168 174
      consumer = OAuth::Consumer.new(config[:oauth][:oauth_key], config[:oauth][:oauth_secret], default_options)
169 175

  
170 176
      method_to_http_request = { :get    => Net::HTTP::Get,

Also available in: Unified diff