Sha256: aad89078249abb470f131321e72c2333f7029d4333f4e0199a6ed9ea5594754c

Contents?: true

Size: 797 Bytes

Versions: 20

Compression:

Stored size: 797 Bytes

Contents

# frozen_string_literal: true

require "httpx/base64"
require "ntlm"

module HTTPX
  module Plugins
    module Authentication
      class Ntlm
        def initialize(user, password, domain: nil)
          @user = user
          @password = password
          @domain = domain
        end

        def can_authenticate?(authenticate)
          authenticate && /NTLM .*/.match?(authenticate)
        end

        def negotiate
          "NTLM #{NTLM.negotiate(domain: @domain).to_base64}"
        end

        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
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
httpx-1.3.4 lib/httpx/plugins/auth/ntlm.rb
httpx-1.3.3 lib/httpx/plugins/auth/ntlm.rb
httpx-1.3.2 lib/httpx/plugins/auth/ntlm.rb
httpx-1.3.1 lib/httpx/plugins/auth/ntlm.rb
httpx-1.3.0 lib/httpx/plugins/auth/ntlm.rb
httpx-1.2.6 lib/httpx/plugins/auth/ntlm.rb
httpx-1.2.4 lib/httpx/plugins/auth/ntlm.rb
httpx-1.2.3 lib/httpx/plugins/auth/ntlm.rb
httpx-1.2.2 lib/httpx/plugins/auth/ntlm.rb
httpx-1.2.1 lib/httpx/plugins/auth/ntlm.rb
httpx-1.2.0 lib/httpx/plugins/auth/ntlm.rb
httpx-1.1.5 lib/httpx/plugins/auth/ntlm.rb
httpx-1.1.4 lib/httpx/plugins/auth/ntlm.rb
httpx-1.1.3 lib/httpx/plugins/auth/ntlm.rb
httpx-1.1.2 lib/httpx/plugins/auth/ntlm.rb
httpx-1.1.1 lib/httpx/plugins/auth/ntlm.rb
httpx-1.1.0 lib/httpx/plugins/auth/ntlm.rb
httpx-1.0.2 lib/httpx/plugins/auth/ntlm.rb
httpx-1.0.1 lib/httpx/plugins/auth/ntlm.rb
httpx-1.0.0 lib/httpx/plugins/auth/ntlm.rb