class RaptorIO::Protocol::HTTP::Request::Manipulators::Authenticators::Negotiate

Implements HTTP Negotiate authentication.

@author Tasos Laskos

Public Instance Methods

run() click to toggle source
# File lib/raptor-io/protocol/http/request/manipulators/authenticators/negotiate.rb, line 17
def run
  return if skip?
  client.manipulators.delete shortname

  t2 = authorize( type1 ).headers['www-authenticate'].split( ' ' ).last

  if authorize( type3( t2 ) ).code == 401 && client.manipulators['authenticator']
    client.datastore['authenticator'][:failed] = true
  end
end

Private Instance Methods

authorize( message ) click to toggle source
# File lib/raptor-io/protocol/http/request/manipulators/authenticators/negotiate.rb, line 34
def authorize( message )
  client.get( request.url,
              mode: :sync,
              manipulators: {
                  'authenticator' => { skip: true },
                  shortname       => { skip: true },
              },
              headers: { 'Authorization' => "#{provider} #{message}" } )
end
provider() click to toggle source
# File lib/raptor-io/protocol/http/request/manipulators/authenticators/negotiate.rb, line 30
def provider
  'Negotiate'
end
skip?() click to toggle source
# File lib/raptor-io/protocol/http/request/manipulators/authenticators/negotiate.rb, line 44
def skip?
  !!options[:skip]
end
type1() click to toggle source
# File lib/raptor-io/protocol/http/request/manipulators/authenticators/negotiate.rb, line 48
def type1
  Net::NTLM::Message::Type1.new.encode64
end
type3( type2 ) click to toggle source
# File lib/raptor-io/protocol/http/request/manipulators/authenticators/negotiate.rb, line 52
def type3( type2 )
  Net::NTLM::Message.decode64( type2 ).response(
      {
          user:     options[:username],
          password: options[:password],
          domain:   options[:domain]
      },
      { ntlmv2: true }
  ).encode64
end