omniauth-shibboleth 1.2.0 → 1.2.1

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
2
  SHA1:
3
- metadata.gz: cbc1910339ca687b35d3e2120072009e39dca66a
4
- data.tar.gz: 60215822a0ac07502b0dcee32545d18c0e2dc160
3
+ metadata.gz: 522260d787eef76c5a8ff86890b001ecf2f6b524
4
+ data.tar.gz: e118c60297ee37d49f279a2836f54a94933143b5
5
5
  SHA512:
6
- metadata.gz: f58cc5c54b07a092f15984b1aa6290d21a7271c4e16933b2d0b6b99639bf8881a1ffe9a03503083be69f8f834bf27c9b843d3c9e52b8bc9a217fe485c2703a3d
7
- data.tar.gz: 2b29dcaa1c212ad9b6825b184b1ba766626685d3212daaa1afe7805c9898b6590a7c9df5e62be68bfb874e3e74caa566d651b174e6f9ed124cac0d8a02cd94ed
6
+ metadata.gz: c143be18e00484f679d4e08c4cd56eeb2c58ea8d5651634a8e35159bb4b9aa03836aa83e906a338d1e458132397b88dc465a9dd07a47fe516e4f828500e5f083
7
+ data.tar.gz: a136b0b97c1299535f9d06bf96bb27869f96fd35b5d5ab7318b304e3c9b44c11ee3948a5b43b67de13e2926c1adfa625d136fecc179e31a0a10c7876a4f05653
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-shibboleth (1.2.0)
5
+ omniauth (>= 1.0.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.2.5)
11
+ hashie (3.4.1)
12
+ omniauth (1.2.2)
13
+ hashie (>= 1.2, < 4)
14
+ rack (~> 1.0)
15
+ rack (1.6.1)
16
+ rack-test (0.6.3)
17
+ rack (>= 1.0)
18
+ rake (10.4.2)
19
+ rspec (3.2.0)
20
+ rspec-core (~> 3.2.0)
21
+ rspec-expectations (~> 3.2.0)
22
+ rspec-mocks (~> 3.2.0)
23
+ rspec-core (3.2.3)
24
+ rspec-support (~> 3.2.0)
25
+ rspec-expectations (3.2.1)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.2.0)
28
+ rspec-mocks (3.2.1)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.2.0)
31
+ rspec-support (3.2.2)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ omniauth-shibboleth!
38
+ rack-test
39
+ rake
40
+ rspec (>= 2.8)
41
+
42
+ BUNDLED WITH
43
+ 1.10.2
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # OmniAuth Shibboleth strategy
2
2
 
