Skip to content

Commit

Permalink
Merge 2fd2468 into d80ece0
Browse files Browse the repository at this point in the history
  • Loading branch information
tjarratt committed Feb 3, 2014
2 parents d80ece0 + 2fd2468 commit 07553b9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 2.2.0 (edge)

* Feature: [#108](https://github.com/savonrb/httpi/pull/108) Make `rubyntlm` gem, an optional dependency.

### 2.1.0 (2013-07-22)

* Feature: [#75](https://github.com/savonrb/httpi/pull/75) Rack adapter.
Expand Down
10 changes: 5 additions & 5 deletions httpi.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ Gem::Specification.new do |s|
s.license = 'MIT'

s.add_dependency 'rack'
s.add_dependency 'rubyntlm', '~> 0.3.2'

s.add_development_dependency 'rake', '~> 10.0'
s.add_development_dependency 'rspec', '~> 2.12'
s.add_development_dependency 'mocha', '~> 0.13'
s.add_development_dependency 'puma', '~> 2.3.2'
s.add_development_dependency 'rubyntlm', '~> 0.3.2'
s.add_development_dependency 'rake', '~> 10.0'
s.add_development_dependency 'rspec', '~> 2.12'
s.add_development_dependency 'mocha', '~> 0.13'
s.add_development_dependency 'puma', '~> 2.3.2'

s.files = `git ls-files`.split("\n")
s.require_path = 'lib'
Expand Down
14 changes: 11 additions & 3 deletions lib/httpi/adapter/net_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

require "httpi/adapter/base"
require "httpi/response"
require 'net/ntlm'
require 'kconv'
require 'socket'

begin
require 'net/ntlm'
unless Net::NTLM::VERSION::STRING >= '0.3.2'
raise ArgumentError('Invalid version of rubyntlm. Please use v0.3.2+')
end
rescue LoadError => e
HTTPI.logger.debug('Net::NTLM is not available')
end

module HTTPI
module Adapter

Expand Down Expand Up @@ -102,7 +110,7 @@ def negotiate_ntlm_auth(http, &requester)
if auth_response.headers["WWW-Authenticate"] =~ /(NTLM|Negotiate) (.+)/
auth_token = $2
ntlm_message = Net::NTLM::Message.decode64(auth_token)

message_builder = {}
# copy the username and password from the authorization parameters
message_builder[:user] = @request.auth.ntlm[0]
Expand All @@ -114,7 +122,7 @@ def negotiate_ntlm_auth(http, &requester)
else
message_builder[:domain] = ''
end

ntlm_response = ntlm_message.response(message_builder ,
{:ntlmv2 => true})
# Finally add header of Authorization
Expand Down
2 changes: 1 addition & 1 deletion lib/httpi/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module HTTPI

VERSION = "2.1.0"
VERSION = "2.2.0"

end

0 comments on commit 07553b9

Please sign in to comment.