openid_connect 0.0.27 → 0.0.28

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openid_connect (0.0.26)
4
+ openid_connect (0.0.27)
5
5
  activemodel (>= 3)
6
6
  attr_required (>= 0.0.3)
7
7
  json (>= 1.4.3)
@@ -25,7 +25,6 @@ GEM
25
25
  addressable (2.2.6)
26
26
  attr_required (0.0.3)
27
27
  bcrypt-ruby (3.0.1)
28
- bcrypt-ruby (3.0.1-java)
29
28
  bouncy-castle-java (1.5.0146.1)
30
29
  builder (3.0.0)
31
30
  crack (0.1.8)
@@ -34,7 +33,7 @@ GEM
34
33
  i18n (0.6.0)
35
34
  jruby-openssl (0.7.4)
36
35
  bouncy-castle-java
37
- json (1.6.0)
36
+ json (1.6.1)
38
37
  jwt (0.1.3)
39
38
  json (>= 1.2.4)
40
39
  mail (2.3.0)
@@ -45,7 +44,7 @@ GEM
45
44
  multi_json (1.0.3)
46
45
  polyglot (0.3.2)
47
46
  rack (1.3.2)
48
- rack-oauth2 (0.10.0)
47
+ rack-oauth2 (0.11.0)
49
48
  activesupport (>= 2.3)
50
49
  attr_required (>= 0.0.3)
51
50
  httpclient (>= 2.2.0.2)
@@ -63,7 +62,7 @@ GEM
63
62
  rspec-expectations (2.6.0)
64
63
  diff-lcs (~> 1.1.2)
65
64
  rspec-mocks (2.6.0)
66
- swd (0.0.6)
65
+ swd (0.0.7)
67
66
  activesupport (>= 3)
68
67
  attr_required (>= 0.0.3)
69
68
  httpclient (>= 2.2.1)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.27
1
+ 0.0.28
@@ -26,12 +26,7 @@ module Rack
26
26
 
27
27
  class Response < Authorize::Code::Response
28
28
  include IdTokenResponse
29
- attr_required :id_token, :private_key
30
-
31
- def protocol_params_location
32
- :fragment
33
- end
34
-
29
+ attr_required :id_token
35
30
  end
36
31
  end
37
32
  end
@@ -30,17 +30,7 @@ module Rack
30
30
 
31
31
  class Response < Authorize::Response
32
32
  include IdTokenResponse
33
- attr_required :id_token, :private_key
34
-
35
- def protocol_params_location
36
- :fragment
37
- end
38
-
39
- def protocol_params
40
- super.merge(
41
- :id_token => jwt_string
42
- )
43
- end
33
+ attr_required :id_token
44
34
  end
45
35
  end
46
36
  end
@@ -25,7 +25,8 @@ module Rack
25
25
  end
26
26
 
27
27
  class Response < Authorize::Token::Response
28
- attr_required :id_token, :private_key
28
+ include IdTokenResponse
29
+ attr_required :id_token
29
30
  end
30
31
  end
31
32
  end
@@ -1,20 +1,15 @@
1
1
  module Rack::OAuth2::Server
2
2
  module IdTokenResponse
3
3
  def self.included(klass)
4
- klass.send :attr_optional, :id_token, :private_key
4
+ klass.send :attr_optional, :id_token
5
5
  klass.class_eval do
6
- def jwt_string
7
- if id_token.is_a? OpenIDConnect::ResponseObject::IdToken
8
- raise AttrRequired::AttrMissing.new("'private_key' required.") unless private_key
9
- id_token.to_jwt private_key
10
- else
11
- id_token
12
- end
6
+ def protocol_params_location
7
+ :fragment
13
8
  end
14
9
 
15
10
  def protocol_params_with_id_token
16
11
  protocol_params_without_id_token.merge(
17
- :id_token => jwt_string
12
+ :id_token => id_token
18
13
  )
19
14
  end
20
15
  alias_method_chain :protocol_params, :id_token
@@ -22,7 +17,6 @@ module Rack::OAuth2::Server
22
17
  end
23
18
  end
24
19
  Token::Response.send :include, IdTokenResponse
25
- Authorize::Token::Response.send :include, IdTokenResponse
26
20
  end
27
21
 
