omniauth-wsfed 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/.gitignore +3 -1
- data/.travis.yml +4 -1
- data/lib/omniauth-wsfed/version.rb +1 -1
- data/lib/omniauth/strategies/wsfed.rb +11 -13
- data/lib/omniauth/strategies/wsfed/auth_request.rb +21 -4
- data/spec/omniauth/strategies/wsfed/auth_request_spec.rb +80 -43
- data/spec/omniauth/strategies/wsfed_spec.rb +41 -15
- metadata +3 -4
- data/Gemfile.lock +0 -37
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDVjMGFmYjFiNmU3MjQxYjk1YmJiYjg4MmMzMTk5MmU0ZTJjZDdlZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzQwNjJmOWQ2MjU3OGQ1NjMwYjNiOGI1MWRkNWM1YTFjYTNhMDkyOQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTIwYjdjZDQwZWVlZjJkNDlmODc1MmRjMDc3ODU5Njk0YTg2YjQ0OTNjNDkz
|
10
|
+
YTY2ZDM5NjNkMjM3MmUzMTNkMDg3ZjM0YzMyMjJjOTIxN2UxNTIzZmYzYjJl
|
11
|
+
NmY1YjA5NjVlMDgxOTJjN2M0YTIzYzFmODg0Y2VlOTYwMzVkMzU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGZlNGRiMGQwYmNhNjMyYThkMGQwOTE3MjM3ZGJkMzhmNGY4Y2U3NzlmMjgy
|
14
|
+
MDk2YjEzOTE2YWFlNGM2NWM4YzAyNGY5ZjAzYzE0M2Q5ODJiOGRhNDFlYTIx
|
15
|
+
Yzg4MjE3MzQyZTI1YTQ0Yjk4NWRhOGRhZTQ4NDg5M2U2MDdlNzI=
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -14,23 +14,15 @@ module OmniAuth
|
|
14
14
|
|
15
15
|
# Issues passive WS-Federation redirect for authentication...
|
16
16
|
def request_phase
|
17
|
-
|
18
|
-
|
19
|
-
if !whr.nil?
|
20
|
-
request = OmniAuth::Strategies::WSFed::AuthRequest.new
|
21
|
-
redirect(request.create(options, :whr => whr))
|
22
|
-
elsif !options[:home_realm_discovery_path].nil?
|
23
|
-
redirect(options[:home_realm_discovery_path])
|
24
|
-
else
|
25
|
-
request = OmniAuth::Strategies::WSFed::AuthRequest.new
|
26
|
-
redirect(request.create(options))
|
27
|
-
end
|
28
|
-
|
17
|
+
auth_request = OmniAuth::Strategies::WSFed::AuthRequest.new(options, :whr => @request.params['whr'])
|
18
|
+
redirect(auth_request.redirect_url)
|
29
19
|
end
|
30
20
|
|
31
21
|
# Parse SAML token...
|
32
22
|
def callback_phase
|
33
23
|
begin
|
24
|
+
validate_callback_params(@request)
|
25
|
+
|
34
26
|
wsfed_callback = request.params['wresult']
|
35
27
|
|
36
28
|
signed_document = OmniAuth::Strategies::WSFed::XMLSecurity::SignedDocument.new(wsfed_callback)
|
@@ -68,7 +60,13 @@ module OmniAuth
|
|
68
60
|
options[:idp_cert_fingerprint]
|
69
61
|
else
|
70
62
|
cert = OpenSSL::X509::Certificate.new(options[:idp_cert].gsub(/^ +/, ''))
|
71
|
-
Digest::SHA1.hexdigest(cert.to_der).upcase.scan(/../).join(
|
63
|
+
Digest::SHA1.hexdigest(cert.to_der).upcase.scan(/../).join(':')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def validate_callback_params(request)
|
68
|
+
if request.params['wresult'].nil? || request.params['wresult'].empty?
|
69
|
+
raise OmniAuth::Strategies::WSFed::ValidationError.new('AuthN token (wresult) missing in callback.')
|
72
70
|
end
|
73
71
|
end
|
74
72
|
|
@@ -9,10 +9,27 @@ module OmniAuth
|
|
9
9
|
|
10
10
|
SIGNIN_PARAM = 'wsignin1.0'
|
11
11
|
|
12
|
-
|
12
|
+
attr_reader :strategy_settings, :args
|
13
|
+
|
14
|
+
def initialize(settings, args = {})
|
15
|
+
raise ArgumentError.new('OmniAuth-WSFed settings cannot be nil.') if settings.nil?
|
16
|
+
|
17
|
+
@strategy_settings = settings
|
18
|
+
@args = args
|
19
|
+
end
|
20
|
+
|
21
|
+
def redirect_url
|
22
|
+
if args[:whr].nil? && strategy_settings[:home_realm_discovery_path]
|
23
|
+
strategy_settings[:home_realm_discovery_path]
|
24
|
+
else
|
25
|
+
wsfed_signin_request
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def wsfed_signin_request
|
13
30
|
wa = SIGNIN_PARAM
|
14
|
-
wtrealm = url_encode(
|
15
|
-
wreply = url_encode(
|
31
|
+
wtrealm = url_encode(strategy_settings[:realm])
|
32
|
+
wreply = url_encode(strategy_settings[:reply])
|
16
33
|
wct = url_encode(Time.now.utc)
|
17
34
|
whr = url_encode(args[:whr])
|
18
35
|
|
@@ -22,7 +39,7 @@ module OmniAuth
|
|
22
39
|
query_string = "#{query_string}&whr=#{whr}"
|
23
40
|
end
|
24
41
|
|
25
|
-
|
42
|
+
strategy_settings[:issuer] + query_string
|
26
43
|
end
|
27
44
|
|
28
45
|
end
|
@@ -3,64 +3,101 @@ require 'erb'
|
|
3
3
|
|
4
4
|
describe OmniAuth::Strategies::WSFed::AuthRequest do
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
let(:wsfed_settings) do
|
7
|
+
{
|
8
|
+
:issuer => 'https://c4sc.accesscontrol.windows.net.com/v2/wsfederation',
|
9
|
+
:realm => 'http://c4sc.com/security_realm',
|
10
|
+
:reply => 'http://rp.c4sc.com/auth/wsfed',
|
11
|
+
:home_realm_discovery_path => 'auth/home_realm_discovery'
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'Initialization' do
|
16
|
+
|
17
|
+
it 'should raise an ArgumentException when strategy_settings are nil or empty' do
|
18
|
+
expect { OmniAuth::Strategies::WSFed::AuthRequest.new(nil, {}) }.to raise_error ArgumentError
|
14
19
|
end
|
15
20
|
|
16
|
-
|
21
|
+
it 'should set strategy_settings and args properties when initialized properly' do
|
22
|
+
args = { :whr => 'https://identity.c4sc.com'}
|
23
|
+
request = OmniAuth::Strategies::WSFed::AuthRequest.new(wsfed_settings, args)
|
17
24
|
|
18
|
-
|
19
|
-
|
20
|
-
|
25
|
+
request.strategy_settings.should == wsfed_settings
|
26
|
+
request.args.should == args
|
27
|
+
end
|
21
28
|
|
22
|
-
|
23
|
-
request.should start_with "#{wsfed_settings[:issuer]}?"
|
24
|
-
end
|
29
|
+
end
|
25
30
|
|
26
|
-
|
27
|
-
request.should include 'wa=wsignin1.0'
|
28
|
-
end
|
31
|
+
context 'Redirect URL' do
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
+
it 'should equal the :home_realm_discovery path if configured and no :whr argument exists' do
|
34
|
+
request = OmniAuth::Strategies::WSFed::AuthRequest.new(wsfed_settings, {})
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
end
|
36
|
+
request.redirect_url.should == wsfed_settings[:home_realm_discovery_path]
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
it 'should equal the wsfed_signin_path if :whr argument exists' do
|
40
|
+
args = { :whr => 'https://identity.c4sc.com'}
|
41
|
+
request = OmniAuth::Strategies::WSFed::AuthRequest.new(wsfed_settings, args)
|
42
|
+
|
43
|
+
request.redirect_url.should == request.wsfed_signin_request
|
44
|
+
end
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
46
|
+
it 'should equal the wsfed_signin_path if :whr argument and :home_realm_discovery_path are missing' do
|
47
|
+
wsfed_settings.delete(:home_realm_discovery_path)
|
48
|
+
request = OmniAuth::Strategies::WSFed::AuthRequest.new(wsfed_settings, {})
|
45
49
|
|
46
|
-
|
47
|
-
|
50
|
+
request.redirect_url.should == request.wsfed_signin_request
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
48
54
|
|
49
|
-
|
55
|
+
context 'WSFed Signin Request' do
|
50
56
|
|
51
|
-
|
57
|
+
let :request do
|
58
|
+
OmniAuth::Strategies::WSFed::AuthRequest.new(wsfed_settings)
|
59
|
+
end
|
52
60
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
61
|
+
it 'should include the issuer URL followed by WsFed query string params' do
|
62
|
+
request.wsfed_signin_request.should start_with "#{request.strategy_settings[:issuer]}?"
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should include the sign-in param [wa]' do
|
66
|
+
request.wsfed_signin_request.should include 'wa=wsignin1.0'
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should include the url-encoded security realm param [wtrealm]' do
|
70
|
+
request.wsfed_signin_request.should include "wtrealm=#{ERB::Util::url_encode(request.strategy_settings[:realm])}"
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should include the url-encoded reply param [wreply]' do
|
74
|
+
request.wsfed_signin_request.should include "wreply=#{ERB::Util::url_encode(request.strategy_settings[:reply])}"
|
75
|
+
end
|
57
76
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
77
|
+
it 'should include an empty context param [wctx]' do
|
78
|
+
request.wsfed_signin_request.should include "wctx=&"
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should include the request creation instant time param [wtc]' do
|
82
|
+
time = Time.now.utc
|
83
|
+
Time.now.stub(:utc).and_return(time)
|
84
|
+
|
85
|
+
request.wsfed_signin_request.should include "wct=#{ERB::Util.url_encode(time)}"
|
86
|
+
end
|
87
|
+
|
88
|
+
describe 'Url-Encoded Home Realm Parameter [whr]' do
|
89
|
+
|
90
|
+
let(:home_realm) { 'http://identity.c4sc.com/trust' }
|
91
|
+
|
92
|
+
it 'should include [whr] if provided in the options' do
|
93
|
+
request = OmniAuth::Strategies::WSFed::AuthRequest.new(wsfed_settings, :whr => home_realm)
|
94
|
+
request.wsfed_signin_request.should include "whr=#{ERB::Util::url_encode(home_realm)}"
|
95
|
+
end
|
63
96
|
|
97
|
+
it 'should exclude [whr] if ignored in the options' do
|
98
|
+
request = OmniAuth::Strategies::WSFed::AuthRequest.new(wsfed_settings, :whr => nil)
|
99
|
+
request.wsfed_signin_request.should_not include "whr=#{ERB::Util::url_encode(home_realm)}"
|
100
|
+
request.wsfed_signin_request.should_not include 'whr='
|
64
101
|
end
|
65
102
|
|
66
103
|
end
|
@@ -1,22 +1,22 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
# Had to split these tests into
|
4
|
-
# instance of the strategy settings per spec description. In other words, any time you
|
5
|
-
# OmniAuth initialization settings, you need a new spec description to
|
3
|
+
# Had to split these tests into different classes because the OmniAuth::Test::StrategyTestCase only
|
4
|
+
# sets up one instance of the strategy settings per spec description. In other words, any time you
|
5
|
+
# need to make changes to the OmniAuth initialization settings, you need a new spec description to
|
6
|
+
# re-initialize the test strategy.
|
6
7
|
|
7
8
|
describe OmniAuth::Strategies::WSFed, :type => :strategy do
|
8
9
|
include OmniAuth::Test::StrategyTestCase
|
9
10
|
|
10
|
-
let(:auth_hash){ last_request.env['omniauth.auth'] }
|
11
11
|
let(:wsfed_settings) do
|
12
12
|
{
|
13
|
-
issuer
|
14
|
-
realm
|
15
|
-
reply
|
13
|
+
:issuer => 'https://c4sc.accesscontrol.windows.net.com/v2/wsfederation',
|
14
|
+
:realm => 'http://example.com/rp',
|
15
|
+
:reply => 'http://example.com/auth/wsfed'
|
16
16
|
}
|
17
17
|
end
|
18
18
|
let(:strategy) { [OmniAuth::Strategies::WSFed, wsfed_settings] }
|
19
|
-
let(:home_realm) {
|
19
|
+
let(:home_realm) { 'http://identity.c4sc.com' }
|
20
20
|
|
21
21
|
|
22
22
|
describe 'request_phase: GET /auth/wsfed' do
|
@@ -47,17 +47,16 @@ end
|
|
47
47
|
describe OmniAuth::Strategies::WSFed, :type => :strategy do
|
48
48
|
include OmniAuth::Test::StrategyTestCase
|
49
49
|
|
50
|
-
let(:home_realm_discovery) { "/auth/wsfed/home_realm_discovery" }
|
51
50
|
let(:wsfed_settings) do
|
52
51
|
{
|
53
|
-
issuer
|
54
|
-
realm
|
55
|
-
reply
|
56
|
-
home_realm_discovery_path
|
52
|
+
:issuer => 'https://c4sc.accesscontrol.windows.net.com/v2/wsfederation',
|
53
|
+
:realm => 'http://example.com/rp',
|
54
|
+
:reply => 'http://example.com/auth/wsfed',
|
55
|
+
:home_realm_discovery_path => '/auth/wsfed/home_realm_discovery'
|
57
56
|
}
|
58
57
|
end
|
59
58
|
let(:strategy) { [OmniAuth::Strategies::WSFed, wsfed_settings] }
|
60
|
-
let(:home_realm) {
|
59
|
+
let(:home_realm) { 'http://identity.c4sc.com' }
|
61
60
|
|
62
61
|
context ':home_realm_discovery_path configured' do
|
63
62
|
|
@@ -65,7 +64,7 @@ describe OmniAuth::Strategies::WSFed, :type => :strategy do
|
|
65
64
|
get '/auth/wsfed'
|
66
65
|
|
67
66
|
last_response.should be_redirect
|
68
|
-
last_response.location.should ==
|
67
|
+
last_response.location.should == wsfed_settings[:home_realm_discovery_path]
|
69
68
|
end
|
70
69
|
|
71
70
|
it 'should redirect to the IdP/FP Issuer URL and maintain [whr] param' do
|
@@ -79,4 +78,31 @@ describe OmniAuth::Strategies::WSFed, :type => :strategy do
|
|
79
78
|
end
|
80
79
|
end
|
81
80
|
|
81
|
+
describe OmniAuth::Strategies::WSFed, :type => :strategy do
|
82
|
+
include OmniAuth::Test::StrategyTestCase
|
83
|
+
|
84
|
+
let(:home_realm_discovery) { '/auth/wsfed/home_realm_discovery' }
|
85
|
+
let(:wsfed_settings) do
|
86
|
+
{
|
87
|
+
:issuer => 'https://c4sc.accesscontrol.windows.net.com/v2/wsfederation',
|
88
|
+
:realm => 'http://example.com/rp',
|
89
|
+
:reply => 'http://example.com/auth/wsfed',
|
90
|
+
:home_realm_discovery_path => home_realm_discovery
|
91
|
+
}
|
92
|
+
end
|
93
|
+
let(:strategy) { [OmniAuth::Strategies::WSFed, wsfed_settings] }
|
94
|
+
let(:home_realm) { 'http://identity.c4sc.com' }
|
95
|
+
|
96
|
+
context 'invalid callbacks' do
|
97
|
+
|
98
|
+
it 'should redirect to failure route when the \'wresult\' parameter is nil' do
|
99
|
+
post 'auth/wsfed/callback'
|
100
|
+
|
101
|
+
last_response.status.should == 302
|
102
|
+
last_response.location.should == '/auth/failure?message=invalid_authn_token&strategy=wsfed'
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
82
108
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-wsfed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Beckman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|
@@ -93,7 +93,6 @@ files:
|
|
93
93
|
- .gitignore
|
94
94
|
- .travis.yml
|
95
95
|
- Gemfile
|
96
|
-
- Gemfile.lock
|
97
96
|
- LICENSE
|
98
97
|
- README.md
|
99
98
|
- Rakefile
|
@@ -131,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
130
|
version: '0'
|
132
131
|
requirements: []
|
133
132
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.0.
|
133
|
+
rubygems_version: 2.0.6
|
135
134
|
signing_key:
|
136
135
|
specification_version: 4
|
137
136
|
summary: A WS-Federation + WS-Trust strategy for OmniAuth.
|
data/Gemfile.lock
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
omniauth-wsfed (0.2.1)
|
5
|
-
omniauth (~> 1.1.0)
|
6
|
-
xmlcanonicalizer (= 0.1.1)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
diff-lcs (1.1.3)
|
12
|
-
hashie (1.2.0)
|
13
|
-
omniauth (1.1.0)
|
14
|
-
hashie (~> 1.2)
|
15
|
-
rack
|
16
|
-
rack (1.4.1)
|
17
|
-
rack-test (0.6.2)
|
18
|
-
rack (>= 1.0)
|
19
|
-
rake (10.0.3)
|
20
|
-
rspec (2.12.0)
|
21
|
-
rspec-core (~> 2.12.0)
|
22
|
-
rspec-expectations (~> 2.12.0)
|
23
|
-
rspec-mocks (~> 2.12.0)
|
24
|
-
rspec-core (2.12.2)
|
25
|
-
rspec-expectations (2.12.1)
|
26
|
-
diff-lcs (~> 1.1.3)
|
27
|
-
rspec-mocks (2.12.1)
|
28
|
-
xmlcanonicalizer (0.1.1)
|
29
|
-
|
30
|
-
PLATFORMS
|
31
|
-
ruby
|
32
|
-
|
33
|
-
DEPENDENCIES
|
34
|
-
omniauth-wsfed!
|
35
|
-
rack-test (>= 0.6.2)
|
36
|
-
rake (>= 10.0.3)
|
37
|
-
rspec (>= 2.12.0)
|