omniauth-cas 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDMxYjQ1ZmY1NjAyNGMzOTMyZDE1MTlkNzVjNGIxOTA3YzdjNDNhOQ==
4
+ OTU0MmMyOWM1MWY0YzBiNjMzZDRkZmE4NTljYTA4NTc3M2NmM2FiYg==
5
5
  data.tar.gz: !binary |-
6
- YzhjYTZiMDY2NDhhMWMxMjA2ZDA0M2QxNDUyMTY3MzE4MWZmN2I1MQ==
6
+ YjM4MmU1MTAwNThmNjJkNWU2OTJiZjJiMTc5ZDNlYjM0ZDQ2M2E3ZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTEzYmQ2NTA3NGRlNjBhZjAxNGYwM2U4N2Y3ZDE0YzlhMmM0ZDRmYWRlZTky
10
- MTBlNmI4ZmYwZDU3NTU4MjZmMWY1MjZmNjEwZWQyNGI3ZGJiOTZjMjZlNGVm
11
- YmI5YzIyNTE0YzUzN2FlMGJlZDkzZjFhZTE3NDZiYmFmNzQ5MmM=
9
+ ZTdkZjEzMDY4ODVjMzY1NDQ2MmUxZTAyMzRkMGUwNzcxYzAyOGM5MzBlNDZi
10
+ ZjU1OTk0OWU1ODIzNTIwYTIxNWM5ZDEzNzFiY2UyODJhYzY3NDRkZmM5ODcy
11
+ NTBlMGM5YWFhZWU1MDBlMTI2YWQ0NTRmODRkZjhiYmVmMjc2ZDI=
12
12
  data.tar.gz: !binary |-
13
- YmZlZDFmMWM0ZjE2ODExY2U4ZGU0YzBiY2U1OGVkMWQzM2ZlMzViODc0NzJj
14
- NmQ2ZTc4MjAxZTllYzE5YTlmNmJlNTE4ZGRmNjlmOGVhYzc3MTFlZjQ3Nzcy
15
- NzRhMjhiNTg5ZGVmY2EyYmZhNGExZWZiODE0ZWY1ZjkzMGY2NWQ=
13
+ OTY0NjU1NTFhZGZmNjdlN2E2OTY5MjNkMTU0NDY5NWQ1ZjQ3N2RiZWFjNmZj
14
+ MDA3MmY4M2U1MjMwOThkZmRhNzYwZDI5NzljYjRiYzk5YjY5MWFlNjBjYjY0
15
+ NzBhNjE1OWViZjMzMGVmYzkzMWM5MTk5MGNmNjk1MTU3YjYxYWU=
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Cas
3
- VERSION = '1.0.3'
3
+ VERSION = '1.0.4'
4
4
  end
5
5
  end
@@ -41,15 +41,20 @@ module OmniAuth
41
41
 
42
42
  {}.tap do |hash|
43
43
  node.children.each do |e|
44
+ node_name = e.name.sub(/^cas:/, '')
44
45
  unless e.kind_of?(Nokogiri::XML::Text) ||
45
- e.name == 'cas:proxies' ||
46
- e.name == 'proxies'
46
+ node_name == 'proxies'
47
47
  # There are no child elements
48
48
  if e.element_children.count == 0
49
- hash[e.name.sub(/^cas:/, '')] = e.content
49
+ hash[node_name] = e.content
50
50
  elsif e.element_children.count
51
- hash[e.name.sub(/^cas:/, '')] = [] if hash[e.name.sub(/^cas:/, '')].nil?
52
- hash[e.name.sub(/^cas:/, '')].push parse_user_info e
51
+ # JASIG style extra attributes
52
+ if node_name == 'attributes'
53
+ hash.merge! parse_user_info e
54
+ else
55
+ hash[node_name] = [] if hash[node_name].nil?
56
+ hash[node_name].push parse_user_info e
57
+ end
53
58
  end
