Method: InspecPlugins::Compliance::API.get_headers

Defined in:
lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb

.get_headers(config) ⇒ Object



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb', line 194

def self.get_headers(config)
  token = get_token(config)
  if is_automate_server?(config) || is_automate2_server?(config)
    headers = { 'chef-delivery-enterprise' => config['automate']['ent'] }
    if config['automate']['token_type'] == 'dctoken'
      headers['x-data-collector-token'] = token
    else
      headers['chef-delivery-user'] = config['user']
      headers['chef-delivery-token'] = token
    end
  else
    headers = { 'Authorization' => "Bearer #{token}" }
  end
  headers
end