omniauth-cas 0.0.5 → 0.0.6.alpha

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -43,7 +43,8 @@ Other configuration options:
43
43
  * `service_validate_url` - The URL to use to validate a user. Defaults to `'/serviceValidate'`
44
44
  * `logout_url` - The URL to use to logout a user. Defaults to `'/logout'`
45
45
  * `uid_key` - The user data attribute to use as your user's unique identifier. Defaults to `'user'` (which usually contains the user's login name)
46
- * `ca_path` - Optional when `ssl` is `true`. Sets path of a CA certification directory. See [Net::HTTP][net_http] for more details
46
+ * `ca_path` - Optional when `ssl` is `true`. Explicitly sets path of a CA certification directory.
47
+ Defaults to something sensible on Ubuntu and OS X. See [Net::HTTP][net_http] for more details
47
48
 
48
49
  ## Contributing
49
50
 
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Cas
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6.alpha"
4
4
  end
5
5
  end
@@ -9,6 +9,19 @@ module OmniAuth
9
9
 
10
10
  VALIDATION_REQUEST_HEADERS = { 'Accept' => '*/*' }
11
11
 
12
+ UbuntuCAPath = '/etc/ssl/certs'
13
+ OSXCAPath = '/opt/local/share/curl/curl-ca-bundle.crt'
14
+
15
+ DefaultCAPath = begin
16
+ if File.exists?(UbuntuCAPath)
17
+ UbuntuCAPath
18
+ elsif File.exists?(OSXCAPath)
19
+ OSXCAPath
20
+ else
21
+ nil
22
+ end
23
+ end
24
+
12
25
  # Build a validator from a +configuration+, a
13
26
  # +return_to+ URL, and a +ticket+.
14
27
  #
@@ -17,7 +30,7 @@ module OmniAuth
17
30
  # @param [String] ticket the service ticket to validate
18
31
  def initialize(strategy, options, return_to_url, ticket)
19
32
  @options = options
20
- @uri = URI.parse(strategy.service_validate_url(return_to_url, ticket))
33
+ @uri = Addressable::URI.parse(strategy.service_validate_url(return_to_url, ticket))
21
34
  end
22
35
 
23
36
  # Request validation of the ticket from the CAS server's
@@ -76,16 +89,22 @@ module OmniAuth
76
89
  # retrieves the `<cas:serviceResponse>` XML from the CAS server
77
90
  def get_service_response_body
78
91
  result = ''
92
+
79
93
  http = Net::HTTP.new(@uri.host, @uri.port)
80
- http.use_ssl = @uri.port == 443 || @uri.instance_of?(URI::HTTPS)
94
+ http.use_ssl = (@uri.port == 443 or @uri.scheme == "https")
95
+
81
96
  if http.use_ssl?
82
97
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @options.disable_ssl_verification?
83
- http.ca_path = @options.ca_path
98
+
99
+ ca_path = @options.ca_path or DefaultCAPath
100
+ http.ca_path = ca_path if ca_path
84
101
  end
102
+
85
103
  http.start do |c|
86
- response = c.get "#{@uri.path}?#{@uri.query}", VALIDATION_REQUEST_HEADERS.dup
104
+ response = c.get( @uri.omit(:scheme, :authority).to_s, VALIDATION_REQUEST_HEADERS.dup )
87
105
  result = response.body
88
106
  end
107
+
89
108
  result
90
109
  end
91
110
 
@@ -22,7 +22,7 @@ describe OmniAuth::Strategies::CAS::ServiceTicketValidator do
22
22
 
23
23
  describe "#user_info" do
24
24
  before do
25
- stub_request(:get, "https://example.org/serviceValidate?").to_return(:status => 200, :body => '')
25
+ stub_request(:get, "https://example.org:80/serviceValidate").to_return(:status => 200, :body => '')
26
26
  validator.user_info
27
27
  end
28
28
  it "should use the configured CA path" do
@@ -56,7 +56,7 @@ describe OmniAuth::Strategies::CAS, :type => :strategy do
56
56
 