54
59
  end
55
60
  end
@@ -0,0 +1,16 @@
1
+ <cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
2
+ <cas:authenticationSuccess>
3
+ <cas:user>psegel</cas:user>
4
+ <cas:attributes>
5
+ <cas:employeeid>54</cas:employeeid>
6
+ <cas:first_name>P. Segel</cas:first_name>
7
+ <cas:first_name>Peter</cas:first_name>
8
+ <cas:last_name>Segel</cas:last_name>
9
+ <cas:email>psegel@intridea.com</cas:email>
10
+ <cas:location>Washington, D.C.</cas:location>
11
+ <cas:image>/images/user.jpg</cas:image>
12
+ <cas:phone>555-555-5555</cas:phone>
13
+ <cas:hire_date>2004-07-13</cas:hire_date>
14
+ </cas:attributes>
15
+ </cas:authenticationSuccess>
16
+ </cas:serviceResponse>
@@ -81,72 +81,84 @@ describe OmniAuth::Strategies::CAS, type: :strategy do
81
81
  end
82
82
 
83
83
  describe 'GET /auth/cas/callback with a valid ticket' do
84
- let(:return_url) { 'http://127.0.0.10/?some=parameter' }
84
+ shared_examples :successful_validation do
85
+ before do
86
+ stub_request(:get, /^http:\/\/cas.example.org:8080?\/serviceValidate\?([^&]+&)?ticket=593af/)
87
+ .with { |request| @request_uri = request.uri.to_s }
88
+ .to_return( body: File.read("spec/fixtures/#{xml_file_name}") )
85
89
 
86
- before do
87
- stub_request(:get, /^http:\/\/cas.example.org:8080?\/serviceValidate\?([^&]+&)?ticket=593af/)
88
- .with { |request| @request_uri = request.uri.to_s }
89
- .to_return( body: File.read('spec/fixtures/cas_success.xml') )
90
+ get "/auth/cas/callback?ticket=593af&url=#{return_url}"
91
+ end
90
92
 
91
- get "/auth/cas/callback?ticket=593af&url=#{return_url}"
92
- end
93
+ it 'should strip the ticket parameter from the callback URL' do
94
+ @request_uri.scan('ticket=').length.should == 1
95
+ end
93
96
 
94
- it 'should strip the ticket parameter from the callback URL' do
95
- @request_uri.scan('ticket=').length.should == 1
96
- end
97
+ it 'should properly encode the service URL' do
98
+ WebMock.should have_requested(:get, 'http://cas.example.org:8080/serviceValidate')
99
+ .with(query: {
100
+ ticket: '593af',
101
+ service: 'http://example.org/auth/cas/callback?url=' + Rack::Utils.escape('http://127.0.0.10/?some=parameter')
102
+ })
103
+ end
97
104
 
98
- it 'should properly encode the service URL' do
99
- WebMock.should have_requested(:get, 'http://cas.example.org:8080/serviceValidate')
100
- .with(query: {
101
- ticket: '593af',
102
- service: 'http://example.org/auth/cas/callback?url=' + Rack::Utils.escape('http://127.0.0.10/?some=parameter')
103
- })
104
- end
105
+ context "request.env['omniauth.auth']" do
106
+ subject { last_request.env['omniauth.auth'] }
105
107
 
106
- context "request.env['omniauth.auth']" do
107
- subject { last_request.env['omniauth.auth'] }
108
+ it { should be_kind_of Hash }
108
109
 
109
- it { should be_kind_of Hash }
110
+ its(:provider) { should == :cas }
110
111
 
111
- its(:provider) { should == :cas }
112
+ its(:uid) { should == '54'}
112
113
 
113
- its(:uid) { should == '54'}
114
+ context 'the info hash' do
115
+ subject { last_request.env['omniauth.auth']['info'] }
114
116
 
115
- context 'the info hash' do
116
- subject { last_request.env['omniauth.auth']['info'] }
117
+ it { should have(6).items }
117
118
 
