rubysspi 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.txt +3 -0
- data/Rakefile +1 -1
- data/bin/apply_sspi_patch +1 -1
- data/lib/win32/sspi/http_proxy_patch.rb +38 -8
- data/test/test_gem_list.rb +22 -7
- data/test/test_net_http.rb +7 -0
- metadata +42 -35
data/CHANGELOG.txt
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
== 1.2.4
|
2
|
+
* Compatibility updates for rubygems 1.2.0
|
3
|
+
|
1
4
|
== 1.2.2
|
2
5
|
* Fixed incompatibility with RubyGems >= 0.9.2 and RubySSPI Net::HTTP patch. Patch now directly requires the SSPI files, rather than relying on RubyGems to load it.
|
3
6
|
* Updated gem tests for compatibility with RubyGems >= 0.9.2.
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ require 'rake/testtask'
|
|
6
6
|
spec = Gem::Specification.new do |s|
|
7
7
|
s.name = "rubysspi"
|
8
8
|
s.summary = "A library which implements Ruby bindings to the Win32 SSPI library. Also includes a module to add Negotiate authentication support to Net::HTTP."
|
9
|
-
s.version = "1.2.
|
9
|
+
s.version = "1.2.4"
|
10
10
|
s.author = "Justin Bailey"
|
11
11
|
s.email = "jgbailey @nospam@ gmail.com"
|
12
12
|
s.homepage = "http://rubyforge.org/projects/rubysspi/"
|
data/bin/apply_sspi_patch
CHANGED
@@ -30,6 +30,27 @@ module Net
|
|
30
30
|
# Suppress warnings about redefining request
|
31
31
|
@old_verbose = $VERBOSE
|
32
32
|
$VERBOSE = nil
|
33
|
+
|
34
|
+
# Determines if authorization is required and returns
|
35
|
+
# the expected type ("NTLM" or "Negotiate"). Otherwise,
|
36
|
+
# returns nil.
|
37
|
+
def sspi_auth_required?(res)
|
38
|
+
header =
|
39
|
+
if proxy? && res.kind_of?(HTTPProxyAuthenticationRequired)
|
40
|
+
"Proxy-Authenticate"
|
41
|
+
elsif res.kind_of?(HTTPUnauthorized)
|
42
|
+
"WWW-Authenticate"
|
43
|
+
else
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
|
47
|
+
if header
|
48
|
+
# Critical to start with Negotiate. NTLM is fallback.
|
49
|
+
["Negotiate", "NTLM"].find { |tok| res[header].include? tok }
|
50
|
+
else
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
end
|
33
54
|
|
34
55
|
def request(req, body = nil, &block) # :yield: +response+
|
35
56
|
unless started?
|
@@ -50,37 +71,46 @@ module Net
|
|
50
71
|
begin
|
51
72
|
res = HTTPResponse.read_new(@socket)
|
52
73
|
end while res.kind_of?(HTTPContinue)
|
53
|
-
|
54
|
-
if res.kind_of?(HTTPProxyAuthenticationRequired) && proxy? && res["Proxy-Authenticate"].include?("Negotiate")
|
74
|
+
if tok = sspi_auth_required?(res)
|
55
75
|
begin
|
56
76
|
n = Win32::SSPI::NegotiateAuth.new
|
57
77
|
res.reading_body(@socket, req.response_body_permitted?) { }
|
58
78
|
end_transport req, res
|
59
79
|
begin_transport req
|
60
|
-
|
80
|
+
if proxy?
|
81
|
+
req["Proxy-Authorization"] = "#{tok} #{n.get_initial_token}"
|
82
|
+
req["Proxy-Connection"] = "Keep-Alive"
|
83
|
+
else
|
84
|
+
req["Authorization"] = "#{tok} #{n.get_initial_token}"
|
85
|
+
end
|
61
86
|
# Some versions of ISA will close the connection if this isn't present.
|
62
87
|
req["Connection"] = "Keep-Alive"
|
63
|
-
req["Proxy-Connection"] = "Keep-Alive"
|
64
88
|
req.exec @socket, @curr_http_version, edit_path(req.path)
|
65
89
|
begin
|
66
90
|
res = HTTPResponse.read_new(@socket)
|
67
91
|
end while res.kind_of?(HTTPContinue)
|
68
|
-
if res["Proxy-Authenticate"]
|
92
|
+
if (proxy? && res["Proxy-Authenticate"]) || (! proxy? && res["WWW-Authenticate"])
|
69
93
|
res.reading_body(@socket, req.response_body_permitted?) { }
|
70
|
-
|
94
|
+
if proxy?
|
95
|
+
req["Proxy-Authorization"] = "#{tok} #{n.complete_authentication res["Proxy-Authenticate"]}"
|
96
|
+
req["Proxy-Connection"] = "Keep-Alive"
|
97
|
+
else
|
98
|
+
token = res["WWW-Authenticate"].split(" ").last
|
99
|
+
req["Authorization"] = "#{tok} #{n.complete_authentication token}"
|
100
|
+
end
|
71
101
|
req["Connection"] = "Keep-Alive"
|
72
|
-
req["Proxy-Connection"] = "Keep-Alive"
|
73
102
|
req.exec @socket, @curr_http_version, edit_path(req.path)
|
74
103
|
begin
|
75
104
|
res = HTTPResponse.read_new(@socket)
|
76
105
|
end while res.kind_of?(HTTPContinue)
|
77
106
|
end
|
78
107
|
rescue
|
79
|
-
exc = $!.exception("Error occurred during proxy negotiation.
|
108
|
+
exc = $!.exception("Error occurred during proxy negotiation. req: #{req["Proxy-Authorization"].inspect}; res: #{res.inspect}; Original message: #{$!.message}")
|
80
109
|
exc.set_backtrace $!.backtrace
|
81
110
|
raise exc
|
82
111
|
end
|
83
112
|
end
|
113
|
+
|
84
114
|
res.reading_body(@socket, req.response_body_permitted?) {
|
85
115
|
yield res if block_given?
|
86
116
|
}
|
data/test/test_gem_list.rb
CHANGED
@@ -10,6 +10,13 @@
|
|
10
10
|
# Ruby Distribution License or GNU General Public License.
|
11
11
|
#
|
12
12
|
|
13
|
+
# Ruby gems > 0.9 loads patch automatically so DISABLE_RUBY_SSPI_PATCH doesn't do any good.
|
14
|
+
# Therefore, need to ensure ruby gems isn't loaded automatically.
|
15
|
+
if ENV["RUBYOPT"]
|
16
|
+
puts "Unset RUBYOPT environment variable before running these tests."
|
17
|
+
exit!
|
18
|
+
end
|
19
|
+
|
13
20
|
# Magic constant will ensure that, if the SSPI patch has been applied, it won't break these tests
|
14
21
|
DISABLE_RUBY_SSPI_PATCH = true
|
15
22
|
|
@@ -28,16 +35,24 @@ class NTLMTest < Test::Unit::TestCase
|
|
28
35
|
# bug occurred when gem list was executed. This tests to ensure
|
29
36
|
# bug does not come back.
|
30
37
|
def test_gem_list
|
31
|
-
Gem.manage_gems
|
32
38
|
|
33
|
-
if Gem::Version.new(Gem::RubyGemsVersion) < Gem::Version.new("
|
34
|
-
|
35
|
-
|
39
|
+
if Gem::Version.new(Gem::RubyGemsVersion) < Gem::Version.new("1.2")
|
40
|
+
Gem.manage_gems
|
41
|
+
if Gem::Version.new(Gem::RubyGemsVersion) < Gem::Version.new("0.9.2")
|
42
|
+
assert_nothing_raised "'gem list --remote rubysspi' failed to execute" do
|
43
|
+
Gem::GemRunner.new.run(%w(list rubysspi --remote --http-proxy ))
|
44
|
+
end
|
45
|
+
else
|
46
|
+
# --http-proxy option not needed after 0.9.2 (at least)
|
47
|
+
assert_nothing_raised "'gem list --remote rubysspi' failed to execute" do
|
48
|
+
Gem::GemRunner.new.run(%w(list rubysspi --remote))
|
49
|
+
end
|
36
50
|
end
|
37
|
-
elsif Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new("
|
38
|
-
|
51
|
+
elsif Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new("1.2")
|
52
|
+
require 'rubygems/command_manager'
|
53
|
+
# Gem::GemRunner not used after 1.2
|
39
54
|
assert_nothing_raised "'gem list --remote rubysspi' failed to execute" do
|
40
|
-
Gem::
|
55
|
+
Gem::CommandManager.instance.run(%w(list rubysspi --remote))
|
41
56
|
end
|
42
57
|
end
|
43
58
|
end
|
data/test/test_net_http.rb
CHANGED
@@ -10,6 +10,13 @@
|
|
10
10
|
# Ruby Distribution License or GNU General Public License.
|
11
11
|
#
|
12
12
|
|
13
|
+
# Ruby gems > 0.9 loads patch automatically so DISABLE_RUBY_SSPI_PATCH doesn't do any good.
|
14
|
+
# Therefore, need to ensure ruby gems isn't loaded automatically.
|
15
|
+
if ENV["RUBYOPT"]
|
16
|
+
puts "Unset RUBYOPT environment variable before running these tests."
|
17
|
+
exit!
|
18
|
+
end
|
19
|
+
|
13
20
|
DISABLE_RUBY_SSPI_PATCH = true
|
14
21
|
|
15
22
|
require 'test/unit'
|
metadata
CHANGED
@@ -1,33 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.2
|
3
|
-
specification_version: 1
|
4
2
|
name: rubysspi
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.2.
|
7
|
-
date: 2007-07-10 00:00:00 -07:00
|
8
|
-
summary: A library which implements Ruby bindings to the Win32 SSPI library. Also includes a module to add Negotiate authentication support to Net::HTTP.
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: jgbailey @nospam@ gmail.com
|
12
|
-
homepage: http://rubyforge.org/projects/rubysspi/
|
13
|
-
rubyforge_project: http://rubyforge.org/projects/rubysspi/
|
14
|
-
description: This gem provides bindings to the Win32 SSPI libraries, primarily to support Negotiate (i.e. SPNEGO, NTLM) authentication with a proxy server. Enough support is implemented to provide the necessary support for the authentication. A module is also provided which overrides Net::HTTP and adds support for Negotiate authentication to it. This implies that open-uri automatically gets support for it, as long as the http_proxy environment variable is set.
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 1.2.4
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Justin Bailey
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-08-01 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: This gem provides bindings to the Win32 SSPI libraries, primarily to support Negotiate (i.e. SPNEGO, NTLM) authentication with a proxy server. Enough support is implemented to provide the necessary support for the authentication. A module is also provided which overrides Net::HTTP and adds support for Negotiate authentication to it. This implies that open-uri automatically gets support for it, as long as the http_proxy environment variable is set.
|
17
|
+
email: jgbailey @nospam@ gmail.com
|
18
|
+
executables:
|
19
|
+
- apply_sspi_patch
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.txt
|
24
|
+
- CHANGELOG.txt
|
25
|
+
- LICENSE.txt
|
31
26
|
files:
|
32
27
|
- lib/win32
|
33
28
|
- lib/win32/sspi
|
@@ -43,23 +38,35 @@ files:
|
|
43
38
|
- README.txt
|
44
39
|
- Rakefile
|
45
40
|
- spa.rb
|
46
|
-
|
47
|
-
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://rubyforge.org/projects/rubysspi/
|
43
|
+
post_install_message:
|
48
44
|
rdoc_options:
|
49
45
|
- --title
|
50
46
|
- Ruby SSPI -- Win32 SSPI Bindings for Ruby
|
51
47
|
- --main
|
52
48
|
- README.txt
|
53
49
|
- --line-numbers
|
54
|
-
|
55
|
-
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
-
|
60
|
-
|
61
|
-
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
version:
|
62
64
|
requirements: []
|
63
65
|
|
64
|
-
|
66
|
+
rubyforge_project: http://rubyforge.org/projects/rubysspi/
|
67
|
+
rubygems_version: 1.2.0
|
68
|
+
signing_key:
|
69
|
+
specification_version: 2
|
70
|
+
summary: A library which implements Ruby bindings to the Win32 SSPI library. Also includes a module to add Negotiate authentication support to Net::HTTP.
|
71
|
+
test_files: []
|
65
72
|
|