Skip to content

Instantly share code, notes, and snippets.

@Castone22
Last active December 2, 2019 14:35
Show Gist options
  • Save Castone22/3ece408353a6cfac95096beed27cbcd0 to your computer and use it in GitHub Desktop.
Save Castone22/3ece408353a6cfac95096beed27cbcd0 to your computer and use it in GitHub Desktop.
Simple Solution to Rest Client NTLM
require 'ntlm/http'
require 'rest-client'
require 'json'
# Quick monkey patch to rest client payloads since for some reason Net/NTLM insists on playing payload streams backwards.
class RestClient::Payload::Base
def rewind
@stream.rewind
end
end
auth_proc = ->(req, _args){ req.ntlm_auth(username, domain, password)}
res = RestClient::Request.new(method: :post, url: url, payload: payload}, before_execution_proc: auth_proc ).execute
res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment