omniauth-cas 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTE0MmRjNzI2MDhhMzNlMDBjZTMwY2RiM2ZhMzM4MGQ0MTEwYmYxOA==
5
+ data.tar.gz: !binary |-
6
+ MzJmY2E3ZGExZTQ2MzE3MWEwMGEyNWFmYjExYzEzNDY3NGJhOTA5ZQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZDM2M2ZiZmVjY2NjNjQ1OTg1NDEyNDU5ZjFjNzcwMjg1M2IxZTQ0ZmE4NzBh
10
+ ZTQ5ZmQ3ODU2NmJkNTQ2Y2VkOTQ2YWJjNzc1MzgyYTc1YjZlY2UzMjBiOWIx
11
+ NDQ4ZGUyMTJiMzNiZWY0YTA5ODZhZjQ4MDlhYWYzYTFlYjA4ZDQ=
12
+ data.tar.gz: !binary |-
13
+ OTQ2Y2QwYTkxNjhmM2M2ZjQ3ZmNkNDY1NzA4NzZiNGQyZDQ1ZmM3YTBiNmVk
14
+ MjljZjI2OGFiZjNlNDM0ZDY1MzI2MDIxNjg1NGQ3NWUzOTBmNzExMjEzZDI0
15
+ NjY2YTUyZWI3M2Q4OGIyZTgyZTAxMWRmYTlhYTk3Y2JhZjQ1NWQ=
data/.gitignore CHANGED
@@ -15,6 +15,7 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ vendor
18
19
 
19
20
  # RSpec
20
21
  .rspec
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # OmniAuth CAS Strategy [![Build Status][travis_status]][travis]
1
+ # OmniAuth CAS Strategy [![Gem Version][version_badge]][version] [![Build Status][travis_status]][travis]
2
2
 
3
+ [version_badge]: https://badge.fury.io/rb/omniauth-cas.png
4
+ [version]: http://badge.fury.io/rb/omniauth-cas
3
5
  [travis]: http://travis-ci.org/dlindahl/omniauth-cas
4
6
  [travis_status]: https://secure.travis-ci.org/dlindahl/omniauth-cas.png
5
- [gemnasium]: https://gemnasium.com/dlindahl/omniauth-cas
6
- [gemnasium_status]: https://gemnasium.com/dlindahl/omniauth-cas.png?travis
7
7
 
8
8
  This is a OmniAuth 1.0 compatible port of the previously available
9
9
  [OmniAuth CAS strategy][old_omniauth_cas] that was bundled with OmniAuth 0.3.
@@ -34,6 +34,10 @@ Rails.application.config.middleware.use OmniAuth::Builder do
34
34
  end
35
35
  ```
36
36
 
37
+ ### Configuration Options
38
+
39
+ #### Required
40
+
37
41
  OmniAuth CAS requires at least one of the following two configuration options:
38
42
 
39
43
  * `url` - Defines the URL of your CAS server (i.e. `http://example.org:8080`)
@@ -41,6 +45,8 @@ OmniAuth CAS requires at least one of the following two configuration options:
41
45
  * `login_url` - Defines the URL used to prompt users for their login information. Defaults to `/login`
42
46
  If no `host` is configured, the host application's domain will be used.
43
47
 
48
+ #### Optional
49
+
44
50
  Other configuration options:
45
51
 
46
52
  * `port` - The port to use for your configured CAS `host`. Optional if using `url`
@@ -68,7 +74,7 @@ provider :cas,
68
74
  service_validate_url: '/cas/serviceValidate'