28
22
  require 'rack/oauth2/server/authorize/extension/code_and_id_token'
@@ -12,7 +12,7 @@ describe Rack::OAuth2::Server::Authorize::Extension::CodeAndIdToken do
12
12
  :user_id => 'user_id',
13
13
  :aud => 'client_id',
14
14
  :exp => 1313424327
15
- )
15
+ ).to_jwt private_key
16
16
  end
17
17
 
18
18
  context "when id_token is given" do
@@ -21,33 +21,18 @@ describe Rack::OAuth2::Server::Authorize::Extension::CodeAndIdToken do
21
21
  response.redirect_uri = redirect_uri
22
22
  response.code = code
23
23
  response.id_token = id_token
24
- response.private_key = private_key
25
24
  response.approve!
26
25
  end
27
26
  end
28
27
  its(:status) { should == 302 }
29
28
  its(:location) { should include "#{redirect_uri}#" }
30
29
  its(:location) { should include "code=#{code}" }
31
- its(:location) { should include "id_token=#{id_token.to_jwt(private_key)}" }
30
+ its(:location) { should include "id_token=#{id_token}" }
32
31
 
33
32
  context 'when id_token is String' do
34
33
  let(:id_token) { 'non_jwt_string' }
35
34
  its(:location) { should include "id_token=non_jwt_string" }
36
35
  end
37
-
38
- context 'when private_key is missing' do
39
- let :app do
40
- Rack::OAuth2::Server::Authorize.new do |request, response|
41
- response.redirect_uri = redirect_uri
42
- response.code = code
43
- response.id_token = id_token
44
- response.approve!
45
- end
46
- end
47
- it do
48
- expect { response }.should raise_error AttrRequired::AttrMissing, "'private_key' required."
49
- end
50
- end
51
36
  end
52
37
 
53
38
  context "otherwise" do
@@ -59,7 +44,7 @@ describe Rack::OAuth2::Server::Authorize::Extension::CodeAndIdToken do
59
44
  end
60
45
  end
61
46
  it do
62
- expect { response }.should raise_error AttrRequired::AttrMissing, "'id_token', 'private_key' required."
47
+ expect { response }.should raise_error AttrRequired::AttrMissing, "'id_token' required."
63
48
  end
64
49
  end
65
50
  end
@@ -12,7 +12,7 @@ describe Rack::OAuth2::Server::Authorize::Extension::IdTokenAndToken do
12
12
  :user_id => 'user_id',
13
13
  :aud => 'client_id',
14
14
  :exp => 1313424327
15
- )
15
+ ).to_jwt private_key
16
16
  end
17
17
 
18
18
  context "when id_token is given" do
@@ -21,31 +21,16 @@ describe Rack::OAuth2::Server::Authorize::Extension::IdTokenAndToken do
21
21
  response.redirect_uri = redirect_uri
22
22
  response.access_token = bearer_token
23
23
  response.id_token = id_token
24
- response.private_key = private_key
25
24
  response.approve!
26
25
  end
27
26
  end
28
27
  its(:status) { should == 302 }
29
- its(:location) { should == "#{redirect_uri}#access_token=access_token&id_token=#{id_token.to_jwt(private_key)}&token_type=bearer" }
28
+ its(:location) { should == "#{redirect_uri}#access_token=access_token&id_token=#{id_token}&token_type=bearer" }
30
29
 
31
30
  context 'when id_token is String' do
32
31
  let(:id_token) { 'id_token' }
33
32
  its(:location) { should == "#{redirect_uri}#access_token=access_token&id_token=id_token&token_type=bearer" }
34
33
  end
35
-
36
- context 'when private_key is missing' do
37
- let :app do
38
- Rack::OAuth2::Server::Authorize.new do |request, response|
39
- response.redirect_uri = redirect_uri
40
- response.access_token = bearer_token
41
- response.id_token = id_token
42
- response.approve!
43
- end
44
- end
45
- it do
46
- expect { response }.should raise_error AttrRequired::AttrMissing, "'private_key' required."
47
- end
48
- end
49
34
  end
50
35
 
51
36
  context "otherwise" do
@@ -57,7 +42,7 @@ describe Rack::OAuth2::Server::Authorize::Extension::IdTokenAndToken do
57
42
  end
58
43
  end
59
44
  it do
