rack-oauth2 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 209bd4160af15825baf09e8e51de40eca26b339e
4
- data.tar.gz: e597b66535c13dbe4c2d0412c3360162bbfeb010
3
+ metadata.gz: d92edcb16d7166257558b555867bfc52c1770514
4
+ data.tar.gz: 25d1d5ee07b9fe8d2f50c93b6b6384439ef53053
5
5
  SHA512:
6
- metadata.gz: c1a9d718acc695b28e290f4da72eda80d158b7f6c39b94b82b6c4d02edc6e3bc9ad3d08c5c3eb4da1728a0a0ecc77ba994f4bc523c1fef6254d9ee3da3c63042
7
- data.tar.gz: 180bab02141d632c431cc90c9520effcc28dd013a18eb4d14c1499bc3e4c97b1e87e772a945d83ba9b95ae36baf870b14bbc32959516b76eeb663dbab8c16ca1
6
+ metadata.gz: 04d1fa45e23b7f7eafc051c84eb6d08df5234ee31c14cf06e1951df8a6a53cba636145649fbd748e7f610911b22a984a928166eb0f37e39b0d049d6b599b3de7
7
+ data.tar.gz: 5a45856133aed0ce20e9d8c5db3ebff15d2b5524c4bbb44a3731bf6986ce8ae5bb65f7125cba6bcdac9f14d808dc980c8ae7f5640330b522c37a428b82ea7e3f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.0
1
+ 1.7.1
@@ -64,6 +64,10 @@ module Rack
64
64
  )
65
65
  end
66
66
 
67
+ def force_token_type!(token_type)
68
+ @forced_token_type = token_type.to_s
69
+ end
70
+
67
71
  def access_token!(*args)
68
72
  headers, params = {}, @grant.as_json
69
73
 
@@ -119,7 +123,7 @@ module Rack
119
123
 
120
124
  def handle_success_response(response)
121
125
  token_hash = parse_json response.body
122
- case token_hash[:token_type].try(:downcase)
126
+ case (@forced_token_type || token_hash[:token_type]).try(:downcase)
123
127
  when 'bearer'
124
128
  AccessToken::Bearer.new(token_hash)
125
129
  when 'mac'
@@ -79,7 +79,7 @@ describe Rack::OAuth2::Client do
79
79
  describe '#access_token!' do
80
80
  subject { client.access_token! }
81
81
 
82
- context 'when *args given' do
82
+ context 'when *args given' do
83
83
 
84
84
  describe 'client authentication method' do
85
85
  before do
@@ -169,7 +169,7 @@ describe Rack::OAuth2::Client do
169
169
  end
170
170
 
171
171
  context 'when bearer token is given' do
172
- before do
172
+ before do
173
173
  client.authorization_code = 'code'
174
174
  mock_response(
175
175
  :post,
@@ -184,7 +184,7 @@ describe Rack::OAuth2::Client do
184
184
  its(:expires_in) { should == 3600 }
185
185
 
186
186
  context 'when token type is "Bearer", not "bearer"' do
187
- before do
187
+ before do
188
188
  client.authorization_code = 'code'
189
189
  mock_response(
190
190
  :post,
@@ -198,7 +198,7 @@ describe Rack::OAuth2::Client do
198
198
  end
199
199
 
200
200
  context 'when mac token is given' do
201
- before do
201
+ before do
202
202
  client.authorization_code = 'code'
203
203
  mock_response(
204
204
  :post,
@@ -214,7 +214,7 @@ describe Rack::OAuth2::Client do
214
214
  end
215
215
 
216
216
  context 'when no-type token is given (JSON)' do
217
- before do
217
+ before do
218
218
  client.authorization_code = 'code'
219
219
  mock_response(
220
220
  :post,
@@ -227,6 +227,14 @@ describe Rack::OAuth2::Client do
227
227
  its(:access_token) { should == 'access_token' }
228
228
  its(:refresh_token) { should == 'refresh_token' }
229
229
  its(:expires_in) { should == 3600 }
230
+
231
+ context 'when token_type is forced' do
232
+ before do
233
+ client.force_token_type! :bearer
234
+ end
235
+ it { should be_instance_of Rack::OAuth2::AccessToken::Bearer }
236
+ its(:token_type) { should == :bearer }
237
+ end
230
238
  end
231
239
 
232
240
  context 'when no-type token is given (key-value)' do
@@ -255,7 +263,7 @@ describe Rack::OAuth2::Client do
255
263
  end
256
264
 
257
265
  context 'when unknown-type token is given' do
258
- before do
266
+ before do
259
267
  client.authorization_code = 'code'
260
268
  mock_response(
261
269
  :post,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-26 00:00:00.000000000 Z
11
+ date: 2018-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -301,7 +301,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
301
  version: 1.3.6
302
302
  requirements: []
303
303
  rubyforge_project:
304
- rubygems_version: 2.6.13
304
+ rubygems_version: 2.6.11
305
305
  signing_key:
306
306
  specification_version: 4
307
307
  summary: OAuth 2.0 Server & Client Library - Both Bearer and MAC token type are supported