Sha256: 929168ddb725ddf6817ffdfb069ff9a3d2f4cd4f617e971122c66db8ddaa5f21

Contents?: true

Size: 911 Bytes

Versions: 29

Compression:

Stored size: 911 Bytes

Contents

module ForemanRhCloud
  module CloudAuth
    extend ActiveSupport::Concern

    def rh_credentials
      @rh_credentials ||= query_refresh_token
    end

    def query_refresh_token
      token_response = RestClient::Request.execute(
        method: :post,
        url: ForemanRhCloud.authentication_url,
        verify_ssl: ForemanRhCloud.verify_ssl_method,
        proxy: ForemanRhCloud.transformed_http_proxy_string(logger: logger),
        payload: {
          grant_type: 'refresh_token',
          client_id: 'rhsm-api',
          refresh_token: Setting[:rh_cloud_token],
        }
      )

      JSON.parse(token_response)['access_token']
    rescue RestClient::ExceptionWithResponse => e
      Foreman::Logging.exception('Unable to authenticate using rh_cloud_token setting', e)
      raise ::Foreman::WrappedException.new(e, N_('Unable to authenticate using rh_cloud_token setting'))
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.21.1 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-3.0.21.1 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-3.0.21 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-3.0.20 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-3.0.19 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-2.0.18.1 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-3.0.18.1 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-1.0.18 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-2.0.18 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-3.0.18 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-1.0.17 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-2.0.17 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-3.0.17 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-2.0.16 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-1.0.16 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-3.0.16 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-1.0.15 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-2.0.15 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-3.0.15 app/services/foreman_rh_cloud/cloud_auth.rb
foreman_rh_cloud-3.0.14 app/services/foreman_rh_cloud/cloud_auth.rb