3
+ [![Gem Version](http://img.shields.io/gem/v/omniauth-shibboleth.svg)](http://rubygems.org/gems/omniauth-shibboleth)
4
+ [![Build Status](https://travis-ci.org/toyokazu/omniauth-shibboleth.svg?branch=master)](https://travis-ci.org/toyokazu/omniauth-shibboleth)
5
+
3
6
  OmniAuth Shibboleth strategy is an OmniAuth strategy for authenticating through Shibboleth (SAML). If you do not know OmniAuth, please visit OmniAuth wiki.
4
7
 
5
8
  https://github.com/intridea/omniauth/wiki
@@ -29,6 +32,11 @@ https://github.com/toyokazu/omniauth-shibboleth/issues
29
32
 
30
33
  To use OmniAuth Shibboleth strategy as a middleware in your rails application, add the following file to your rails application initializer directory.
31
34
 
35
+ % vi config/initializer/omniauth.rb
36
+ Rails.application.config.middleware.use OmniAuth::Builder do
37
+ provider :shibboleth
38
+ end
39
+
32
40
  % vi config/initializer/omniauth.rb
33
41
  Rails.application.config.middleware.use OmniAuth::Builder do
34
42
  provider :shibboleth, {
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Shibboleth
3
- VERSION = "1.2.0"
3
+ VERSION = "1.2.1"
4
4
  end
5
5
  end
@@ -10,6 +10,7 @@ module OmniAuth
10
10
  option :info_fields, {}
11
11
  option :extra_fields, []
12
12
  option :debug, false
13
+ option :fail_with_empty_uid, false
13
14
  option :request_type, :env
14
15
 
15
16
  def request_phase
@@ -55,6 +56,7 @@ module OmniAuth
55
56
  ]
56
57
  end
57
58
  return fail!(:no_shibboleth_session) unless (request_param(options.shib_session_id_field.to_s) || request_param(options.shib_application_id_field.to_s))
59
+ return fail!(:empty_uid) if options[:fail_with_empty_uid] && option_handler(options.uid_field).empty?
58
60
  super
59
61
  end
60
62
 
@@ -10,7 +10,7 @@ def make_env(path = '/auth/shibboleth', props = {})
10
10
  }.merge(props)
11
11
  end
12
12
 
13
- def failure_path
13
+ def without_session_failure_path
14
14
  if OmniAuth::VERSION >= "1.0" && OmniAuth::VERSION < "1.1"
15
15
  "/auth/failure?message=no_shibboleth_session"
16
16
  elsif OmniAuth::VERSION >= "1.1"
@@ -18,6 +18,14 @@ def failure_path
18
18
  end
19
19
  end
20
20
 
21
+ def empty_uid_failure_path
22
+ if OmniAuth::VERSION >= "1.0" && OmniAuth::VERSION < "1.1"
23
+ "/auth/failure?message=empty_uid"
24
+ elsif OmniAuth::VERSION >= "1.1"
25
+ "/auth/failure?message=empty_uid&strategy=shibboleth"
26
+ end
27
+ end
28
+
21
29
  describe OmniAuth::Strategies::Shibboleth do
22
30
  let(:app){ Rack::Builder.new do |b|
23
31
  b.use Rack::Session::Cookie, {:secret => "abc123"}
@@ -44,7 +52,7 @@ describe OmniAuth::Strategies::Shibboleth do
44
52
 
45
53
  it 'is expected to fail to get Shib-Session-ID environment variable' do
46
54
  expect(last_response.status).to eq(302)
47
- expect(last_response.location).to eq(failure_path)
55
+ expect(last_response.location).to eq(without_session_failure_path)
48
56
  end
49
57
  end
50
58
 
@@ -68,7 +76,6 @@ describe OmniAuth::Strategies::Shibboleth do
68
76
  :shib_application_id_field => 'Shib-Application-ID',
69
77
  :uid_field => :uid,
70
78
  :name_field => :sn,
71
- #:name_field => :displayName,
72
79
  :info_fields => {},
73
80
  :extra_fields => [:o, :affiliation] } }
74
81
  let(:app){ lambda{|env| [404, {}, ['Not Found']]}}
@@ -233,5 +240,48 @@ describe OmniAuth::Strategies::Shibboleth do
233
240
  expect(strategy.env['omniauth.auth']['extra']['raw_info']['affiliation']).to eq(@affiliation)
234
241
  end
235
242
  end
243
+
244
+ context 'empty uid with :fail_with_empty_uid = false' do
245
+ let(:options){ {
246
+ :request_type => :env,
247
+ :fail_with_empty_uid => false,
248
+ :uid_field => :uid,
249
+ :name_field => :displayName,
250
+ :info_fields => {} } }
251
+ let(:app){ lambda{|env| [200, {}, ['OK']]}}
252
+ let(:strategy){ OmniAuth::Strategies::Shibboleth.new(app, options) }
253
+
254
+ it 'is expected to output null (empty) uid as it is' do
255
+ @dummy_id = 'abcdefg'
256
+ @display_name = 'Test User'
257
+ @uid = ''
258
+ env = make_env('/auth/shibboleth/callback', 'Shib-Session-ID' => @dummy_id, 'uid' => @uid, 'displayName' => @display_name)
259
+ response = strategy.call!(env)
260
+ expect(strategy.env['omniauth.auth']['uid']).to eq(@uid)
261
+ end
262
+ end
263
+
264
+ context 'empty uid with :fail_with_empty_uid = true' do
265
+ let(:options){ {
266
+ :request_type => :env,
267
+ :fail_with_empty_uid => true,
268
+ :shib_session_id_field => 'Shib-Session-ID',
269
+ :shib_application_id_field => 'Shib-Application-ID',
270
+ :uid_field => :uid,
271
+ :name_field => :displayName,
272
+ :info_fields => {} } }
273
+ let(:app){ lambda{|env| [200, {}, ['OK']]}}
274
+ let(:strategy){ OmniAuth::Strategies::Shibboleth.new(app, options) }
275
+
276
+ it 'is expected to fail because of the empty uid' do
277
+ @dummy_id = 'abcdefg'
278
+ @display_name = 'Test User'
279
+ @uid = ''
280
+ env = make_env('/auth/shibboleth/callback', 'Shib-Session-ID' => @dummy_id, 'uid' => @uid, 'displayName' => @display_name)
281
+ response = strategy.call!(env)
282
+ expect(response[0]).to eq(302)
283
+ expect(response[1]["Location"]).to eq(empty_uid_failure_path)
284
+ end
285
+ end
236
286
  end
237
287
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-shibboleth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toyokazu Akiyama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-08 00:00:00.000000000 Z
11
+ date: 2015-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -74,6 +74,7 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - Gemfile
77
+ - Gemfile.lock
77
78
  - README.md
78
79
  - Rakefile
79
80
  - lib/omniauth-shibboleth.rb
@@ -102,11 +103,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  version: '0'
103
104
  requirements: []
104
105
  rubyforge_project:
105
- rubygems_version: 2.3.0
106
+ rubygems_version: 2.4.5
106
107
  signing_key:
107
108
  specification_version: 4
108
109
  summary: OmniAuth Shibboleth strategies for OmniAuth 1.x
109
110
  test_files:
110
111
  - spec/omniauth/strategies/shibboleth_spec.rb
111
112
  - spec/spec_helper.rb
112
- has_rdoc: