omniauth-cas 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 09cce5081c4f84323fdc73cc34324fd597d78424
4
- data.tar.gz: 9a70b93dee51a38340bd07630f83179992f254b1
2
+ SHA256:
3
+ metadata.gz: 20d02177b4bdbd637993a8d225133ada4d6d40092b59db98e54b38bbe8aef780
4
+ data.tar.gz: 9143ccd826882b5f1228b7686958cfa62c9527ab1fef041d6ce1bfb39e7e0f6d
5
5
  SHA512:
6
- metadata.gz: 436b7b6a87016de8dd0b4c0e8d89697a5570f17d88662bd73b1ee407f9edb3cf8b058d523c1863e5ecaef9aba9ebaf3c52457005119a547398f7fb761f4949a0
7
- data.tar.gz: d2e434a790244adbe2c83fdfc9900785acbf48f3f9592911a580ce3fefa35eca3e8561906898c4c134895fbcd6614ce2f019ecada702cf56d9a1a453ef9b8457
6
+ metadata.gz: a9edd4d3c46a7c7349a0ebf05a67747cb25cfda51fc2c4ebfbc054726e4e8b7034f969291f5f184d609999250507bdfe1da01f659cb43682b837d4fa44292271
7
+ data.tar.gz: e64e3311e11537b2abc77d25189ef38eebdcbb147eb6db53deb7562530371f40851e035eae08370f3621843873c36c47e9690d1e5f2a0678b31ea8dd87f79bca
@@ -1,9 +1,21 @@
1
+ dist: xenial
2
+ os: linux
3
+ language: ruby
1
4
  rvm:
2
5
  - 2.1
3
6
  - 2.2
4
- - 2.3.1
7
+ - 2.3
8
+ - 2.4
9
+ - 2.5
10
+ - 2.6
11
+ - 2.7
12
+ - ruby-edge
5
13
  branches:
6
14
  only:
7
15
  - master
8
16
  before_install:
