openid_connect 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openid_connect (0.0.18)
4
+ openid_connect (0.0.19)
5
5
  activemodel (>= 3)
6
6
  attr_required (>= 0.0.3)
7
7
  json (>= 1.4.3)
8
8
  jwt (>= 0.1.3)
9
- rack-oauth2 (>= 0.9.3)
9
+ rack-oauth2 (>= 0.9.4)
10
10
  swd (>= 0.0.4)
11
11
  tzinfo
12
12
  validate_email
@@ -46,7 +46,7 @@ GEM
46
46
  multi_json (1.0.3)
47
47
  polyglot (0.3.2)
48
48
  rack (1.3.2)
49
- rack-oauth2 (0.9.3)
49
+ rack-oauth2 (0.9.4)
50
50
  activesupport (>= 2.3)
51
51
  attr_required (>= 0.0.3)
52
52
  httpclient (>= 2.2.0.2)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.19
1
+ 0.0.20
@@ -17,6 +17,7 @@ module OpenIDConnect
17
17
  @@debugging
18
18
  end
19
19
  def self.debugging=(boolean)
20
+ Rack::OAuth2.debugging = boolean
20
21
  @@debugging = boolean
21
22
  end
22
23
  def self.debug!
@@ -41,3 +42,4 @@ require 'openid_connect/access_token'
41
42
  require 'openid_connect/response_object'
42
43
  require 'openid_connect/server'
43
44
  require 'openid_connect/discovery'
45
+ require 'openid_connect/debugger'
@@ -0,0 +1,3 @@
1
+ Dir[File.dirname(__FILE__) + '/debugger/*.rb'].each do |file|
2
+ require file
3
+ end
@@ -0,0 +1,20 @@
1
+ module OpenIDConnect
2
+ module Debugger
3
+ class RequestFilter
4
+ # Callback called in HTTPClient (before sending a request)
5
+ # request:: HTTP::Message
6
+ def filter_request(request)
7
+ started = "======= [OpenIDConnect] HTTP REQUEST STARTED ======="
8
+ OpenIDConnect.logger.info [started, request.dump].join("\n")
9
+ end
10
+
11
+ # Callback called in HTTPClient (after received a response)
12
+ # request:: HTTP::Message
13
+ # response:: HTTP::Message
14
+ def filter_response(request, response)
15
+ finished = "======= [OpenIDConnect] HTTP REQUEST FINISHED ======="
16
+ OpenIDConnect.logger.info ['-' * 50, response.dump, finished].join("\n")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -29,8 +29,10 @@ module OpenIDConnect
29
29
  def from_jwt(jwt_string, key_or_client)
30
30
  attributes = case key_or_client
31
31
  when Client
32
+ http_client = HTTPClient.new
33
+ http_client.request_filter << Debugger::RequestFilter
32
34
  resource_request do
33
- HTTPClient.new.post key_or_client.check_session_uri, :id_token => jwt_string
35
+ http_client.post key_or_client.check_session_uri, :id_token => jwt_string
34
36
  end
35
37
  else
36
38
  JWT.decode(jwt_string, key_or_client).with_indifferent_access
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.add_runtime_dependency "validate_email"
19
19
  s.add_runtime_dependency "jwt", ">= 0.1.3"
20
20
  s.add_runtime_dependency "swd", ">= 0.0.4"
21
- s.add_runtime_dependency "rack-oauth2", ">= 0.9.3"
21
+ s.add_runtime_dependency "rack-oauth2", ">= 0.9.4"
22
22
  s.add_development_dependency "rake", ">= 0.8"
23
23
  s.add_development_dependency "rcov", ">= 0.9"