69
75
  ```
70
76
 
71
- If you encounter problems wih SSL certificates you may want to set the `ca_path` parameter or activate `disable_ssl_verification` (not recommended).
77
+ If you encounter problems wih SSL certificates you may want to set the `ca_path` parameter or activate `disable_ssl_verification` (not recommended).
72
78
 
73
79
  ## Contributing
74
80
 
@@ -88,4 +94,4 @@ Special thanks go out to the following people
88
94
 
89
95
  [old_omniauth_cas]: https://github.com/intridea/omniauth/blob/0-3-stable/oa-enterprise/lib/omniauth/strategies/cas.rb
90
96
  [document_up]: http://dlindahl.github.com/omniauth-cas/
91
- [net_http]: http://ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html
97
+ [net_http]: http://ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Cas
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
@@ -16,10 +16,11 @@ module OmniAuth
16
16
  attr_accessor :raw_info
17
17
  alias_method :user_info, :raw_info
18
18
 
19
- option :name, :cas # TODO: Why do I need to specify this?
19
+ option :name, :cas # Required property by OmniAuth::Strategy
20
20
 
21
21
  option :host, nil
22
22
  option :port, nil
23
+ option :path, nil
23
24
  option :ssl, true
24
25
  option :service_validate_url, '/serviceValidate'
25
26
  option :login_url, '/login'
@@ -87,12 +88,15 @@ module OmniAuth
87
88
  # Build a CAS host with protocol and port
88
89
  #
89
90
  #
90
- def cas_host
91
- @host ||= begin
92
- host = @options.ssl ? "https" : "http"
93
- port = @options.port ? ":#{@options.port}" : ''
94
-
95
- "#{host}://#{@options.host}#{port}"
91
+ def cas_url
92
+ @cas_url ||= begin
93
+ uri = Addressable::URI.new
94
+ uri.host = @options.host
95
+ uri.scheme = @options.ssl ? 'https' : 'http'
96
+ uri.port = @options.port
97
+ uri.path = @options.path
98
+
99
+ uri.to_s
96
100
  end
97
101
  end
98
102
 
@@ -109,8 +113,7 @@ module OmniAuth
109
113
  service_url = Addressable::URI.parse( service_url )
110
114
  service_url.query_values = service_url.query_values.tap { |qs| qs.delete('ticket') }
111
115
 
112
- # cas_host + append_params(@options.service_validate_url, { :service => service_url.to_s, :ticket => ticket })
113
- cas_host + append_params(@options.service_validate_url, { :service => service_url.to_s, :ticket => ticket })
116
+ cas_url + append_params(@options.service_validate_url, { :service => service_url.to_s, :ticket => ticket })
114
117
  end
115
118
 
116
119
  # Build a CAS login URL from +service+.
@@ -119,7 +122,7 @@ module OmniAuth
119
122
  #
120
123
  # @return [String] a URL like `http://cas.mycompany.com/login?service=...`
121
124
  def login_url(service)
122
- cas_host + append_params( @options.login_url, { :service => service })
125
+ cas_url + append_params( @options.login_url, { :service => service })
123
126
  end
124
127
 
125
128
  # Adds URL-escaped +parameters+ to +base+.
@@ -141,7 +144,7 @@ module OmniAuth
141
144
  # Deletes Hash pairs with `nil` values.
142
145
  # From https://github.com/mkdynamic/omniauth-facebook/blob/972ed5e3456bcaed7df1f55efd7c05c216c8f48e/lib/omniauth/strategies/facebook.rb#L122-127
143
146
  def prune!(hash)
144
- hash.delete_if do |_, value|
147
+ hash.delete_if do |_, value|
145
148
  prune!(value) if value.is_a?(Hash)
146
149
  value.nil? || (value.respond_to?(:empty?) && value.empty?)
147
150
  end
@@ -17,6 +17,7 @@ module OmniAuth
17
17
  @options.merge!(
18
18
  'host' => url.host,
19
19
  'port' => url.port,
20
+ 'path' => url.path,
20
21
  'ssl' => url.scheme == 'https'
21
22
  )
22
23
  end
@@ -1,3 +1,5 @@
1
+ require 'spec_helper'
2
+
1
3
  describe OmniAuth::Strategies::CAS::Configuration do
2
4
  subject { described_class.new }
3
5
 
@@ -13,7 +15,7 @@ describe OmniAuth::Strategies::CAS::Configuration do
13
15
  describe '#initialize' do
14
16
  let(:params) do
15
17
  {
16
- 'url' => 'http://example.org:8080',
18
+ 'url' => 'http://example.org:8080/my_cas',
17
19
  'login_url' => '/'
18
20
  }
19
21
  end
@@ -31,6 +33,7 @@ describe OmniAuth::Strategies::CAS::Configuration do
31
33
  it 'should parse the URL' do
32
34
  subject.host.should eq 'example.org'
33
35
  subject.port.should eq 8080
36
+ subject.path.should eq '/my_cas'
34
37
  subject.ssl.should be_false
35
38
  end
36
39
  end
@@ -1,3 +1,5 @@
1
+ require 'spec_helper'
2
+
1
3
  describe OmniAuth::Strategies::CAS::ServiceTicketValidator do
2
4
  let(:strategy_stub) do
3
5
  stub('strategy stub',
@@ -1,3 +1,5 @@
1
+ require 'spec_helper'
2
+
1
3
  describe OmniAuth::Strategies::CAS, type: :strategy do
2
4
  include Rack::Test::Methods
3
5
 
@@ -5,7 +7,7 @@ describe OmniAuth::Strategies::CAS, type: :strategy do
5
7
  def app
6
8
  Rack::Builder.new {
7
9
  use OmniAuth::Test::PhonySession
8
- use MyCasProvider, name: :cas, host: 'cas.example.org', uid_key: :employeeid
10
+ use MyCasProvider, name: :cas, host: 'cas.example.org', ssl: false, port: 8080, uid_key: :employeeid
9
11
  run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] }
10
12
  }.to_app
