net-http-ntlm
Adds NTLM authentication to HTTP requests using the rubyntlm gem. A drop-in replacement for ruby-ntlm with NTLMv2 support.
NTLM authentication is used in Microsoft's server products, such as MS Exchange Server and IIS.
Install
gem install net-http-ntlm
If you'd rather install net-http-ntlm using bundler
, add a line for it in your Gemfile:
gem 'net-http-ntlm'
Note about Ruby 3 and OpenSSL 3
NTLM potentially uses legacy ciphers, which need to be enabled explicitly.
You can either create a custom OpenSSL profile in Ruby or load a custom SSL
configuration by setting OPENSSL_CONF=
before Ruby loads.
There's an example in the [Github Actions][.github/workflows/ci.yml]
Usage
require 'net/http/ntlm'
http = Net::HTTP.new('www.example.com')
request = Net::HTTP::Get.new('/')
request.ntlm_auth('User', 'Domain', 'Password')
response = http.request(request)
References
- rubyntlm: https://github.com/WinRb/rubyntlm
- ruby-ntlm: https://github.com/macks/ruby-ntlm