24
24
  s.add_development_dependency "rspec", ">= 2"
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe OpenIDConnect::Debugger::RequestFilter do
4
+ let(:resource_endpoint) { 'https://example.com/resources' }
5
+ let(:request) { HTTP::Message.new_request(:get, URI.parse(resource_endpoint)) }
6
+ let(:response) { HTTP::Message.new_response({:hello => 'world'}.to_json) }
7
+ let(:request_filter) { OpenIDConnect::Debugger::RequestFilter.new }
8
+
9
+ describe '#filter_request' do
10
+ it 'should log request' do
11
+ OpenIDConnect.logger.should_receive(:info).with(
12
+ "======= [OpenIDConnect] HTTP REQUEST STARTED =======\n" +
13
+ request.dump
14
+ )
15
+ request_filter.filter_request(request)
16
+ end
17
+ end
18
+
19
+ describe '#filter_response' do
20
+ it 'should log response' do
21
+ OpenIDConnect.logger.should_receive(:info).with(
22
+ "--------------------------------------------------\n" +
23
+ response.dump +
24
+ "\n======= [OpenIDConnect] HTTP REQUEST FINISHED ======="
25
+ )
26
+ request_filter.filter_response(request, response)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe OpenIDConnect do
4
+ subject { OpenIDConnect }
5
+ after { OpenIDConnect.debugging = false }
6
+
7
+ its(:logger) { should be_a Logger }
8
+ its(:debugging?) { should be_false }
9
+
10
+ describe '.debug!' do
11
+ before { OpenIDConnect.debug! }
12
+ its(:debugging?) { should be_true }
13
+ end
14
+
15
+ describe '.debug' do
16
+ it 'should enable debugging within given block' do
17
+ OpenIDConnect.debug do
18
+ Rack::OAuth2.debugging?.should be_true
19
+ OpenIDConnect.debugging?.should be_true
20
+ end
21
+ Rack::OAuth2.debugging?.should be_false
22
+ OpenIDConnect.debugging?.should be_false
23
+ end
24
+
25
+ it 'should not force disable debugging' do
26
+ Rack::OAuth2.debug!
27
+ OpenIDConnect.debug!
28
+ OpenIDConnect.debug do
29
+ Rack::OAuth2.debugging?.should be_true
30
+ OpenIDConnect.debugging?.should be_true
31
+ end
32
+ Rack::OAuth2.debugging?.should be_true
33
+ OpenIDConnect.debugging?.should be_true
34
+ end
35
+ end
36
+ end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openid_connect
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 55
4
5
  prerelease:
5
- version: 0.0.19
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 20
10
+ version: 0.0.20
6
11
  platform: ruby
7
12
  authors:
8
13
  - nov matake
@@ -20,6 +25,11 @@ dependencies:
20
25
  requirements:
21
26
  - - ">="
22
27
  - !ruby/object:Gem::Version
28
+ hash: 1
29
+ segments:
30
+ - 1
31
+ - 4
32
+ - 3
23
33
  version: 1.4.3
24
34
  type: :runtime
25
35
  version_requirements: *id001
@@ -31,6 +41,9 @@ dependencies:
31
41
  requirements:
32
42
  - - ">="
33
43
  - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
34
47
  version: "0"
35
48
  type: :runtime
36
49
  version_requirements: *id002
@@ -42,6 +55,11 @@ dependencies:
42
55
  requirements:
43
56
  - - ">="
44
57
  - !ruby/object:Gem::Version
58
+ hash: 25
59
+ segments:
60
+ - 0
61
+ - 0
62
+ - 3
45
63
  version: 0.0.3
46
64
  type: :runtime
47
65
  version_requirements: *id003
@@ -53,6 +71,9 @@ dependencies:
53
71
  requirements:
54
72
  - - ">="
55
73
  - !ruby/object:Gem::Version
74
+ hash: 5
75
+ segments:
76
+ - 3
56
77
  version: "3"
57
78
  type: :runtime
58
79
  version_requirements: *id004
@@ -64,6 +85,9 @@ dependencies:
64
85
  requirements:
65
86
  - - ">="
66
87
  - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
67
91
  version: "0"
68
92
  type: :runtime
69
93
  version_requirements: *id005
@@ -75,6 +99,9 @@ dependencies:
75
99
  requirements:
76
100
  - - ">="
77
101
  - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
78
105
  version: "0"
79
106
  type: :runtime
80
107
  version_requirements: *id006
@@ -86,6 +113,11 @@ dependencies:
86
113
  requirements:
87
114
  - - ">="
88
115
  - !ruby/object:Gem::Version
116
+ hash: 29
117
+ segments:
118
+ - 0
119
+ - 1
120
+ - 3
89
121
  version: 0.1.3
90
122
  type: :runtime
91
123
  version_requirements: *id007
@@ -97,6 +129,11 @@ dependencies:
97
129
  requirements:
98
130
  - - ">="
99
131
  - !ruby/object:Gem::Version
132
+ hash: 23
133
+ segments:
134
+ - 0
135
+ - 0
136
+ - 4
100
137
  version: 0.0.4
101
138
  type: :runtime
102
139
  version_requirements: *id008
@@ -108,7 +145,12 @@ dependencies:
108
145
  requirements:
109
146
  - - ">="
110
147
  - !ruby/object:Gem::Version
111
- version: 0.9.3
148
+ hash: 51
149
+ segments:
150
+ - 0
151
+ - 9
152
+ - 4
153
+ version: 0.9.4
112
154
  type: :runtime
113
155
  version_requirements: *id009
114
156
  - !ruby/object:Gem::Dependency
@@ -119,6 +161,10 @@ dependencies:
119
161
  requirements:
120
162
  - - ">="
121
163
  - !ruby/object:Gem::Version
