class HTTPX::Plugins::NtlmV2Auth::Authenticator

  1. lib/httpx/plugins/ntlm_v2_auth.rb
Superclass: Object

Methods

Public Class

  1. new

Public Instance

  1. authenticate
  2. can_authenticate?
  3. negotiate

Public Class methods

new(user, password, domain: nil)
[show source]
   # File lib/httpx/plugins/ntlm_v2_auth.rb
19 def initialize(user, password, domain: nil)
20   @user = user
21   @password = password
22   @domain = domain
23 end

Public Instance methods

authenticate(_request, www_authenticate)
[show source]
   # File lib/httpx/plugins/ntlm_v2_auth.rb
35 def authenticate(_request, www_authenticate)
36   challenge_b64 = www_authenticate[/NTLM (.+)/i, 1]
37   t2 = Net::NTLM::Message.decode64(challenge_b64)
38   t3 = t2.response(
39     { user: @user, password: @password, domain: @domain },
40     ntlmv2: true
41   )
42   "NTLM #{t3.encode64}"
43 end
can_authenticate?(www_authenticate)
[show source]
   # File lib/httpx/plugins/ntlm_v2_auth.rb
25 def can_authenticate?(www_authenticate)
26   www_authenticate && /NTLM/i.match?(www_authenticate)
27 end
negotiate()
[show source]
   # File lib/httpx/plugins/ntlm_v2_auth.rb
29 def negotiate
30   t1 = Net::NTLM::Message::Type1.new
31   t1.domain = @domain if @domain
32   "NTLM #{t1.encode64}"
33 end