Skip to content

Commit

Permalink
moved support for ntlm authentication to httpi-ntlm
Browse files Browse the repository at this point in the history
since ntlm support caused quite some problems for people who didn't
even need it, i decided to move it into httpi-ntlm until it's stable.
  • Loading branch information
rubiii committed Jun 29, 2011
1 parent fdc3a82 commit f792d27
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 26 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.9.5 (2011-06-30)

* Improvement: Moved support for NTLM authentication into a separate gem.
Since NTLM support caused quite some problems for people who didn't even
need it, I decided to move it into httpi-ntlm until it's stable.

## 0.9.4 (2011-05-15)

* Fix: issues [34](https://github.com/rubiii/httpi/issues/34) and
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,14 @@ HTTPI::Auth
``` ruby
request.auth.basic("username", "password") # HTTP basic auth credentials
request.auth.digest("username", "password") # HTTP digest auth credentials
request.auth.ntlm("username", "password") # NTLM auth credentials
```

For experimental NTLM authentication, please use the [httpi-ntlm](rubygems.org/gems/httpi-ntml)
gem and provide feedback.

``` ruby
request.auth.ntlm("username", "password") # NTLM auth credentials
```

HTTPI::Auth::SSL
----------------
Expand Down
1 change: 0 additions & 1 deletion httpi.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Gem::Specification.new do |s|
s.rubyforge_project = s.name

s.add_dependency "rack"
s.add_dependency "pyu-ntlm-http", ">= 0.1.3.1"

s.add_development_dependency "rspec", "~> 2.2"
s.add_development_dependency "autotest"
Expand Down
14 changes: 7 additions & 7 deletions lib/httpi/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ module HTTPI
module Adapter

ADAPTERS = {
:httpclient => { :class => HTTPClient, :dependencies => ["httpclient"] },
:curb => { :class => Curb, :dependencies => ["curb"] },
:net_http => { :class => NetHTTP, :dependencies => ["net/https", "net/ntlm_http"] }
:httpclient => { :class => HTTPClient, :require => "httpclient" },
:curb => { :class => Curb, :require => "curb" },
:net_http => { :class => NetHTTP, :require => "net/https" }
}

LOAD_ORDER = [:httpclient, :curb, :net_http]
Expand All @@ -27,7 +27,7 @@ def use=(adapter)
return @adapter = nil if adapter.nil?

validate_adapter! adapter
load_dependencies adapter
load_adapter adapter
@adapter = adapter
end

Expand All @@ -50,16 +50,16 @@ def validate_adapter!(adapter)
def default_adapter
LOAD_ORDER.each do |adapter|
begin
load_dependencies adapter
load_adapter adapter
return adapter
rescue LoadError
next
end
end
end

def load_dependencies(adapter)
ADAPTERS[adapter][:dependencies].each { |dependency| require dependency }
def load_adapter(adapter)
require ADAPTERS[adapter][:require]
end

end
Expand Down
6 changes: 0 additions & 6 deletions lib/httpi/adapter/curb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def setup_client(request)
basic_setup request
setup_http_auth request if request.auth.http?
setup_ssl_auth request.auth.ssl if request.auth.ssl?
setup_ntlm_auth request if request.auth.ntlm?
end

def basic_setup(request)
Expand All @@ -84,11 +83,6 @@ def setup_ssl_auth(ssl)
client.ssl_verify_peer = ssl.verify_mode == :peer
end

def setup_ntlm_auth(request)
client.username, client.password = *request.auth.credentials
client.http_auth_types = request.auth.type
end

def respond_with(client)
status, headers = parse_header_string(client.header_str)
Response.new client.response_code, headers, client.body_str
Expand Down
2 changes: 1 addition & 1 deletion lib/httpi/adapter/httpclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def do_request(request)

def setup_client(request)
basic_setup request
setup_auth request if request.auth.http? || request.auth.ntlm?
setup_auth request if request.auth.http?
setup_ssl_auth request.auth.ssl if request.auth.ssl?
end

Expand Down
2 changes: 0 additions & 2 deletions lib/httpi/adapter/net_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ def request_client(type, request)
end

request_client = request_class.new request.url.request_uri, request.headers

request_client.basic_auth *request.auth.credentials if request.auth.basic?
request_client.ntlm_auth *request.auth.credentials if request.auth.ntlm?

request_client
end
Expand Down
13 changes: 5 additions & 8 deletions lib/httpi/auth/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Auth
class Config

# Supported authentication types.
TYPES = [:basic, :digest, :ssl, :ntlm]
TYPES = [:basic, :digest, :ssl]

# Accessor for the HTTP basic auth credentials.
def basic(*args)
Expand Down Expand Up @@ -43,17 +43,14 @@ def http?
type == :basic || type == :digest
end

# Accessor for the NTLM auth credentials.
# Only available with the httpi-ntlm gem.
def ntlm(*args)
return @ntlm if args.empty?

self.type = :ntlm
@ntlm = args.flatten.compact
raise "Install the httpi-ntlm gem for experimental NTLM support"
end

# Returns whether to use NTLM auth.
# Only available with the httpi-ntlm gem.
def ntlm?
type == :ntlm
raise "Install the httpi-ntlm gem for experimental NTLM support"
end

# Returns the <tt>HTTPI::Auth::SSL</tt> object.
Expand Down

0 comments on commit f792d27

Please sign in to comment.