9
- - gem install bundler
17
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
18
+ - gem install bundler -v '< 2'
19
+ jobs:
20
+ allow_failures:
21
+ - rvm: ruby-edge
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/) and this
6
6
  project adheres to [Semantic Versioning](http://semver.org/)
7
7
 
8
+ ## 2.0.0 - 2010-11-14
9
+
10
+ ### Added
11
+
12
+ * Add support for multivalued attributes ([#59](https://github.com/dlindahl/omniauth-cas/pull/59))
13
+ * Successfully test against Ruby 2.4 and up ([#60](https://github.com/dlindahl/omniauth-cas/pull/60))
14
+
15
+ ### Changed
16
+
17
+ * Forward success response to `fetch_raw_info` callback ([#51](https://github.com/dlindahl/omniauth-cas/pull/51))
18
+ * Relax development dependencies to the latest versions
19
+
8
20
  ## 1.1.1 - 2016-09-19
9
21
 
10
22
  ### Changed
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
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
5
- [travis]: http://travis-ci.org/dlindahl/omniauth-cas
6
- [travis_status]: https://secure.travis-ci.org/dlindahl/omniauth-cas.png
3
+ [version_badge]: https://badge.fury.io/rb/omniauth-cas.svg
4
+ [version]: https://badge.fury.io/rb/omniauth-cas
5
+ [travis]: https://travis-ci.org/dlindahl/omniauth-cas
6
+ [travis_status]: https://secure.travis-ci.org/dlindahl/omniauth-cas.svg
7
7
  [releases]: https://github.com/dlindahl/omniauth-cas/releases
8
8
 
9
9
  This is a OmniAuth 1.0 compatible port of the previously available
@@ -58,6 +58,7 @@ Other configuration options:
58
58
  * `uid_field` - The user data attribute to use as your user's unique identifier. Defaults to `'user'` (which usually contains the user's login name).
59
59
  * `ca_path` - Optional when `ssl` is `true`. Sets path of a CA certification directory. See [Net::HTTP][net_http] for more details.
60
60
  * `disable_ssl_verification` - Optional when `ssl` is true. Disables verification.
61
+ * `merge_multivalued_attributes` - When set to `true` returns attributes with multiple values as arrays. Defaults to `false` and returns the last value as a string.
61
62
  * `on_single_sign_out` - Optional. Callback used when a [CAS 3.1 Single Sign Out][sso]
62
63
  request is received.
63
64
  * `fetch_raw_info` - Optional. Callback used to return additional "raw" user
@@ -65,9 +66,13 @@ Other configuration options:
65
66
 
66
67
  ```ruby
67
68
  provider :cas,
68
- fetch_raw_info: lambda { |strategy, options, ticket, user_info|
69
- ExternalService.get(user_info[:user]).attributes
70
- }
69
+ fetch_raw_info: Proc.new { |strategy, opts, ticket, user_info, rawxml|
70
+ return {} if user_info.empty? || rawxml.nil? # Auth failed
71
+
72
+ extra_info = ExternalService.get(user_info[:user]).attributes
73
+ extra_info.merge!({'roles' => rawxml.xpath('//cas:roles').map(&:text)})
74
+ extra_info
75
+ }
71
76
  ```
72
77
 
73
78
  Configurable options for values returned by CAS:
@@ -118,6 +123,6 @@ Special thanks go out to the following people
118
123
  * @rbq for README updates and OmniAuth 0.3 migration guide
119
124
 
120
125
  [old_omniauth_cas]: https://github.com/intridea/omniauth/blob/0-3-stable/oa-enterprise/lib/omniauth/strategies/cas.rb
121
- [document_up]: http://dlindahl.github.com/omniauth-cas/
122
- [net_http]: http://ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html
126
+ [document_up]: https://dlindahl.github.io/omniauth-cas/
127
+ [net_http]: https://ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html
123
128
  [sso]: https://wiki.jasig.org/display/CASUM/Single+Sign+Out
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Cas
3
- VERSION = '1.1.1'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
@@ -22,6 +22,7 @@ module OmniAuth
22
22
  option :port, nil
23
23
  option :path, nil
24
24
  option :ssl, true
25
+ option :merge_multivalued_attributes, false
25
26
  option :service_validate_url, '/serviceValidate'
26
27
  option :login_url, '/login'
27
28
  option :logout_url, '/logout'
@@ -189,8 +190,11 @@ module OmniAuth
189
190
  private
190
191
 
191
192
  def fetch_raw_info(ticket)
192
- ticket_user_info = validate_service_ticket(ticket).user_info
193
- custom_user_info = options.fetch_raw_info.call(self, options, ticket, ticket_user_info)
193
+ validator = validate_service_ticket(ticket)
194
+ ticket_user_info = validator.user_info
195
+ ticket_success_body = validator.success_body
196
+ custom_user_info = options.fetch_raw_info.call(self,
197
+ options, ticket, ticket_user_info, ticket_success_body)
194
198
  self.raw_info = ticket_user_info.merge(custom_user_info)
195
199
  end
196
200
 
@@ -8,6 +8,8 @@ module OmniAuth
8
8
  class ServiceTicketValidator
9
9
  VALIDATION_REQUEST_HEADERS = { 'Accept' => '*/*' }
10
10
 
11
+ attr_reader :success_body
12
+
11
13
  # Build a validator from a +configuration+, a
12
14
  # +return_to+ URL, and a +ticket+.
13
15
  #
@@ -40,6 +42,16 @@ module OmniAuth
40
42
 
41
43
  private
42
44
 
45
+ # Merges attributes with multiple values into an array if support is
46
+ # enabled (disabled by default)
47
+ def attribute_value(user_info, attribute, value)
48
+ if @options.merge_multivalued_attributes && user_info.key?(attribute)
49
+ Array(user_info[attribute]).push(value)
50
+ else
51
+ value
52
+ end
53
+ end
54
+
43
55
  # turns an `<cas:authenticationSuccess>` node into a Hash;
44
56
  # returns nil if given nil
45
57
  def parse_user_info(node)
@@ -50,7 +62,7 @@ module OmniAuth
50
62
  unless e.kind_of?(Nokogiri::XML::Text) || node_name == 'proxies'
51
63
  # There are no child elements
52
64
  if e.element_children.count == 0
53
- hash[node_name] = e.content
65
+ hash[node_name] = attribute_value(hash, node_name, e.content)
54
66
  elsif e.element_children.count
55
67
  # JASIG style extra attributes
56
68
  if node_name == 'attributes'
@@ -19,10 +19,10 @@ Gem::Specification.new do |gem|
19
19
  gem.add_dependency 'nokogiri', '~> 1.5'
20
20
  gem.add_dependency 'addressable', '~> 2.3'
21
21
 
22
- gem.add_development_dependency 'rake', '~> 10.0'
23
- gem.add_development_dependency 'webmock', '~> 1.19.0'
24
- gem.add_development_dependency 'rspec', '~> 3.1.0'
25
- gem.add_development_dependency 'rack-test', '~> 0.6'
22
+ gem.add_development_dependency 'rake'
23
+ gem.add_development_dependency 'webmock'
24
+ gem.add_development_dependency 'rspec'
25
+ gem.add_development_dependency 'rack-test'
26
26
 
27
27
  gem.add_development_dependency 'awesome_print'
28
28
  end
@@ -10,5 +10,8 @@
10
10
  <cas:image>/images/user.jpg</cas:image>
11
11
  <cas:phone>555-555-5555</cas:phone>
12
12
  <cas:hire_date>2004-07-13</cas:hire_date>
13
+ <cas:roles>senator</cas:roles>
14
+ <cas:roles>lobbyist</cas:roles>
15
+ <cas:roles>financier</cas:roles>
13
16
  </cas:authenticationSuccess>
14
17
  </cas:serviceResponse>
@@ -11,6 +11,9 @@
11
11
  <cas:image>/images/user.jpg</cas:image>
12
12
  <cas:phone>555-555-5555</cas:phone>
13
13
  <cas:hire_date>2004-07-13</cas:hire_date>
14
+ <cas:roles>senator</cas:roles>
15
+ <cas:roles>lobbyist</cas:roles>
16
+ <cas:roles>financier</cas:roles>
14
17
  </cas:attributes>
15
18
  </cas:authenticationSuccess>
16
19
  </cas:serviceResponse>
@@ -58,12 +58,14 @@ describe OmniAuth::Strategies::CAS::LogoutRequest do
58
58
  { on_single_sign_out: callback }
59
59
  end
60
60
 
61
+ let(:response_body) { subject[2].respond_to?(:body) ? subject[2].body : subject[2] }
62
+
61
63
  context 'that returns TRUE' do
62
64
  let(:callback) { Proc.new{true} }
63
65
 
64
66
  it 'responds with OK' do
65
67
  expect(subject[0]).to eq 200
66
- expect(subject[2].body).to eq ['OK']
68
+ expect(response_body).to eq ['OK']
67
69
  end
68
70
  end
69
71
 
@@ -72,7 +74,7 @@ describe OmniAuth::Strategies::CAS::LogoutRequest do
72
74
 
73
75
  it 'responds with OK' do
74
76
  expect(subject[0]).to eq 200
75
- expect(subject[2].body).to eq ['OK']
77
+ expect(response_body).to eq ['OK']
76
78
  end
77
79
  end
78
80
 
@@ -81,7 +83,7 @@ describe OmniAuth::Strategies::CAS::LogoutRequest do
81
83
 
82
84
  it 'responds with OK' do
83
85
  expect(subject[0]).to eq 400
84
- expect(subject[2].body).to eq ['Bad Request']
86
+ expect(response_body).to eq ['Bad Request']
85
87
  end
86
88
  end
87
89
 
@@ -9,6 +9,7 @@ describe OmniAuth::Strategies::CAS::ServiceTicketValidator do
9
9
  let(:provider_options) do
10
10
  double('provider_options',
11
11
  disable_ssl_verification?: false,
12
+ merge_multivalued_attributes: false,
12
13
  ca_path: '/etc/ssl/certsZOMG'
13
14
  )
14
15
  end
@@ -48,8 +49,26 @@ describe OmniAuth::Strategies::CAS::ServiceTicketValidator do
48
49
 
49
50
  subject { validator.user_info }
50
51
 
51
- it 'parses user info from the response' do
52
- expect(subject).to include 'user' => 'psegel'
52
+ context 'with default settings' do
53
+ it 'parses user info from the response' do
54
+ expect(subject).to include 'user' => 'psegel'
55
+ expect(subject).to include 'roles' => 'financier'
56
+ end
57
+ end
58
+
59
+ context 'when merging multivalued attributes' do
60
+ let(:provider_options) do
61
+ double('provider_options',
62
+ disable_ssl_verification?: false,
63
+ merge_multivalued_attributes: true,
64
+ ca_path: '/etc/ssl/certsZOMG'
65
+ )
66
+ end
67
+
68
+ it 'parses multivalued user info from the response' do
69
+ expect(subject).to include 'user' => 'psegel'
70
+ expect(subject).to include 'roles' => %w[senator lobbyist financier]
71
+ end
53
72
  end
54
73
  end
55
74
  end
@@ -10,7 +10,17 @@ describe OmniAuth::Strategies::CAS, type: :strategy do
10
10
  let(:app) do
11
11
  Rack::Builder.new {
12
12
  use OmniAuth::Test::PhonySession
13
- use MyCasProvider, name: :cas, host: 'cas.example.org', ssl: false, port: 8080, uid_field: :employeeid
13
+ use MyCasProvider,
14
+ name: :cas,
15
+ host: 'cas.example.org',
16
+ ssl: false,
17
+ port: 8080,
18
+ uid_field: :employeeid,
19
+ fetch_raw_info: Proc.new { |v, opts, ticket, info, node|
20
+ info.empty? ? {} : {
21
+ "roles" => node.xpath('//cas:roles').map(&:text),
22
+ }
23
+ }
14
24
  run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] }
15
25
  }.to_app
16
26
  end
@@ -184,6 +194,7 @@ describe OmniAuth::Strategies::CAS, type: :strategy do
184
194
  expect(subject.user).to eq 'psegel'
185
195
  expect(subject.employeeid).to eq '54'
186
196
  expect(subject.hire_date).to eq '2004-07-13'
197
+ expect(subject.roles).to eq %w(senator lobbyist financier)
187
198
  end
188
199
  end
189
200
 
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.1.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Lindahl
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-26 00:00:00.000000000 Z
11
+ date: 2020-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -56,58 +56,58 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 1.19.0
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 1.19.0
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 3.1.0
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 3.1.0
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rack-test
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '0.6'
103
+ version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '0.6'
110
+ version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: awesome_print
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -131,7 +131,6 @@ extra_rdoc_files: []
131
131
  files:
132
132
  - ".editorconfig"
133
133
  - ".gitignore"
134
- - ".ruby-version"
135
134
  - ".travis.yml"
136
135
  - CHANGELOG.md
137
136
  - Gemfile
@@ -155,7 +154,7 @@ files:
155
154
  homepage: https://github.com/dlindahl/omniauth-cas
156
155
  licenses: []
157
156
  metadata: {}
158
- post_install_message:
157
+ post_install_message:
159
158
  rdoc_options: []
160
159
  require_paths:
161
160
  - lib
@@ -170,9 +169,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
169
  - !ruby/object:Gem::Version
171
170
  version: '0'
172
171
  requirements: []
173
- rubyforge_project:
174
- rubygems_version: 2.2.2
175
- signing_key:
172
+ rubygems_version: 3.1.3
173
+ signing_key:
176
174
  specification_version: 4
177
175
  summary: CAS Strategy for OmniAuth
178
176
  test_files:
@@ -1 +0,0 @@
1
- 2.1.2