Class: HTTPX::Plugins::Authentication::Ntlm
- Inherits:
-
Object
- Object
- HTTPX::Plugins::Authentication::Ntlm
- Defined in:
- lib/httpx/plugins/auth/ntlm.rb
Instance Method Summary collapse
- #authenticate(_req, www) ⇒ Object
- #can_authenticate?(authenticate) ⇒ Boolean
-
#initialize(user, password, domain: nil) ⇒ Ntlm
constructor
A new instance of Ntlm.
- #negotiate ⇒ Object
Constructor Details
#initialize(user, password, domain: nil) ⇒ Ntlm
Returns a new instance of Ntlm.
10 11 12 13 14 |
# File 'lib/httpx/plugins/auth/ntlm.rb', line 10 def initialize(user, password, domain: nil) @user = user @password = password @domain = domain end |
Instance Method Details
#authenticate(_req, www) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/httpx/plugins/auth/ntlm.rb', line 24 def authenticate(_req, www) challenge = www[/NTLM (.*)/, 1] challenge = Base64.decode64(challenge) ntlm_challenge = NTLM.authenticate(challenge, @user, @domain, @password).to_base64 "NTLM #{ntlm_challenge}" end |
#can_authenticate?(authenticate) ⇒ Boolean
16 17 18 |
# File 'lib/httpx/plugins/auth/ntlm.rb', line 16 def can_authenticate?(authenticate) authenticate && /NTLM .*/.match?(authenticate) end |
#negotiate ⇒ Object
20 21 22 |
# File 'lib/httpx/plugins/auth/ntlm.rb', line 20 def negotiate "NTLM #{NTLM.negotiate(domain: @domain).to_base64}" end |