60
- expect { response }.should raise_error AttrRequired::AttrMissing, "'id_token', 'private_key' required."
45
+ expect { response }.should raise_error AttrRequired::AttrMissing, "'id_token' required."
61
46
  end
62
47
  end
63
48
  end
@@ -11,7 +11,7 @@ describe Rack::OAuth2::Server::Authorize::Extension::IdToken do
11
11
  :user_id => 'user_id',
12
12
  :aud => 'client_id',
13
13
  :exp => 1313424327
14
- )
14
+ ).to_jwt private_key
15
15
  end
16
16
 
17
17
  context "when id_token is given" do
@@ -19,30 +19,16 @@ describe Rack::OAuth2::Server::Authorize::Extension::IdToken do
19
19
  Rack::OAuth2::Server::Authorize.new do |request, response|
20
20
  response.redirect_uri = redirect_uri
21
21
  response.id_token = id_token
22
- response.private_key = private_key
23
22
  response.approve!
24
23
  end
25
24
  end
26
25
  its(:status) { should == 302 }
27
- its(:location) { should == "#{redirect_uri}#id_token=#{id_token.to_jwt(private_key)}" }
26
+ its(:location) { should == "#{redirect_uri}#id_token=#{id_token}" }
28
27
 
29
28
  context 'when id_token is String' do
30
29
  let(:id_token) { 'id_token' }
31
30
  its(:location) { should == "#{redirect_uri}#id_token=id_token" }
32
31
  end
33
-
34
- context 'when private_key is missing' do
35
- let :app do
36
- Rack::OAuth2::Server::Authorize.new do |request, response|
37
- response.redirect_uri = redirect_uri
38
- response.id_token = id_token
39
- response.approve!
40
- end
41
- end
42
- it do
43
- expect { response }.should raise_error AttrRequired::AttrMissing, "'private_key' required."
44
- end
45
- end
46
32
  end
47
33
 
48
34
  context "otherwise" do
@@ -53,7 +39,7 @@ describe Rack::OAuth2::Server::Authorize::Extension::IdToken do
53
39
  end
54
40
  end
55
41
  it do
56
- expect { response }.should raise_error AttrRequired::AttrMissing, "'id_token', 'private_key' required."
42
+ expect { response }.should raise_error AttrRequired::AttrMissing, "'id_token' required."
57
43
  end
58
44
  end
59
45
  end
@@ -18,7 +18,7 @@ describe Rack::OAuth2::Server::Token::AuthorizationCode do
18
18
  :aud => 'client_id',
19
19
  :exp => 1313424327,
20
20
  :secret => 'secret'
21
- )
21
+ ).to_jwt private_key
22
22
  end
23
23
 
24
24
  context "when id_token is given" do
@@ -26,28 +26,15 @@ describe Rack::OAuth2::Server::Token::AuthorizationCode do
26
26
  Rack::OAuth2::Server::Token.new do |request, response|
27
27
  response.access_token = Rack::OAuth2::AccessToken::Bearer.new(:access_token => 'access_token')
28
28
  response.id_token = id_token
29
- response.private_key = private_key
30
29
  end
31
30
  end
32
31
  its(:status) { should == 200 }
33
- its(:body) { should include "\"id_token\":\"#{id_token.to_jwt(private_key)}\"" }
32
+ its(:body) { should include "\"id_token\":\"#{id_token}\"" }
34
33
 
35
34
  context 'when id_token is String' do
36
35
  let(:id_token) { 'id_token' }
37
36
  its(:body) { should include "\"id_token\":\"id_token\"" }
38
37
  end
39
-
40
- context 'when private_key is missing' do
41
- let :app do
42
- Rack::OAuth2::Server::Token.new do |request, response|
43
- response.access_token = Rack::OAuth2::AccessToken::Bearer.new(:access_token => 'access_token')
44
- response.id_token = id_token
45
- end
46
- end
47
- it do
48
- expect { response }.should raise_error AttrRequired::AttrMissing, "'private_key' required."
49
- end
50
- end
51
38
  end
52
39
 
53
40
  context "otherwise" do
@@ -17,7 +17,7 @@ describe Rack::OAuth2::Server::Token::RefreshToken do
17
17
  :aud => 'client_id',
18
18
  :exp => 1313424327,
19
19
  :secret => 'secret'
