Object
Authentication filter for handling Negotiate/NTLM negotiation. Used in ProxyAuth.
SSPINegotiateAuth depends on 'win32/sspi' module.
Creates new SSPINegotiateAuth filter.
# File lib/httpclient/auth.rb, line 463 def initialize @challenge = {} @scheme = "Negotiate" end
Challenge handler: remember URL and challenge token for response.
# File lib/httpclient/auth.rb, line 505 def challenge(uri, param_str) return false unless SSPIEnabled if param_str.nil? or @challenge[uri].nil? c = @challenge[uri] = {} c[:state] = :init c[:authenticator] = nil c[:authphrase] = "" else c = @challenge[uri] c[:state] = :response c[:authphrase] = param_str end true end
Response handler: returns credential. See win32/sspi for negotiation state transition.
# File lib/httpclient/auth.rb, line 483 def get(req) return nil unless SSPIEnabled target_uri = req.header.request_uri domain_uri, param = @challenge.find { |uri, v| Util.uri_part_of(target_uri, uri) } return nil unless param state = param[:state] authenticator = param[:authenticator] authphrase = param[:authphrase] case state when :init authenticator = param[:authenticator] = Win32::SSPI::NegotiateAuth.new return authenticator.get_initial_token(@scheme) when :response @challenge.delete(domain_uri) return authenticator.complete_authentication(authphrase) end nil end
Generated with the Darkfish Rdoc Generator 2.