openid_connect 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +23 -22
- data/VERSION +1 -1
- data/lib/openid_connect/connect_object.rb +3 -0
- data/lib/openid_connect/response_object/id_token.rb +27 -3
- data/openid_connect.gemspec +1 -1
- data/spec/openid_connect/access_token_spec.rb +4 -4
- data/spec/openid_connect/client/registrar_spec.rb +7 -7
- data/spec/openid_connect/client_spec.rb +3 -3
- data/spec/openid_connect/connect_object_spec.rb +4 -4
- data/spec/openid_connect/discovery/principal/uri_spec.rb +1 -1
- data/spec/openid_connect/discovery/principal_spec.rb +1 -1
- data/spec/openid_connect/request_object_spec.rb +1 -1
- data/spec/openid_connect/response_object/id_token_spec.rb +56 -8
- data/spec/rack/oauth2/server/authorize/extension/code_and_id_token_and_token_spec.rb +1 -1
- data/spec/rack/oauth2/server/authorize/extension/code_and_id_token_spec.rb +1 -1
- data/spec/rack/oauth2/server/authorize/extension/id_token_and_token_spec.rb +1 -1
- data/spec/rack/oauth2/server/authorize/extension/id_token_spec.rb +1 -1
- data/spec/rack/oauth2/server/resource/error_with_connect_ext_spec.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
openid_connect (0.3.
|
4
|
+
openid_connect (0.3.1)
|
5
5
|
activemodel (>= 3)
|
6
6
|
attr_required (>= 0.0.5)
|
7
7
|
json (>= 1.4.3)
|
8
|
-
json-jwt (>= 0.0
|
8
|
+
json-jwt (>= 0.3.0)
|
9
9
|
rack-oauth2 (>= 0.14.2)
|
10
10
|
swd (>= 0.1.2)
|
11
11
|
tzinfo
|
@@ -15,16 +15,16 @@ PATH
|
|
15
15
|
GEM
|
16
16
|
remote: http://rubygems.org/
|
17
17
|
specs:
|
18
|
-
activemodel (3.2.
|
19
|
-
activesupport (= 3.2.
|
18
|
+
activemodel (3.2.8)
|
19
|
+
activesupport (= 3.2.8)
|
20
20
|
builder (~> 3.0.0)
|
21
|
-
activesupport (3.2.
|
21
|
+
activesupport (3.2.8)
|
22
22
|
i18n (~> 0.6)
|
23
23
|
multi_json (~> 1.0)
|
24
|
-
addressable (2.2
|
24
|
+
addressable (2.3.2)
|
25
25
|
attr_required (0.0.5)
|
26
26
|
bouncy-castle-java (1.5.0146.1)
|
27
|
-
builder (3.0.
|
27
|
+
builder (3.0.3)
|
28
28
|
configatron (2.9.1)
|
29
29
|
yamler (>= 0.1.0)
|
30
30
|
cover_me (1.2.0)
|
@@ -33,12 +33,13 @@ GEM
|
|
33
33
|
crack (0.3.1)
|
34
34
|
diff-lcs (1.1.3)
|
35
35
|
hashie (1.2.0)
|
36
|
-
httpclient (2.2.
|
37
|
-
i18n (0.6.
|
36
|
+
httpclient (2.2.7)
|
37
|
+
i18n (0.6.1)
|
38
38
|
jruby-openssl (0.7.7)
|
39
39
|
bouncy-castle-java (>= 1.5.0146.1)
|
40
|
-
json (1.7.
|
41
|
-
json
|
40
|
+
json (1.7.5)
|
41
|
+
json (1.7.5-java)
|
42
|
+
json-jwt (0.3.0)
|
42
43
|
activesupport (>= 2.3)
|
43
44
|
i18n
|
44
45
|
json (>= 1.4.3)
|
@@ -51,22 +52,22 @@ GEM
|
|
51
52
|
multi_json (1.3.6)
|
52
53
|
polyglot (0.3.3)
|
53
54
|
rack (1.4.1)
|
54
|
-
rack-oauth2 (0.14.
|
55
|
+
rack-oauth2 (0.14.9)
|
55
56
|
activesupport (>= 2.3)
|
56
57
|
attr_required (>= 0.0.5)
|
57
58
|
httpclient (>= 2.2.0.2)
|
58
59
|
i18n
|
59
|
-
|
60
|
+
multi_json (>= 1.3.6)
|
60
61
|
rack (>= 1.1)
|
61
62
|
rake (0.9.2.2)
|
62
|
-
rspec (2.
|
63
|
-
rspec-core (~> 2.
|
64
|
-
rspec-expectations (~> 2.
|
65
|
-
rspec-mocks (~> 2.
|
66
|
-
rspec-core (2.
|
67
|
-
rspec-expectations (2.
|
63
|
+
rspec (2.11.0)
|
64
|
+
rspec-core (~> 2.11.0)
|
65
|
+
rspec-expectations (~> 2.11.0)
|
66
|
+
rspec-mocks (~> 2.11.0)
|
67
|
+
rspec-core (2.11.1)
|
68
|
+
rspec-expectations (2.11.3)
|
68
69
|
diff-lcs (~> 1.1.3)
|
69
|
-
rspec-mocks (2.
|
70
|
+
rspec-mocks (2.11.3)
|
70
71
|
swd (0.1.2)
|
71
72
|
activesupport (>= 3)
|
72
73
|
attr_required (>= 0.0.5)
|
@@ -78,12 +79,12 @@ GEM
|
|
78
79
|
polyglot (>= 0.3.1)
|
79
80
|
tzinfo (0.3.33)
|
80
81
|
url_safe_base64 (0.2.1)
|
81
|
-
validate_email (0.1.
|
82
|
+
validate_email (0.1.6)
|
82
83
|
activemodel (>= 3.0)
|
83
84
|
mail (>= 2.2.5)
|
84
85
|
validate_url (0.2.0)
|
85
86
|
activemodel (>= 3.0.0)
|
86
|
-
webmock (1.8.
|
87
|
+
webmock (1.8.11)
|
87
88
|
addressable (>= 2.2.7)
|
88
89
|
crack (>= 0.1.7)
|
89
90
|
yamler (0.1.0)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
@@ -2,10 +2,13 @@ module OpenIDConnect
|
|
2
2
|
class ConnectObject
|
3
3
|
include ActiveModel::Validations, AttrRequired, AttrOptional
|
4
4
|
|
5
|
+
attr_accessor :raw_attributes
|
6
|
+
|
5
7
|
def initialize(attributes = {})
|
6
8
|
all_attributes.each do |_attr_|
|
7
9
|
self.send :"#{_attr_}=", attributes[_attr_]
|
8
10
|
end
|
11
|
+
self.raw_attributes = attributes
|
9
12
|
attr_missing!
|
10
13
|
end
|
11
14
|
|
@@ -6,11 +6,11 @@ module OpenIDConnect
|
|
6
6
|
class InvalidToken < Exception; end
|
7
7
|
|
8
8
|
attr_required :iss, :user_id, :aud, :exp, :iat
|
9
|
-
attr_optional :acr, :auth_time, :nonce, :at_hash, :c_hash
|
9
|
+
attr_optional :acr, :auth_time, :nonce, :user_jwk, :at_hash, :c_hash
|
10
10
|
|
11
11
|
def initialize(attributes = {})
|
12
12
|
super
|
13
|
-
(all_attributes - [:exp, :iat, :auth_time]).each do |key|
|
13
|
+
(all_attributes - [:exp, :iat, :auth_time, :user_jwk]).each do |key|
|
14
14
|
self.send "#{key}=", self.send(key).try(:to_s)
|
15
15
|
end
|
16
16
|
end
|
@@ -26,7 +26,31 @@ module OpenIDConnect
|
|
26
26
|
include JWTnizable
|
27
27
|
class << self
|
28
28
|
def decode(jwt_string, key)
|
29
|
-
|
29
|
+
if key == :self_issued
|
30
|
+
decode_self_issued jwt_string
|
31
|
+
else
|
32
|
+
new JSON::JWT.decode jwt_string, key
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def decode_self_issued(jwt_string)
|
37
|
+
jwt = JSON::JWT.decode jwt_string, :skip_verification
|
38
|
+
jwk = jwt[:user_jwk]
|
39
|
+
raise InvalidToken.new('Missing user_jwk') if jwk.blank?
|
40
|
+
public_key = JSON::JWK.decode jwk
|
41
|
+
user_id_base_string = case public_key
|
42
|
+
when OpenSSL::PKey::RSA
|
43
|
+
[jwk[:mod], jwk[:exp]].join
|
44
|
+
when OpenSSL::PKey::EC
|
45
|
+
raise NotImplementedError.new('Not Implemented Yet')
|
46
|
+
else
|
47
|
+
# Shouldn't reach here. All unknown algorithm error should occurs when decoding JWK
|
48
|
+
raise InvalidToken.new('Unknown Algorithm')
|
49
|
+
end
|
50
|
+
expected_user_id = UrlSafeBase64.encode64 OpenSSL::Digest::SHA256.digest(user_id_base_string)
|
51
|
+
raise InvalidToken.new('Invalid user_id') unless jwt[:user_id] == expected_user_id
|
52
|
+
jwt.verify public_key
|
53
|
+
new jwt
|
30
54
|
end
|
31
55
|
end
|
32
56
|
end
|
data/openid_connect.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.add_runtime_dependency "activemodel", ">= 3"
|
17
17
|
s.add_runtime_dependency "validate_url"
|
18
18
|
s.add_runtime_dependency "validate_email"
|
19
|
-
s.add_runtime_dependency "json-jwt", ">= 0.0
|
19
|
+
s.add_runtime_dependency "json-jwt", ">= 0.3.0"
|
20
20
|
s.add_runtime_dependency "swd", ">= 0.1.2"
|
21
21
|
s.add_runtime_dependency "rack-oauth2", ">= 0.14.2"
|
22
22
|
s.add_development_dependency "rake", ">= 0.8"
|
@@ -56,7 +56,7 @@ describe OpenIDConnect::AccessToken do
|
|
56
56
|
mock_json :get, endpoint, 'errors/invalid_request', :HTTP_AUTHORIZATION => 'Bearer access_token', :status => 400, :params => {
|
57
57
|
:schema => 'openid'
|
58
58
|
} do
|
59
|
-
expect { request }.
|
59
|
+
expect { request }.to raise_error OpenIDConnect::BadRequest
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -66,7 +66,7 @@ describe OpenIDConnect::AccessToken do
|
|
66
66
|
mock_json :get, endpoint, 'errors/invalid_access_token', :HTTP_AUTHORIZATION => 'Bearer access_token', :status => 401, :params => {
|
67
67
|
:schema => 'openid'
|
68
68
|
} do
|
69
|
-
expect { request }.
|
69
|
+
expect { request }.to raise_error OpenIDConnect::Unauthorized
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -76,7 +76,7 @@ describe OpenIDConnect::AccessToken do
|
|
76
76
|
mock_json :get, endpoint, 'errors/insufficient_scope', :HTTP_AUTHORIZATION => 'Bearer access_token', :status => 403, :params => {
|
77
77
|
:schema => 'openid'
|
78
78
|
} do
|
79
|
-
expect { request }.
|
79
|
+
expect { request }.to raise_error OpenIDConnect::Forbidden
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -86,7 +86,7 @@ describe OpenIDConnect::AccessToken do
|
|
86
86
|
mock_json :get, endpoint, 'errors/unknown', :HTTP_AUTHORIZATION => 'Bearer access_token', :status => 500, :params => {
|
87
87
|
:schema => 'openid'
|
88
88
|
} do
|
89
|
-
expect { request }.
|
89
|
+
expect { request }.to raise_error OpenIDConnect::HttpError
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
@@ -56,7 +56,7 @@ describe OpenIDConnect::Client::Registrar do
|
|
56
56
|
it do
|
57
57
|
expect do
|
58
58
|
instance
|
59
|
-
end.
|
59
|
+
end.not_to raise_error
|
60
60
|
end
|
61
61
|
it { should_not be_valid }
|
62
62
|
end
|
@@ -69,7 +69,7 @@ describe OpenIDConnect::Client::Registrar do
|
|
69
69
|
it do
|
70
70
|
expect do
|
71
71
|
instance
|
72
|
-
end.
|
72
|
+
end.to raise_error AttrRequired::AttrMissing
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -208,7 +208,7 @@ describe OpenIDConnect::Client::Registrar do
|
|
208
208
|
it do
|
209
209
|
expect do
|
210
210
|
instance.as_json
|
211
|
-
end.
|
211
|
+
end.to raise_error OpenIDConnect::ValidationFailed
|
212
212
|
end
|
213
213
|
end
|
214
214
|
end
|
@@ -237,7 +237,7 @@ describe OpenIDConnect::Client::Registrar do
|
|
237
237
|
}, :status => 400 do
|
238
238
|
expect do
|
239
239
|
instance.associate!
|
240
|
-
end.
|
240
|
+
end.to raise_error OpenIDConnect::Client::Registrar::RegistrationFailed
|
241
241
|
end
|
242
242
|
end
|
243
243
|
end
|
@@ -274,7 +274,7 @@ describe OpenIDConnect::Client::Registrar do
|
|
274
274
|
}, :status => 400 do
|
275
275
|
expect do
|
276
276
|
instance.update!
|
277
|
-
end.
|
277
|
+
end.to raise_error OpenIDConnect::Client::Registrar::RegistrationFailed
|
278
278
|
end
|
279
279
|
end
|
280
280
|
end
|
@@ -308,7 +308,7 @@ describe OpenIDConnect::Client::Registrar do
|
|
308
308
|
it do
|
309
309
|
expect do
|
310
310
|
instance.validate!
|
311
|
-
end.
|
311
|
+
end.not_to raise_error OpenIDConnect::ValidationFailed
|
312
312
|
end
|
313
313
|
end
|
314
314
|
|
@@ -321,7 +321,7 @@ describe OpenIDConnect::Client::Registrar do
|
|
321
321
|
it do
|
322
322
|
expect do
|
323
323
|
instance.validate!
|
324
|
-
end.
|
324
|
+
end.to raise_error OpenIDConnect::ValidationFailed
|
325
325
|
end
|
326
326
|
end
|
327
327
|
end
|
@@ -26,7 +26,7 @@ describe OpenIDConnect::Client do
|
|
26
26
|
[:authorization_uri, :user_info_uri].each do |endpoint|
|
27
27
|
describe endpoint do
|
28
28
|
it do
|
29
|
-
expect { client.send endpoint }.
|
29
|
+
expect { client.send endpoint }.to raise_error 'No Host Info'
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -109,7 +109,7 @@ describe OpenIDConnect::Client do
|
|
109
109
|
mock_json :post, client.token_endpoint, 'access_token/invalid_json', :request_header => header_params, :params => protocol_params do
|
110
110
|
expect do
|
111
111
|
access_token
|
112
|
-
end.
|
112
|
+
end.to raise_error OpenIDConnect::Exception, 'Unknown Token Type'
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
@@ -117,7 +117,7 @@ describe OpenIDConnect::Client do
|
|
117
117
|
context 'otherwise' do
|
118
118
|
it 'should raise Unexpected Token Type exception' do
|
119
119
|
mock_json :post, client.token_endpoint, 'access_token/mac', :request_header => header_params, :params => protocol_params do
|
120
|
-
expect { access_token }.
|
120
|
+
expect { access_token }.to raise_error OpenIDConnect::Exception, 'Unexpected Token Type: mac'
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
@@ -35,13 +35,13 @@ describe OpenIDConnect::ConnectObject do
|
|
35
35
|
{:optional => 'Optional'}
|
36
36
|
end
|
37
37
|
it do
|
38
|
-
expect { klass.new attributes }.
|
38
|
+
expect { klass.new attributes }.to raise_error AttrRequired::AttrMissing
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'otherwise' do
|
43
43
|
it do
|
44
|
-
expect { klass.new }.
|
44
|
+
expect { klass.new }.to raise_error AttrRequired::AttrMissing
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -59,7 +59,7 @@ describe OpenIDConnect::ConnectObject do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'should raise OpenIDConnect::ValidationFailed with ActiveModel::Errors owner' do
|
62
|
-
expect { instance.as_json }.
|
62
|
+
expect { instance.as_json }.to raise_error(OpenIDConnect::ValidationFailed) { |e|
|
63
63
|
e.message.should include 'Required is not included in the list'
|
64
64
|
e.message.should include 'Required is too long (maximum is 10 characters)'
|
65
65
|
e.object.errors.should be_a ActiveModel::Errors
|
@@ -80,7 +80,7 @@ describe OpenIDConnect::ConnectObject do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'should raise OpenIDConnect::ValidationFailed with ActiveModel::Errors owner' do
|
83
|
-
expect { instance.validate! }.
|
83
|
+
expect { instance.validate! }.to raise_error(OpenIDConnect::ValidationFailed) { |e|
|
84
84
|
e.message.should include 'Required is not included in the list'
|
85
85
|
e.message.should include 'Required is too long (maximum is 10 characters)'
|
86
86
|
e.object.errors.should be_a ActiveModel::Errors
|
@@ -37,7 +37,7 @@ describe OpenIDConnect::Discovery::Principal::URI do
|
|
37
37
|
describe 'error handling' do
|
38
38
|
let(:identifier) { '**' }
|
39
39
|
it do
|
40
|
-
expect { uri }.
|
40
|
+
expect { uri }.to raise_error OpenIDConnect::Discovery::InvalidIdentifier
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -26,7 +26,7 @@ describe OpenIDConnect::Discovery::Principal do
|
|
26
26
|
context 'when discovery failed' do
|
27
27
|
it do
|
28
28
|
SWD.should_receive(:discover!).and_raise(SWD::Exception)
|
29
|
-
expect { request }.
|
29
|
+
expect { request }.to raise_error OpenIDConnect::Discovery::DiscoveryFailed
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -19,7 +19,7 @@ describe OpenIDConnect::ResponseObject::IdToken do
|
|
19
19
|
describe 'attributes' do
|
20
20
|
subject { klass }
|
21
21
|
its(:required_attributes) { should == [:iss, :user_id, :aud, :exp, :iat] }
|
22
|
-
its(:optional_attributes) { should == [:acr, :auth_time, :nonce, :at_hash, :c_hash] }
|
22
|
+
its(:optional_attributes) { should == [:acr, :auth_time, :nonce, :user_jwk, :at_hash, :c_hash] }
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '#verify!' do
|
@@ -39,7 +39,7 @@ describe OpenIDConnect::ResponseObject::IdToken do
|
|
39
39
|
:issuer => attributes[:iss],
|
40
40
|
:client_id => attributes[:aud]
|
41
41
|
)
|
42
|
-
end.
|
42
|
+
end.to raise_error OpenIDConnect::ResponseObject::IdToken::InvalidToken
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -51,7 +51,7 @@ describe OpenIDConnect::ResponseObject::IdToken do
|
|
51
51
|
:issuer => 'invalid_issuer',
|
52
52
|
:client_id => attributes[:aud]
|
53
53
|
)
|
54
|
-
end.
|
54
|
+
end.to raise_error OpenIDConnect::ResponseObject::IdToken::InvalidToken
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -61,7 +61,7 @@ describe OpenIDConnect::ResponseObject::IdToken do
|
|
61
61
|
id_token.verify!(
|
62
62
|
:client_id => attributes[:aud]
|
63
63
|
)
|
64
|
-
end.
|
64
|
+
end.to raise_error OpenIDConnect::ResponseObject::IdToken::InvalidToken
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -72,7 +72,7 @@ describe OpenIDConnect::ResponseObject::IdToken do
|
|
72
72
|
:issuer => attributes[:iss],
|
73
73
|
:client_id => 'invalid_client'
|
74
74
|
)
|
75
|
-
end.
|
75
|
+
end.to raise_error OpenIDConnect::ResponseObject::IdToken::InvalidToken
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -82,7 +82,7 @@ describe OpenIDConnect::ResponseObject::IdToken do
|
|
82
82
|
id_token.verify!(
|
83
83
|
:issuer => attributes[:iss]
|
84
84
|
)
|
85
|
-
end.
|
85
|
+
end.to raise_error OpenIDConnect::ResponseObject::IdToken::InvalidToken
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -107,7 +107,7 @@ describe OpenIDConnect::ResponseObject::IdToken do
|
|
107
107
|
:client_id => attributes[:aud],
|
108
108
|
:nonce => 'invalid_nonce'
|
109
109
|
)
|
110
|
-
end.
|
110
|
+
end.to raise_error OpenIDConnect::ResponseObject::IdToken::InvalidToken
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -118,7 +118,7 @@ describe OpenIDConnect::ResponseObject::IdToken do
|
|
118
118
|
:issuer => attributes[:iss],
|
119
119
|
:client_id => attributes[:aud]
|
120
120
|
)
|
121
|
-
end.
|
121
|
+
end.to raise_error OpenIDConnect::ResponseObject::IdToken::InvalidToken
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
@@ -157,5 +157,53 @@ describe OpenIDConnect::ResponseObject::IdToken do
|
|
157
157
|
its(key) { should == attributes[key] }
|
158
158
|
end
|
159
159
|
its(:exp) { should == attributes[:exp].to_i }
|
160
|
+
|
161
|
+
context 'when self-issued' do
|
162
|
+
context 'when valid' do
|
163
|
+
let(:self_issued) do
|
164
|
+
'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NlbGYtaXNzdWVkLm1lIiwidXNlcl9pZCI6IkN5amplQ0trLU9xSS1YcW5GYzduX1pSOG4xaXlLNFlIcXNzNkp1SHlnNkUiLCJhdWQiOiJ0YXBpZC50YXBpZGVudGl0eS5jb20iLCJleHAiOjEzNDkyNDc3ODAsImlhdCI6MTM0OTI0NDE4MCwidXNlcl9qd2siOnsiYWxnIjoiUlNBIiwibW9kIjoibWtra29uTXZuQkxiWkRCZE9lNkM3Ukk3T2xLbjVZazl0eTBSQ0NFa2E5TkVDVVhWRmJqaHdrVjlNeFpSekQ2Q3ZIZDQzUmU5ak5iRFFVQVloNm1peHZtdFFSODlDUFlMeWNvOXIzTlEySXpEZmVPZjlUbFpMUXhpOG9FSVBOeURyN1FoSHlpUTlBRkd6YUhNLW1DU1hCcTRnM0Z4Nko4U1d0MFBRSERoZV9MN3FURTJHbzA4NGRyZUtXMFZSazhBRkxrM2V3cVlvV0RQRXhjcFlNYWNNSUhnaFd1N0pRSG9xX0xId2hmdnk3cnN2MFh1QTR0ai1oNnhvaDhubUR6MjBfdUc5Wm9MZHJ0cE44ZHF1MTdOTDgwTmQ1cVotaHRwVUpSemUzVzdyN3F4Y0dwNEtzQnRhc0NqWlcyWGlyQlZ1eXU2bDNqc3JnTlB2S1NaZ2NpUGdRIiwiZXhwIjoiQVFBQiJ9fQ.gp7Yr3mT3oneZusYMOKB3_777QwJNrQlqiK4x7HpYreuPNbBYHOKo8Jsmqe8gCnrWcOtGHe2Flt1NvN_Yy-7TgVP9L8XyaM9KnWrVEPVCDlf2tIqIAd6MSOfWtiDsA--a7AHfg7o2HcxH3-V3JXS3LQJnzpKBHuaJJIYwj1_8W9sUXwljqNCmnCytrqkmIWocQazoAy5mvmUcpcTWGnSsiibQGk_eQTRjZaiouDDbHWi87IneVQ7UeuurPIYoVK6PWhj0894zcJEyJFWkf2UshgP1grGVO8FC6dvlF5dayt6aUYeGMrTEV8KL6FNYAB9dZKR7xDC4uOjumHTjvQFfA'
|
165
|
+
end
|
166
|
+
|
167
|
+
context 'when key == :self_issued' do
|
168
|
+
it do
|
169
|
+
expect do
|
170
|
+
klass.decode self_issued, :self_issued
|
171
|
+
end.not_to raise_error
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context 'when key == public_key' do
|
176
|
+
it do
|
177
|
+
expect do
|
178
|
+
klass.decode self_issued, public_key
|
179
|
+
end.to raise_error JSON::JWS::VerificationFailed
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
context 'when invalid user_id' do
|
185
|
+
let(:self_issued) do
|
186
|
+
'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NlbGYtaXNzdWVkLm1lIiwidXNlcl9pZCI6ImludmFsaWRfdXNlcl9pZCIsImF1ZCI6InRhcGlkLnRhcGlkZW50aXR5LmNvbSIsImV4cCI6MTM0OTI0ODgxOCwiaWF0IjoxMzQ5MjQ1MjE4LCJ1c2VyX2p3ayI6eyJhbGciOiJSU0EiLCJtb2QiOiJta2trb25Ndm5CTGJaREJkT2U2QzdSSTdPbEtuNVlrOXR5MFJDQ0VrYTlORUNVWFZGYmpod2tWOU14WlJ6RDZDdkhkNDNSZTlqTmJEUVVBWWg2bWl4dm10UVI4OUNQWUx5Y285cjNOUTJJekRmZU9mOVRsWkxReGk4b0VJUE55RHI3UWhIeWlROUFGR3phSE0tbUNTWEJxNGczRng2SjhTV3QwUFFIRGhlX0w3cVRFMkdvMDg0ZHJlS1cwVlJrOEFGTGszZXdxWW9XRFBFeGNwWU1hY01JSGdoV3U3SlFIb3FfTEh3aGZ2eTdyc3YwWHVBNHRqLWg2eG9oOG5tRHoyMF91Rzlab0xkcnRwTjhkcXUxN05MODBOZDVxWi1odHBVSlJ6ZTNXN3I3cXhjR3A0S3NCdGFzQ2paVzJYaXJCVnV5dTZsM2pzcmdOUHZLU1pnY2lQZ1EiLCJleHAiOiJBUUFCIn19.JTIAhIrjbI5s4-1QelTveJYqFjHz2vMQrkRo---TLtSkSDL4IaBXxXabQm_hgXR_Rh80GV2nAD9BR7PSdH2v4BK-xBzHnVzOIfWGzbB-fySvwEF3AO0cQpy8v95no6R8cbVF6exzVmuC5kLesS3BCjoHjywl-fS1H9fUMhUwDS6OatVg4AC3guz0_9l-cM1JE4Ryko-zLAzAkE8cfvVYyH0UCHAQUcTd2T45JmW4_hzN37ziuTs-xKkQ4fZ6TLURS_Q0sxX2vNIhdP1QQWzBwHwxObFK1O_Zb00KVe7MCB7Uxfisz1FDlFgq0Z0QCrQHuVyFqHqcJQjvPh3ORv0_6g'
|
187
|
+
end
|
188
|
+
|
189
|
+
it do
|
190
|
+
expect do
|
191
|
+
klass.decode self_issued, :self_issued
|
192
|
+
end.to raise_error OpenIDConnect::ResponseObject::IdToken::InvalidToken, 'Invalid user_id'
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
context 'when no user_jwk' do
|
197
|
+
let(:self_issued) do
|
198
|
+
'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NlbGYtaXNzdWVkLm1lIiwidXNlcl9pZCI6IkN5amplQ0trLU9xSS1YcW5GYzduX1pSOG4xaXlLNFlIcXNzNkp1SHlnNkUiLCJhdWQiOiJ0YXBpZC50YXBpZGVudGl0eS5jb20iLCJleHAiOjEzNDkyNDg5NjAsImlhdCI6MTM0OTI0NTM2MH0.SyXFCTAAB0l29qxnfUxj5G217cQqVhCiPlQDCq_ZZmtZyGqM4eLI-5D2MPZTc905i10sbwKHTeKqwjhYki2pVOuU5n-N9duTlO64kimg8hAnwEJKsil9jvRPb5hCnc-5vRyXaRV3N1zYFurCEZFmVvXCg4ccKbA_viyuhIYtiMQPHOGY-ELFokfwsbEv11hi9d0kt89pfBMlDyEIZiEDYT0fEl-w7e8tPEk99rCzD_jkitTtdXv18_UsgeM2pDaO9G7_8wQYAX4ldHZjXSihKp2DuTY7edZpP4arYIFHPibtPVcKEnpmK-25mk9Ujo6k7N5kqz9SX6isktbE9-3W4Q'
|
199
|
+
end
|
200
|
+
|
201
|
+
it do
|
202
|
+
expect do
|
203
|
+
klass.decode self_issued, :self_issued
|
204
|
+
end.to raise_error OpenIDConnect::ResponseObject::IdToken::InvalidToken, 'Missing user_jwk'
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
160
208
|
end
|
161
209
|
end
|
@@ -50,7 +50,7 @@ describe Rack::OAuth2::Server::Authorize::Extension::CodeAndIdTokenAndToken do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
it do
|
53
|
-
expect { response }.
|
53
|
+
expect { response }.to raise_error AttrRequired::AttrMissing, "'access_token', 'code', 'id_token' required."
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -47,7 +47,7 @@ describe Rack::OAuth2::Server::Authorize::Extension::CodeAndIdToken do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
it do
|
50
|
-
expect { response }.
|
50
|
+
expect { response }.to raise_error AttrRequired::AttrMissing, "'id_token' required."
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -48,7 +48,7 @@ describe Rack::OAuth2::Server::Authorize::Extension::IdTokenAndToken do
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
it do
|
51
|
-
expect { response }.
|
51
|
+
expect { response }.to raise_error AttrRequired::AttrMissing, "'id_token' required."
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -43,7 +43,7 @@ describe Rack::OAuth2::Server::Authorize::Extension::IdToken do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
it do
|
46
|
-
expect { response }.
|
46
|
+
expect { response }.to raise_error AttrRequired::AttrMissing, "'id_token' required."
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -6,7 +6,7 @@ describe Rack::OAuth2::Server::Resource::ErrorWithConnectExt do
|
|
6
6
|
|
7
7
|
describe 'invalid_schema!' do
|
8
8
|
it do
|
9
|
-
expect { request.invalid_schema! }.
|
9
|
+
expect { request.invalid_schema! }.to raise_error Rack::OAuth2::Server::Resource::BadRequest
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openid_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -114,7 +114,7 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ! '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.0
|
117
|
+
version: 0.3.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
requirements:
|
123
123
|
- - ! '>='
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.0
|
125
|
+
version: 0.3.0
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: swd
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|