164
+ hash: 27
165
+ segments:
166
+ - 0
167
+ - 8
122
168
  version: "0.8"
123
169
  type: :development
124
170
  version_requirements: *id010
@@ -130,6 +176,10 @@ dependencies:
130
176
  requirements:
131
177
  - - ">="
132
178
  - !ruby/object:Gem::Version
179
+ hash: 25
180
+ segments:
181
+ - 0
182
+ - 9
133
183
  version: "0.9"
134
184
  type: :development
135
185
  version_requirements: *id011
@@ -141,6 +191,9 @@ dependencies:
141
191
  requirements:
142
192
  - - ">="
143
193
  - !ruby/object:Gem::Version
194
+ hash: 7
195
+ segments:
196
+ - 2
144
197
  version: "2"
145
198
  type: :development
146
199
  version_requirements: *id012
@@ -152,6 +205,11 @@ dependencies:
152
205
  requirements:
153
206
  - - ">="
154
207
  - !ruby/object:Gem::Version
208
+ hash: 11
209
+ segments:
210
+ - 1
211
+ - 6
212
+ - 2
155
213
  version: 1.6.2
156
214
  type: :development
157
215
  version_requirements: *id013
@@ -177,6 +235,8 @@ files:
177
235
  - lib/openid_connect.rb
178
236
  - lib/openid_connect/access_token.rb
179
237
  - lib/openid_connect/client.rb
238
+ - lib/openid_connect/debugger.rb
239
+ - lib/openid_connect/debugger/request_filter.rb
180
240
  - lib/openid_connect/discovery.rb
181
241
  - lib/openid_connect/discovery/principal.rb
182
242
  - lib/openid_connect/discovery/principal/email.rb
@@ -213,6 +273,7 @@ files:
213
273
  - spec/mock_response/user_info/openid.json
214
274
  - spec/openid_connect/access_token_spec.rb
215
275
  - spec/openid_connect/client_spec.rb
276
+ - spec/openid_connect/debugger/request_filter_spec.rb
216
277
  - spec/openid_connect/discovery/principal/email_spec.rb
217
278
  - spec/openid_connect/discovery/principal/uri_spec.rb
218
279
  - spec/openid_connect/discovery/principal/xri_spec.rb
@@ -224,6 +285,7 @@ files:
224
285
  - spec/openid_connect/response_object/user_info/open_id_spec.rb
225
286
  - spec/openid_connect/response_object_spec.rb
226
287
  - spec/openid_connect/server/id_token_spec.rb
288
+ - spec/openid_connect_spec.rb
227
289
  - spec/rack/oauth2/server/authorize/code_and_token_spec.rb
228
290
  - spec/rack/oauth2/server/authorize/extension/code_and_id_token_spec.rb
229
291
  - spec/rack/oauth2/server/authorize/extension/id_token_and_token_spec.rb
@@ -245,17 +307,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
245
307
  requirements:
246
308
  - - ">="
247
309
  - !ruby/object:Gem::Version
310
+ hash: 3
311
+ segments:
312
+ - 0
248
313
  version: "0"
249
314
  required_rubygems_version: !ruby/object:Gem::Requirement
250
315
  none: false
251
316
  requirements:
252
317
  - - ">="
253
318
  - !ruby/object:Gem::Version
319
+ hash: 3
320
+ segments:
321
+ - 0
254
322
  version: "0"
255
323
  requirements: []
256
324
 
257
325
  rubyforge_project:
258
- rubygems_version: 1.8.10
326
+ rubygems_version: 1.8.5
259
327
  signing_key:
260
328
  specification_version: 3
261
329
  summary: OpenID Connect Server & Client Library
@@ -273,6 +341,7 @@ test_files:
273
341
  - spec/mock_response/user_info/openid.json
274
342
  - spec/openid_connect/access_token_spec.rb
275
343
  - spec/openid_connect/client_spec.rb
344
+ - spec/openid_connect/debugger/request_filter_spec.rb
276
345
  - spec/openid_connect/discovery/principal/email_spec.rb
277
346
  - spec/openid_connect/discovery/principal/uri_spec.rb
278
347
  - spec/openid_connect/discovery/principal/xri_spec.rb
@@ -284,6 +353,7 @@ test_files:
284
353
  - spec/openid_connect/response_object/user_info/open_id_spec.rb
285
354
  - spec/openid_connect/response_object_spec.rb
286
355
  - spec/openid_connect/server/id_token_spec.rb
356
+ - spec/openid_connect_spec.rb
287
357
  - spec/rack/oauth2/server/authorize/code_and_token_spec.rb
288
358
  - spec/rack/oauth2/server/authorize/extension/code_and_id_token_spec.rb
289
359
  - spec/rack/oauth2/server/authorize/extension/id_token_and_token_spec.rb