openid_connect 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/rack/oauth2/server/authorize/extension/code_and_id_token_and_token.rb +36 -0
- data/lib/rack/oauth2/server/id_token_response.rb +2 -0
- data/spec/rack/oauth2/server/authorize/extension/code_and_id_token_and_token_spec.rb +55 -0
- data/spec/rack/oauth2/server/authorize/extension/id_token_and_token_spec.rb +3 -4
- data/spec/rack/oauth2/server/authorize/extension/id_token_spec.rb +1 -2
- metadata +31 -28
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Rack
|
2
|
+
module OAuth2
|
3
|
+
module Server
|
4
|
+
class Authorize
|
5
|
+
module Extension
|
6
|
+
class CodeAndIdTokenAndToken < Abstract::Handler
|
7
|
+
class << self
|
8
|
+
def response_type_for?(response_type)
|
9
|
+
response_type.split.sort == ['code', 'id_token', 'token']
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
@request = Request.new env
|
15
|
+
@response = Response.new request
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
class Request < Authorize::Extension::CodeAndToken::Request
|
20
|
+
def initialize(env)
|
21
|
+
super
|
22
|
+
@response_type = [:code, :id_token, :token]
|
23
|
+
attr_missing!
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Response < Authorize::Extension::CodeAndToken::Response
|
28
|
+
include IdTokenResponse
|
29
|
+
attr_required :id_token
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -20,5 +20,7 @@ module Rack::OAuth2::Server
|
|
20
20
|
end
|
21
21
|
|
22
22
|
require 'rack/oauth2/server/authorize/extension/code_and_id_token'
|
23
|
+
require 'rack/oauth2/server/authorize/extension/code_and_token'
|
24
|
+
require 'rack/oauth2/server/authorize/extension/code_and_id_token_and_token'
|
23
25
|
require 'rack/oauth2/server/authorize/extension/id_token'
|
24
26
|
require 'rack/oauth2/server/authorize/extension/id_token_and_token'
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rack::OAuth2::Server::Authorize::Extension::CodeAndIdTokenAndToken do
|
4
|
+
subject { response }
|
5
|
+
let(:request) { Rack::MockRequest.new app }
|
6
|
+
let(:response) { request.get('/?response_type=code%20id_token%20token&client_id=client&state=state') }
|
7
|
+
let(:redirect_uri) { 'http://client.example.com/callback' }
|
8
|
+
let(:bearer_token) { Rack::OAuth2::AccessToken::Bearer.new(:access_token => 'access_token') }
|
9
|
+
let(:code) { 'authorization_code' }
|
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
|
+
:nonce => 'nonce',
|
16
|
+
:exp => 1313424327
|
17
|
+
).to_jwt private_key
|
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.id_token = id_token
|
26
|
+
response.access_token = bearer_token
|
27
|
+
response.approve!
|
28
|
+
end
|
29
|
+
end
|
30
|
+
its(:status) { should == 302 }
|
31
|
+
its(:location) { should include "#{redirect_uri}#" }
|
32
|
+
its(:location) { should include "access_token=#{bearer_token.access_token}" }
|
33
|
+
its(:location) { should include "id_token=#{id_token}" }
|
34
|
+
its(:location) { should include "token_type=#{bearer_token.token_type}" }
|
35
|
+
its(:location) { should include "code=#{code}" }
|
36
|
+
its(:location) { should include 'state=state' }
|
37
|
+
|
38
|
+
context 'when id_token is String' do
|
39
|
+
let(:id_token) { 'id_token' }
|
40
|
+
its(:location) { should include 'id_token=id_token' }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'otherwise' do
|
45
|
+
let :app do
|
46
|
+
Rack::OAuth2::Server::Authorize.new do |request, response|
|
47
|
+
response.redirect_uri = redirect_uri
|
48
|
+
response.approve!
|
49
|
+
end
|
50
|
+
end
|
51
|
+
it do
|
52
|
+
expect { response }.should raise_error AttrRequired::AttrMissing, "'access_token', 'code', 'id_token' required."
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -26,11 +26,10 @@ describe Rack::OAuth2::Server::Authorize::Extension::IdTokenAndToken do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
its(:status) { should == 302 }
|
29
|
-
its(:location) {
|
30
|
-
its(:location) { should include
|
31
|
-
its(:location) { should include 'access_token=access_token' }
|
29
|
+
its(:location) { should include "#{redirect_uri}#" }
|
30
|
+
its(:location) { should include "access_token=#{bearer_token.access_token}" }
|
32
31
|
its(:location) { should include "id_token=#{id_token}" }
|
33
|
-
its(:location) { should include
|
32
|
+
its(:location) { should include "token_type=#{bearer_token.token_type}" }
|
34
33
|
its(:location) { should include 'state=state' }
|
35
34
|
|
36
35
|
context 'when id_token is String' do
|
@@ -24,8 +24,7 @@ describe Rack::OAuth2::Server::Authorize::Extension::IdToken do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
its(:status) { should == 302 }
|
27
|
-
its(:location) {
|
28
|
-
its(:location) { should include '#' }
|
27
|
+
its(:location) { should include "#{redirect_uri}#" }
|
29
28
|
its(:location) { should include "id_token=#{id_token}" }
|
30
29
|
its(:location) { should include 'state=state' }
|
31
30
|
|
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.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &70121141941000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.4.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70121141941000
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: tzinfo
|
27
|
-
requirement: &
|
27
|
+
requirement: &70121141939640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70121141939640
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: attr_required
|
38
|
-
requirement: &
|
38
|
+
requirement: &70121141938520 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.0.5
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70121141938520
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activemodel
|
49
|
-
requirement: &
|
49
|
+
requirement: &70121141937300 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '3'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70121141937300
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: validate_url
|
60
|
-
requirement: &
|
60
|
+
requirement: &70121141931520 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70121141931520
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: validate_email
|
71
|
-
requirement: &
|
71
|
+
requirement: &70121141912840 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70121141912840
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: json-jwt
|
82
|
-
requirement: &
|
82
|
+
requirement: &70121141907020 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 0.0.3
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70121141907020
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: swd
|
93
|
-
requirement: &
|
93
|
+
requirement: &70121141903880 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 0.1.2
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70121141903880
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rack-oauth2
|
104
|
-
requirement: &
|
104
|
+
requirement: &70121141901320 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: 0.14.2
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70121141901320
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: rake
|
115
|
-
requirement: &
|
115
|
+
requirement: &70121141899780 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0.8'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70121141899780
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: cover_me
|
126
|
-
requirement: &
|
126
|
+
requirement: &70121141892320 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: 1.2.0
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *70121141892320
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: rspec
|
137
|
-
requirement: &
|
137
|
+
requirement: &70121141886580 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: '2'
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *70121141886580
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: webmock
|
148
|
-
requirement: &
|
148
|
+
requirement: &70121141874380 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,7 +153,7 @@ dependencies:
|
|
153
153
|
version: 1.6.2
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *70121141874380
|
157
157
|
description: OpenID Connect Server & Client Library
|
158
158
|
email:
|
159
159
|
- nov@matake.jp
|
@@ -192,6 +192,7 @@ files:
|
|
192
192
|
- lib/openid_connect/response_object/user_info/open_id.rb
|
193
193
|
- lib/openid_connect/response_object/user_info/open_id/address.rb
|
194
194
|
- lib/rack/oauth2/server/authorize/extension/code_and_id_token.rb
|
195
|
+
- lib/rack/oauth2/server/authorize/extension/code_and_id_token_and_token.rb
|
195
196
|
- lib/rack/oauth2/server/authorize/extension/id_token.rb
|
196
197
|
- lib/rack/oauth2/server/authorize/extension/id_token_and_token.rb
|
197
198
|
- lib/rack/oauth2/server/authorize/request_with_connect_params.rb
|
@@ -229,6 +230,7 @@ files:
|
|
229
230
|
- spec/openid_connect/response_object/user_info/open_id_spec.rb
|
230
231
|
- spec/openid_connect/response_object_spec.rb
|
231
232
|
- spec/openid_connect_spec.rb
|
233
|
+
- spec/rack/oauth2/server/authorize/extension/code_and_id_token_and_token_spec.rb
|
232
234
|
- spec/rack/oauth2/server/authorize/extension/code_and_id_token_spec.rb
|
233
235
|
- spec/rack/oauth2/server/authorize/extension/id_token_and_token_spec.rb
|
234
236
|
- spec/rack/oauth2/server/authorize/extension/id_token_spec.rb
|
@@ -292,6 +294,7 @@ test_files:
|
|
292
294
|
- spec/openid_connect/response_object/user_info/open_id_spec.rb
|
293
295
|
- spec/openid_connect/response_object_spec.rb
|
294
296
|
- spec/openid_connect_spec.rb
|
297
|
+
- spec/rack/oauth2/server/authorize/extension/code_and_id_token_and_token_spec.rb
|
295
298
|
- spec/rack/oauth2/server/authorize/extension/code_and_id_token_spec.rb
|
296
299
|
- spec/rack/oauth2/server/authorize/extension/id_token_and_token_spec.rb
|
297
300
|
- spec/rack/oauth2/server/authorize/extension/id_token_spec.rb
|