20
- )
20
+ ).to_jwt private_key
21
21
  end
22
22
 
23
23
  context "when id_token is given" do
@@ -25,28 +25,15 @@ describe Rack::OAuth2::Server::Token::RefreshToken do
25
25
  Rack::OAuth2::Server::Token.new do |request, response|
26
26
  response.access_token = Rack::OAuth2::AccessToken::Bearer.new(:access_token => 'access_token')
27
27
  response.id_token = id_token
28
- response.private_key = private_key
29
28
  end
30
29
  end
31
30
  its(:status) { should == 200 }
32
- its(:body) { should include "\"id_token\":\"#{id_token.to_jwt(private_key)}\"" }
31
+ its(:body) { should include "\"id_token\":\"#{id_token}\"" }
33
32
 
34
33
  context 'when id_token is String' do
35
34
  let(:id_token) { 'id_token' }
36
35
  its(:body) { should include "\"id_token\":\"id_token\"" }
37
36
  end
38
-
39
- context 'when private_key is missing' do
40
- let :app do
41
- Rack::OAuth2::Server::Token.new do |request, response|
42
- response.access_token = Rack::OAuth2::AccessToken::Bearer.new(:access_token => 'access_token')
43
- response.id_token = id_token
44
- end
45
- end
46
- it do
47
- expect { response }.should raise_error AttrRequired::AttrMissing, "'private_key' required."
48
- end
49
- end
50
37
  end
51
38
 
52
39
  context "otherwise" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: openid_connect
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.27
5
+ version: 0.0.28
6
6
  platform: ruby
7
7
  authors:
8
8
  - nov matake
@@ -228,11 +228,9 @@ files:
228
228
  - spec/openid_connect/response_object_spec.rb
229
229
  - spec/openid_connect/server/id_token_spec.rb
230
230
  - spec/openid_connect_spec.rb
231
- - spec/rack/oauth2/server/authorize/code_and_token_spec.rb
232
231
  - spec/rack/oauth2/server/authorize/extension/code_and_id_token_spec.rb
233
232
  - spec/rack/oauth2/server/authorize/extension/id_token_and_token_spec.rb
234
233
  - spec/rack/oauth2/server/authorize/extension/id_token_spec.rb
235
- - spec/rack/oauth2/server/authorize/token_spec.rb
236
234
  - spec/rack/oauth2/server/token/authorization_code_spec.rb
237
235
  - spec/rack/oauth2/server/token/refresh_token_spec.rb
238
236
  - spec/spec_helper.rb
@@ -290,11 +288,9 @@ test_files:
290
288
  - spec/openid_connect/response_object_spec.rb
291
289
  - spec/openid_connect/server/id_token_spec.rb
292
290
  - spec/openid_connect_spec.rb
293
- - spec/rack/oauth2/server/authorize/code_and_token_spec.rb
294
291
  - spec/rack/oauth2/server/authorize/extension/code_and_id_token_spec.rb
295
292
  - spec/rack/oauth2/server/authorize/extension/id_token_and_token_spec.rb
296
293
  - spec/rack/oauth2/server/authorize/extension/id_token_spec.rb
297
- - spec/rack/oauth2/server/authorize/token_spec.rb
298
294
  - spec/rack/oauth2/server/token/authorization_code_spec.rb
299
295
  - spec/rack/oauth2/server/token/refresh_token_spec.rb
300
296
  - spec/spec_helper.rb