11
13
  end
@@ -21,10 +23,15 @@ describe OmniAuth::Strategies::CAS, type: :strategy do
21
23
  it { should be_redirect }
22
24
 
23
25
  it 'should redirect to the CAS server' do
24
- subject.headers['Location'].should == 'https://cas.example.org/login?' + redirect_params
26
+ subject.headers['Location'].should == 'http://cas.example.org:8080/login?' + redirect_params
25
27
  end
26
28
  end
27
29
 
30
+ describe 'defaults' do
31
+ subject { MyCasProvider.default_options.to_hash }
32
+ it { should include('ssl' => true) }
33
+ end
34
+
28
35
  describe 'GET /auth/cas' do
29
36
  let(:return_url) { 'http://myapp.com/admin/foo' }
30
37
 
@@ -59,7 +66,7 @@ describe OmniAuth::Strategies::CAS, type: :strategy do
59
66
 
60
67
  describe 'GET /auth/cas/callback with an invalid ticket' do
61
68
  before do
62
- stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=9391d/).
69
+ stub_request(:get, /^http:\/\/cas.example.org:8080?\/serviceValidate\?([^&]+&)?ticket=9391d/).
63
70
  to_return( body: File.read('spec/fixtures/cas_failure.xml') )
64
71
  get '/auth/cas/callback?ticket=9391d'
65
72
  end
@@ -77,7 +84,7 @@ describe OmniAuth::Strategies::CAS, type: :strategy do
77
84
  let(:return_url) { 'http://127.0.0.10/?some=parameter' }
78
85
 
79
86
  before do
80
- stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=593af/)
87
+ stub_request(:get, /^http:\/\/cas.example.org:8080?\/serviceValidate\?([^&]+&)?ticket=593af/)
81
88
  .with { |request| @request_uri = request.uri.to_s }
82
89
  .to_return( body: File.read('spec/fixtures/cas_success.xml') )
83
90
 
@@ -89,7 +96,7 @@ describe OmniAuth::Strategies::CAS, type: :strategy do
89
96
  end
90
97
 
91
98
  it 'should properly encode the service URL' do
92
- WebMock.should have_requested(:get, 'https://cas.example.org/serviceValidate')
99
+ WebMock.should have_requested(:get, 'http://cas.example.org:8080/serviceValidate')
93
100
  .with(query: {
94
101
  ticket: '593af',
95
102
  service: 'http://example.org/auth/cas/callback?url=' + Rack::Utils.escape('http://127.0.0.10/?some=parameter')
@@ -143,4 +150,4 @@ describe OmniAuth::Strategies::CAS, type: :strategy do
143
150
  end
144
151
  end
145
152
 
146
- end
153
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-cas
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Derek Lindahl
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-10 00:00:00.000000000 Z
11
+ date: 2013-06-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: omniauth
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: nokogiri
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: addressable
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: webmock
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: simplecov
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rspec
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -126,7 +111,6 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: rack-test
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
115
  - - ~>
132
116
  - !ruby/object:Gem::Version
@@ -134,7 +118,6 @@ dependencies:
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
122
  - - ~>
140
123
  - !ruby/object:Gem::Version
@@ -142,7 +125,6 @@ dependencies:
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: awesome_print
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
129
  - - ! '>='
148
130
  - !ruby/object:Gem::Version
@@ -150,7 +132,6 @@ dependencies:
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
136
  - - ! '>='
156
137
  - !ruby/object:Gem::Version
@@ -185,33 +166,26 @@ files:
185
166
  - spec/spec_helper.rb
186
167
  homepage: https://github.com/dlindahl/omniauth-cas
187
168
  licenses: []
169
+ metadata: {}
188
170
  post_install_message:
189
171
  rdoc_options: []
190
172
  require_paths:
191
173
  - lib
192
174
  required_ruby_version: !ruby/object:Gem::Requirement
193
- none: false
194
175
  requirements:
195
176
  - - ! '>='
196
177
  - !ruby/object:Gem::Version
197
178
  version: '0'
198
- segments:
199
- - 0
200
- hash: 3594521613564365784
201
179
  required_rubygems_version: !ruby/object:Gem::Requirement
202
- none: false
203
180
  requirements:
204
181
  - - ! '>='
205
182
  - !ruby/object:Gem::Version
206
183
  version: '0'
207
- segments:
208
- - 0
209
- hash: 3594521613564365784
210
184
  requirements: []
211
185
  rubyforge_project:
212
- rubygems_version: 1.8.24
186
+ rubygems_version: 2.0.3
213
187
  signing_key:
214
- specification_version: 3
188
+ specification_version: 4
215
189
  summary: CAS Strategy for OmniAuth
216
190
  test_files:
217
191
  - spec/fixtures/cas_failure.xml