57
57
  describe 'GET /auth/cas/callback with an invalid ticket' do
58
58
  before do
59
- stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=9391d/).
59
+ stub_request(:get, /^https:\/\/cas.example.org(:443)?(:80)?\/serviceValidate\?([^&]+&)?ticket=9391d/).
60
60
  to_return( :body => File.read('spec/fixtures/cas_failure.xml') )
61
61
  get '/auth/cas/callback?ticket=9391d'
62
62
  end
@@ -72,7 +72,7 @@ describe OmniAuth::Strategies::CAS, :type => :strategy do
72
72
  describe 'GET /auth/cas/callback with a valid ticket' do
73
73
  let(:return_url) { "http://127.0.0.10/?some=parameter" }
74
74
  before do
75
- stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=593af/).
75
+ stub_request(:get, /^https:\/\/cas.example.org(:443)?(:80)?\/serviceValidate\?([^&]+&)?ticket=593af/).
76
76
  with { |request| @request_uri = request.uri.to_s }.
77
77
  to_return( :body => File.read('spec/fixtures/cas_success.xml') )
78
78
 
@@ -84,7 +84,7 @@ describe OmniAuth::Strategies::CAS, :type => :strategy do
84
84
  end
85
85
 
86
86
  it "should properly encode the service URL" do
87
- WebMock.should have_requested(:get, "https://cas.example.org/serviceValidate")
87
+ WebMock.should have_requested(:get, "https://cas.example.org:80/serviceValidate")
88
88
  .with(:query => {
89
89
  :ticket => "593af",
90
90
  :service => "http://example.org/auth/cas/callback?url=" + Rack::Utils.escape("http://127.0.0.10/?some=parameter")
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-cas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
4
+ version: 0.0.6.alpha
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Derek Lindahl
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-11 00:00:00.000000000Z
12
+ date: 2012-02-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth
16
- requirement: &2152816500 !ruby/object:Gem::Requirement
16
+ requirement: &2160884240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152816500
24
+ version_requirements: *2160884240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &2152816000 !ruby/object:Gem::Requirement
27
+ requirement: &2160883720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.5'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2152816000
35
+ version_requirements: *2160883720
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: addressable
38
- requirement: &2152815520 !ruby/object:Gem::Requirement
38
+ requirement: &2160883260 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '2.2'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2152815520
46
+ version_requirements: *2160883260
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &2152815060 !ruby/object:Gem::Requirement
49
+ requirement: &2160882800 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0.9'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2152815060
57
+ version_requirements: *2160882800
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: webmock
60
- requirement: &2152804240 !ruby/object:Gem::Requirement
60
+ requirement: &2160882340 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '1.7'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2152804240
68
+ version_requirements: *2160882340
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
- requirement: &2152803740 !ruby/object:Gem::Requirement
71
+ requirement: &2160871780 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.5.4
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2152803740
79
+ version_requirements: *2160871780
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rspec
82
- requirement: &2152803280 !ruby/object:Gem::Requirement
82
+ requirement: &2160870320 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '2.8'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2152803280
90
+ version_requirements: *2160870320
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rack-test
93
- requirement: &2152802560 !ruby/object:Gem::Requirement
93
+ requirement: &2160869740 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0.6'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2152802560
101
+ version_requirements: *2160869740
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: bourne
104
- requirement: &2152802080 !ruby/object:Gem::Requirement
104
+ requirement: &2160869160 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '1.0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2152802080
112
+ version_requirements: *2160869160
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: awesome_print
115
- requirement: &2152801700 !ruby/object:Gem::Requirement
115
+ requirement: &2160868660 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *2152801700
123
+ version_requirements: *2160868660
124
124
  description:
125
125
  email:
126
126
  - dlindahl@customink.com
@@ -163,9 +163,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
163
  required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  none: false
165
165
  requirements:
166
- - - ! '>='
166
+ - - ! '>'
167
167
  - !ruby/object:Gem::Version
168
- version: '0'
168
+ version: 1.3.1
169
169
  requirements: []
170
170
  rubyforge_project:
171
171
  rubygems_version: 1.8.10