@@ -1,67 +0,0 @@
1
- require 'spec_helper.rb'
2
- require 'rack/oauth2/server/authorize/extension/code_and_token'
3
-
4
- describe Rack::OAuth2::Server::Authorize::Extension::CodeAndToken do
5
- subject { response }
6
- let(:request) { Rack::MockRequest.new app }
7
- let(:response) { request.get("/?response_type=code%20token&client_id=client") }
8
- let(:redirect_uri) { 'http://client.example.com/callback' }
9
- let(:bearer_token) { Rack::OAuth2::AccessToken::Bearer.new(:access_token => 'access_token') }
10
- let :id_token do
11
- OpenIDConnect::ResponseObject::IdToken.new(
12
- :iss => 'https://server.example.com',
13
- :user_id => 'user_id',
14
- :aud => 'client_id',
15
- :exp => 1313424327,
16
- :secret => 'secret'
17
- )
18
- end
19
-
20
- context "when id_token is given" do
21
- let :app do
22
- Rack::OAuth2::Server::Authorize.new do |request, response|
23
- response.redirect_uri = redirect_uri
24
- response.code = 'code'
25
- response.access_token = bearer_token
26
- response.id_token = id_token
27
- response.private_key = private_key
28
- response.approve!
29
- end
30
- end
31
- its(:status) { should == 302 }
32
- its(:location) { should == "#{redirect_uri}?code=code#access_token=access_token&id_token=#{id_token.to_jwt(private_key)}&token_type=bearer" }
33
-
34
- context 'when id_token is String' do
35
- let(:id_token) { 'id_token' }
36
- its(:location) { should == "#{redirect_uri}?code=code#access_token=access_token&id_token=id_token&token_type=bearer" }
37
- end
38
-
39
- context 'when private_key is missing' do
40
- let :app do
41
- Rack::OAuth2::Server::Authorize.new do |request, response|
42
- response.redirect_uri = redirect_uri
43
- response.code = 'code'
44
- response.access_token = bearer_token
45
- response.id_token = id_token
46
- response.approve!
47
- end
48
- end
49
- it do
50
- expect { response }.should raise_error AttrRequired::AttrMissing, "'private_key' required."
51
- end
52
- end
53
- end
54
-
55
- context "otherwise" do
56
- let :app do
57
- Rack::OAuth2::Server::Authorize.new do |request, response|
58
- response.redirect_uri = redirect_uri
59
- response.code = 'code'
60
- response.access_token = bearer_token
61
- response.approve!
62
- end
63
- end
64
- its(:status) { should == 302 }
65
- its(:location) { should == "#{redirect_uri}?code=code#access_token=access_token&token_type=bearer" }
66
- end
67
- end
@@ -1,62 +0,0 @@
1
- require 'spec_helper.rb'
2
-
3
- describe Rack::OAuth2::Server::Authorize::Token do
4
- subject { response }
5
- let(:request) { Rack::MockRequest.new app }
6
- let(:response) { request.get("/?response_type=token&client_id=client") }
7
- let(:redirect_uri) { 'http://client.example.com/callback' }
8
- let(:bearer_token) { Rack::OAuth2::AccessToken::Bearer.new(:access_token => 'access_token') }
9
- let :id_token do
10
- OpenIDConnect::ResponseObject::IdToken.new(
11
- :iss => 'https://server.example.com',
12
- :user_id => 'user_id',
13
- :aud => 'client_id',
14
- :exp => 1313424327
15
- )
16
- end
17
-
18
- context "when id_token is given" do
19
- let :app do
20
- Rack::OAuth2::Server::Authorize.new do |request, response|
21
- response.redirect_uri = redirect_uri
22
- response.access_token = bearer_token
23
- response.id_token = id_token
24
- response.private_key = private_key
25
- response.approve!
26
- end
27
- end
28
- its(:status) { should == 302 }
29
- its(:location) { should == "#{redirect_uri}#access_token=access_token&id_token=#{id_token.to_jwt(private_key)}&token_type=bearer" }
30
-
31
- context 'when id_token is String' do
32
- let(:id_token) { 'id_token' }
33
- its(:location) { should == "#{redirect_uri}#access_token=access_token&id_token=id_token&token_type=bearer" }
34
- end
35
-
36
- context 'when private_key is missing' do
37
- let :app do
38
- Rack::OAuth2::Server::Authorize.new do |request, response|
39
- response.redirect_uri = redirect_uri
40
- response.access_token = bearer_token
41
- response.id_token = id_token
42
- response.approve!
43
- end
44
- end
45
- it do
46
- expect { response }.should raise_error AttrRequired::AttrMissing, "'private_key' required."
47
- end
48
- end
49
- end
50
-
51
- context "otherwise" do
52
- let :app do
53
- Rack::OAuth2::Server::Authorize.new do |request, response|
54
- response.redirect_uri = redirect_uri
55
- response.access_token = bearer_token
56
- response.approve!
57
- end
58
- end
59
- its(:status) { should == 302 }
60
- its(:location) { should == "#{redirect_uri}#access_token=access_token&token_type=bearer" }
61
- end
62
- end