118
- it { should have(6).items }
119
+ its(:name) { should == 'Peter Segel' }
120
+ its(:first_name) { should == 'Peter' }
121
+ its(:last_name) { should == 'Segel' }
122
+ its(:email) { should == 'psegel@intridea.com' }
123
+ its(:location) { should == 'Washington, D.C.' }
124
+ its(:image) { should == '/images/user.jpg' }
125
+ its(:phone) { should == '555-555-5555' }
126
+ end
119
127
 
120
- its(:name) { should == 'Peter Segel' }
121
- its(:first_name) { should == 'Peter' }
122
- its(:last_name) { should == 'Segel' }
123
- its(:email) { should == 'psegel@intridea.com' }
124
- its(:location) { should == 'Washington, D.C.' }
125
- its(:image) { should == '/images/user.jpg' }
126
- its(:phone) { should == '555-555-5555' }
127
- end
128
+ context 'the extra hash' do
129
+ subject { last_request.env['omniauth.auth']['extra'] }
128
130
 
129
- context 'the extra hash' do
130
- subject { last_request.env['omniauth.auth']['extra'] }
131
+ it { should have(3).items }
131
132
 
132
- it { should have(3).items }
133
+ its(:user) { should == 'psegel' }
134
+ its(:employeeid) { should == '54' }
135
+ its(:hire_date) { should == '2004-07-13' }
136
+ end
133
137
 
134
- its(:user) { should == 'psegel' }
135
- its(:employeeid) { should == '54' }
136
- its(:hire_date) { should == '2004-07-13' }
137
- end
138
+ context 'the credentials hash' do
139
+ subject { last_request.env['omniauth.auth']['credentials'] }
138
140
 
139
- context 'the credentials hash' do
140
- subject { last_request.env['omniauth.auth']['credentials'] }
141
+ it { should have(1).items }
141
142
 
142
- it { should have(1).items }
143
+ its(:ticket) { should == '593af' }
144
+ end
145
+ end
143
146
 
144
- its(:ticket) { should == '593af' }
147
+ it 'should call through to the master app' do
148
+ last_response.body.should == 'true'
145
149
  end
146
150
  end
147
151
 
148
- it 'should call through to the master app' do
149
- last_response.body.should == 'true'
152
+ let(:return_url) { 'http://127.0.0.10/?some=parameter' }
153
+
154
+ context 'with JASIG flavored XML' do
155
+ let(:xml_file_name) { 'cas_success_jasig.xml' }
156
+ it_behaves_like :successful_validation
157
+ end
158
+
159
+ context 'with classic XML' do
160
+ let(:xml_file_name) { 'cas_success.xml' }
161
+ it_behaves_like :successful_validation
150
162
  end
151
163
  end
152
164
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-cas
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Lindahl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-27 00:00:00.000000000 Z
11
+ date: 2013-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -160,6 +160,7 @@ files:
160
160
  - omniauth-cas.gemspec
161
161
  - spec/fixtures/cas_failure.xml
162
162
  - spec/fixtures/cas_success.xml
163
+ - spec/fixtures/cas_success_jasig.xml
163
164
  - spec/omniauth/strategies/cas/configuration_spec.rb
164
165
  - spec/omniauth/strategies/cas/service_ticket_validator_spec.rb
165
166
  - spec/omniauth/strategies/cas_spec.rb
@@ -190,6 +191,7 @@ summary: CAS Strategy for OmniAuth
190
191
  test_files:
191
192
  - spec/fixtures/cas_failure.xml
192
193
  - spec/fixtures/cas_success.xml
194
+ - spec/fixtures/cas_success_jasig.xml
193
195
  - spec/omniauth/strategies/cas/configuration_spec.rb
194
196
  - spec/omniauth/strategies/cas/service_ticket_validator_spec.rb
195
197
  - spec/omniauth/strategies/cas_spec.rb