Last active
December 2, 2019 14:35
-
-
Save Castone22/3ece408353a6cfac95096beed27cbcd0 to your computer and use it in GitHub Desktop.
Simple Solution to Rest Client NTLM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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