rack-oauth2 1.21.2 → 1.21.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bedb933d3946aef05d7ca583bd18b46941aebdf7fc0f8640be2f5909f9be4e9c
4
- data.tar.gz: 8740a613173e5edd0c98d79d1079b933d3eaee89b56369ae109d10841d7b94d8
3
+ metadata.gz: 7303cf85e66a7fb4a89d66d95b4ad35720ecb95459f9740208328314ea54b157
4
+ data.tar.gz: 061a4a30cbb25212979a37f26e18043cbf71dead3e36981b37f6152fc6899cfd
5
5
  SHA512:
6
- metadata.gz: 465ffccc2e5e41e396949947904f359a6d67d5637e6b0056a8bbca10f3b6755b14682fcad8092dddba7eabca72b66e1f66691b20a3351c79a7b1269abb478c07
7
- data.tar.gz: c0b6d79ad4c019fa58034d446acaf7ee2d6ec5b9cf77e5b8548f924cbbc544e34d6c09d6a2433e9ed5dbca7915b27280602ce8a62dda12722a9b28a3c6c07bb8
6
+ metadata.gz: 5fbabf81d770e80f02614d3b00b0fd9db8a63ed695a5b67b74266eee1f09ec6e7045db009ea7e6ee09af84680699809032ecc64d58caee48305573cd3532b5be
7
+ data.tar.gz: 5bc8cdbdddb9a997560eab574a955ab69d3ad8f9e594554a45d17e077991c2551382c917363c1c09db349abf262f5d9c15a7cfb13c24e56fe27d83cbde62f0f3
@@ -0,0 +1,30 @@
1
+ name: Spec
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ spec:
12
+ strategy:
13
+ matrix:
14
+ os: ['ubuntu-20.04']
15
+ ruby-version: ['2.6', '2.7', '3.0', '3.1']
16
+ # ubuntu 22.04 only supports ssl 3 and thus only ruby 3.1
17
+ include:
18
+ - os: 'ubuntu-22.04'
19
+ ruby-version: '3.1'
20
+ runs-on: ${{ matrix.os }}
21
+
22
+ steps:
23
+ - uses: actions/checkout@v3
24
+ - name: Set up Ruby
25
+ uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: ${{ matrix.ruby-version }}
28
+ bundler-cache: true
29
+ - name: Run Specs
30
+ run: bundle exec rake spec
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ before_install:
2
2
  - gem install bundler
3
3
 
4
4
  rvm:
5
- - 2.5.8
6
- - 2.6.6
7
- - 2.7.2
8
- - 3.0.2
5
+ - 2.6.10
6
+ - 2.7.6
7
+ - 3.0.4
8
+ - 3.1.2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.21.2
1
+ 1.21.3
@@ -27,7 +27,7 @@ module Rack
27
27
  response.status = status
28
28
  yield response if block_given?
29
29
  unless response.redirect?
30
- response.header['Content-Type'] = 'application/json'
30
+ response.headers['Content-Type'] = 'application/json'
31
31
  response.write Util.compact_hash(protocol_params).to_json
32
32
  end
33
33
  response.finish
@@ -21,9 +21,9 @@ module Rack
21
21
  end
22
22
  end
23
23
 
24
- def header
24
+ def headers
25
25
  ensure_finish do
26
- @header
26
+ @headers
27
27
  end
28
28
  end
29
29
 
@@ -39,7 +39,7 @@ module Rack
39
39
  end
40
40
 
41
41
  def ensure_finish
42
- @status, @header, @body = finish unless finished?
42
+ @status, @headers, @body = finish unless finished?
43
43
  yield
44
44
  end
45
45
  end
@@ -13,11 +13,11 @@ module Rack
13
13
  def finish
14
14
  super do |response|
15
15
  self.realm ||= DEFAULT_REALM
16
- header = response.header['WWW-Authenticate'] = "#{scheme} realm=\"#{realm}\""
16
+ headers = response.headers['WWW-Authenticate'] = "#{scheme} realm=\"#{realm}\""
17
17
  if ErrorMethods::DEFAULT_DESCRIPTION.keys.include?(error)
18
- header << ", error=\"#{error}\""
19
- header << ", error_description=\"#{description}\"" if description.present?
20
- header << ", error_uri=\"#{uri}\"" if uri.present?
18
+ headers << ", error=\"#{error}\""
19
+ headers << ", error_description=\"#{description}\"" if description.present?
20
+ headers << ", error_uri=\"#{uri}\"" if uri.present?
21
21
  end
22
22
  end
23
23
  end
@@ -9,7 +9,7 @@ module Rack
9
9
  def finish
10
10
  super do |response|
11
11
  unless @skip_www_authenticate
12
- response.header['WWW-Authenticate'] = 'Basic realm="OAuth2 Token Endpoint"'
12
+ response.headers['WWW-Authenticate'] = 'Basic realm="OAuth2 Token Endpoint"'
13
13
  end
14
14
  end
15
15
  end
@@ -80,9 +80,9 @@ module Rack
80
80
  def finish
81
81
  attr_missing!
82
82
  write Util.compact_hash(protocol_params).to_json
83
- header['Content-Type'] = 'application/json'
84
- header['Cache-Control'] = 'no-store'
85
- header['Pragma'] = 'no-cache'
83
+ headers['Content-Type'] = 'application/json'
84
+ headers['Cache-Control'] = 'no-store'
85
+ headers['Pragma'] = 'no-cache'
86
86
  super
87
87
  end
88
88
  end
@@ -188,7 +188,7 @@ describe Rack::OAuth2::Client do
188
188
  let :client do
189
189
  Rack::OAuth2::Client.new(
190
190
  identifier: 'client_id',
191
- private_key: OpenSSL::PKey::EC.new('prime256v1').generate_key,
191
+ private_key: OpenSSL::PKey::EC.generate('prime256v1'),
192
192
  host: 'server.example.com',
193
193
  redirect_uri: 'https://client.example.com/callback'
194
194
  )
@@ -23,27 +23,27 @@ describe Rack::OAuth2::Server::Authorize::BadRequest do
23
23
  context 'when protocol_params_location = :query' do
24
24
  before { error.protocol_params_location = :query }
25
25
  it 'should redirect with error in query' do
26
- state, header, response = error.finish
26
+ state, headers, response = error.finish
27
27
  state.should == 302
28
- header["Location"].should == "#{redirect_uri}?error=invalid_request"
28
+ headers["Location"].should == "#{redirect_uri}?error=invalid_request"
29
29
  end
30
30
  end
31
31
 
32
32
  context 'when protocol_params_location = :fragment' do
33
33
  before { error.protocol_params_location = :fragment }
34
34
  it 'should redirect with error in fragment' do
35
- state, header, response = error.finish
35
+ state, headers, response = error.finish
36
36
  state.should == 302
37
- header["Location"].should == "#{redirect_uri}#error=invalid_request"
37
+ headers["Location"].should == "#{redirect_uri}#error=invalid_request"
38
38
  end
39
39
  end
40
40
 
41
41
  context 'otherwise' do
42
42
  before { error.protocol_params_location = :other }
43
43
  it 'should redirect without error' do
44
- state, header, response = error.finish
44
+ state, headers, response = error.finish
45
45
  state.should == 302
46
- header["Location"].should == redirect_uri
46
+ headers["Location"].should == redirect_uri
47
47
  end
48
48
  end
49
49
  end
@@ -12,8 +12,8 @@ describe Rack::OAuth2::Server::Resource::Bearer::Unauthorized do
12
12
 
13
13
  describe '#finish' do
14
14
  it 'should use Bearer scheme' do
15
- status, header, response = error.finish
16
- header['WWW-Authenticate'].should include 'Bearer'
15
+ status, headers, response = error.finish
16
+ headers['WWW-Authenticate'].should include 'Bearer'
17
17
  end
18
18
  end
19
19
  end
@@ -22,29 +22,29 @@ describe Rack::OAuth2::Server::Resource::Bearer do
22
22
 
23
23
  shared_examples_for :authenticated_bearer_request do
24
24
  it 'should be authenticated' do
25
- status, header, response = request
25
+ status, headers, response = request
26
26
  status.should == 200
27
27
  access_token.should == bearer_token
28
28
  end
29
29
  end
30
30
  shared_examples_for :unauthorized_bearer_request do
31
31
  it 'should be unauthorized' do
32
- status, header, response = request
32
+ status, headers, response = request
33
33
  status.should == 401
34
- header['WWW-Authenticate'].should include 'Bearer'
34
+ headers['WWW-Authenticate'].should include 'Bearer'
35
35
  access_token.should be_nil
36
36
  end
37
37
  end
38
38
  shared_examples_for :bad_bearer_request do
39
39
  it 'should be bad_request' do
40
- status, header, response = request
40
+ status, headers, response = request
41
41
  status.should == 400
42
42
  access_token.should be_nil
43
43
  end
44
44
  end
45
45
  shared_examples_for :skipped_authentication_request do
46
46
  it 'should skip OAuth 2.0 authentication' do
47
- status, header, response = request
47
+ status, headers, response = request
48
48
  status.should == 200
49
49
  access_token.should be_nil
50
50
  end
@@ -94,15 +94,15 @@ describe Rack::OAuth2::Server::Resource::Bearer do
94
94
  end
95
95
  end
96
96
  it 'should use specified realm' do
97
- status, header, response = request
98
- header['WWW-Authenticate'].should include "Bearer realm=\"#{realm}\""
97
+ status, headers, response = request
98
+ headers['WWW-Authenticate'].should include "Bearer realm=\"#{realm}\""
99
99
  end
100
100
  end
101
101
 
102
102
  context 'otherwize' do
103
103
  it 'should use default realm' do
104
- status, header, response = request
105
- header['WWW-Authenticate'].should include "Bearer realm=\"#{Rack::OAuth2::Server::Resource::Bearer::DEFAULT_REALM}\""
104
+ status, headers, response = request
105
+ headers['WWW-Authenticate'].should include "Bearer realm=\"#{Rack::OAuth2::Server::Resource::Bearer::DEFAULT_REALM}\""
106
106
  end
107
107
  end
108
108
  end
@@ -7,9 +7,9 @@ describe Rack::OAuth2::Server::Resource::BadRequest do
7
7
 
8
8
  describe '#finish' do
9
9
  it 'should respond in JSON' do
10
- status, header, response = error.finish
10
+ status, headers, response = error.finish
11
11
  status.should == 400
12
- header['Content-Type'].should == 'application/json'
12
+ headers['Content-Type'].should == 'application/json'
13
13
  response.should == ['{"error":"invalid_request"}']
14
14
  end
15
15
  end
@@ -40,10 +40,10 @@ describe Rack::OAuth2::Server::Resource::Unauthorized do
40
40
 
41
41
  describe '#finish' do
42
42
  it 'should respond in JSON' do
43
- status, header, response = error_with_scheme.finish
43
+ status, headers, response = error_with_scheme.finish
44
44
  status.should == 401
45
- header['Content-Type'].should == 'application/json'
46
- header['WWW-Authenticate'].should == "Scheme realm=\"#{realm}\", error=\"invalid_token\""
45
+ headers['Content-Type'].should == 'application/json'
46
+ headers['WWW-Authenticate'].should == "Scheme realm=\"#{realm}\", error=\"invalid_token\""
47
47
  response.should == ['{"error":"invalid_token"}']
48
48
  end
49
49
 
@@ -51,8 +51,8 @@ describe Rack::OAuth2::Server::Resource::Unauthorized do
51
51
  let(:error) { Rack::OAuth2::Server::Resource::Unauthorized.new(:something) }
52
52
 
53
53
  it 'should have error_code in body but not in WWW-Authenticate header' do
54
- status, header, response = error_with_scheme.finish
55
- header['WWW-Authenticate'].should == "Scheme realm=\"#{realm}\""
54
+ status, headers, response = error_with_scheme.finish
55
+ headers['WWW-Authenticate'].should == "Scheme realm=\"#{realm}\""
56
56
  response.first.should include '"error":"something"'
57
57
  end
58
58
  end
@@ -61,8 +61,8 @@ describe Rack::OAuth2::Server::Resource::Unauthorized do
61
61
  let(:error) { Rack::OAuth2::Server::Resource::Unauthorized.new }
62
62
 
63
63
  it 'should have error_code in body but not in WWW-Authenticate header' do
64
- status, header, response = error_with_scheme.finish
65
- header['WWW-Authenticate'].should == "Scheme realm=\"#{realm}\""
64
+ status, headers, response = error_with_scheme.finish
65
+ headers['WWW-Authenticate'].should == "Scheme realm=\"#{realm}\""
66
66
  response.first.should == '{"error":"unauthorized"}'
67
67
  end
68
68
  end
@@ -72,8 +72,8 @@ describe Rack::OAuth2::Server::Resource::Unauthorized do
72
72
  let(:error) { Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new(:something, nil, realm: realm) }
73
73
 
74
74
  it 'should use given realm' do
75
- status, header, response = error_with_scheme.finish
76
- header['WWW-Authenticate'].should == "Scheme realm=\"#{realm}\""
75
+ status, headers, response = error_with_scheme.finish
76
+ headers['WWW-Authenticate'].should == "Scheme realm=\"#{realm}\""
77
77
  response.first.should include '"error":"something"'
78
78
  end
79
79
  end
@@ -88,9 +88,9 @@ describe Rack::OAuth2::Server::Resource::Forbidden do
88
88
 
89
89
  describe '#finish' do
90
90
  it 'should respond in JSON' do
91
- status, header, response = error.finish
91
+ status, headers, response = error.finish
92
92
  status.should == 403
93
- header['Content-Type'].should == 'application/json'
93
+ headers['Content-Type'].should == 'application/json'
94
94
  response.should == ['{"error":"insufficient_scope"}']
95
95
  end
96
96
  end
@@ -99,7 +99,7 @@ describe Rack::OAuth2::Server::Resource::Forbidden do
99
99
  let(:error) { Rack::OAuth2::Server::Resource::Bearer::Forbidden.new(:insufficient_scope, 'Desc', scope: [:scope1, :scope2]) }
100
100
 
101
101
  it 'should have blank WWW-Authenticate header' do
102
- status, header, response = error.finish
102
+ status, headers, response = error.finish
103
103
  response.first.should include '"scope":"scope1 scope2"'
104
104
  end
105
105
  end
@@ -12,8 +12,8 @@ describe Rack::OAuth2::Server::Resource::MAC::Unauthorized do
12
12
 
13
13
  describe '#finish' do
14
14
  it 'should use MAC scheme' do
15
- status, header, response = error.finish
16
- header['WWW-Authenticate'].should =~ /^MAC /
15
+ status, headers, response = error.finish
16
+ headers['WWW-Authenticate'].should =~ /^MAC /
17
17
  end
18
18
  end
19
19
  end
@@ -29,29 +29,29 @@ describe Rack::OAuth2::Server::Resource::MAC do
29
29
 
30
30
  shared_examples_for :non_mac_request do
31
31
  it 'should skip OAuth 2.0 authentication' do
32
- status, header, response = request
32
+ status, headers, response = request
33
33
  status.should == 200
34
34
  access_token.should be_nil
35
35
  end
36
36
  end
37
37
  shared_examples_for :authenticated_mac_request do
38
38
  it 'should be authenticated' do
39
- status, header, response = request
39
+ status, headers, response = request
40
40
  status.should == 200
41
41
  access_token.should == mac_token
42
42
  end
43
43
  end
44
44
  shared_examples_for :unauthorized_mac_request do
45
45
  it 'should be unauthorized' do
46
- status, header, response = request
46
+ status, headers, response = request
47
47
  status.should == 401
48
- header['WWW-Authenticate'].should include 'MAC'
48
+ headers['WWW-Authenticate'].should include 'MAC'
49
49
  access_token.should be_nil
50
50
  end
51
51
  end
52
52
  shared_examples_for :bad_mac_request do
53
53
  it 'should be unauthorized' do
54
- status, header, response = request
54
+ status, headers, response = request
55
55
  status.should == 400
56
56
  access_token.should be_nil
57
57
  end
@@ -60,7 +60,7 @@ describe Rack::OAuth2::Server::Resource::MAC do
60
60
  context 'when no access token is given' do
61
61
  let(:env) { Rack::MockRequest.env_for('/protected_resource') }
62
62
  it 'should skip OAuth 2.0 authentication' do
63
- status, header, response = request
63
+ status, headers, response = request
64
64
  status.should == 200
65
65
  access_token.should be_nil
66
66
  end
@@ -103,15 +103,15 @@ describe Rack::OAuth2::Server::Resource::MAC do
103
103
  end
104
104
  end
105
105
  it 'should use specified realm' do
106
- status, header, response = request
107
- header['WWW-Authenticate'].should include "MAC realm=\"#{realm}\""
106
+ status, headers, response = request
107
+ headers['WWW-Authenticate'].should include "MAC realm=\"#{realm}\""
108
108
  end
109
109
  end
110
110
 
111
111
  context 'otherwize' do
112
112
  it 'should use default realm' do
113
- status, header, response = request
114
- header['WWW-Authenticate'].should include "MAC realm=\"#{Rack::OAuth2::Server::Resource::DEFAULT_REALM}\""
113
+ status, headers, response = request
114
+ headers['WWW-Authenticate'].should include "MAC realm=\"#{Rack::OAuth2::Server::Resource::DEFAULT_REALM}\""
115
115
  end
116
116
  end
117
117
  end
@@ -24,8 +24,8 @@ describe Rack::OAuth2::Server::Token::AuthorizationCode do
24
24
  its(:body) { should include '"token_type":"bearer"' }
25
25
 
26
26
  it 'should prevent to be cached' do
27
- response.header['Cache-Control'].should == 'no-store'
28
- response.header['Pragma'].should == 'no-cache'
27
+ response.headers['Cache-Control'].should == 'no-store'
28
+ response.headers['Pragma'].should == 'no-cache'
29
29
  end
30
30
 
31
31
  [:code].each do |required|
@@ -7,9 +7,9 @@ describe Rack::OAuth2::Server::Token::BadRequest do
7
7
 
8
8
  describe '#finish' do
9
9
  it 'should respond in JSON' do
10
- status, header, response = error.finish
10
+ status, headers, response = error.finish
11
11
  status.should == 400
12
- header['Content-Type'].should == 'application/json'
12
+ headers['Content-Type'].should == 'application/json'
13
13
  response.should == ['{"error":"invalid_request"}']
14
14
  end
15
15
  end
@@ -22,10 +22,10 @@ describe Rack::OAuth2::Server::Token::Unauthorized do
22
22
 
23
23
  describe '#finish' do
24
24
  it 'should respond in JSON' do
25
- status, header, response = error.finish
25
+ status, headers, response = error.finish
26
26
  status.should == 401
27
- header['Content-Type'].should == 'application/json'
28
- header['WWW-Authenticate'].should == 'Basic realm="OAuth2 Token Endpoint"'
27
+ headers['Content-Type'].should == 'application/json'
28
+ headers['WWW-Authenticate'].should == 'Basic realm="OAuth2 Token Endpoint"'
29
29
  response.should == ['{"error":"invalid_request"}']
30
30
  end
31
31
  end
@@ -28,7 +28,7 @@ describe Rack::OAuth2::Server::Token do
28
28
  )
29
29
  end
30
30
  it 'should fail with unsupported_grant_type' do
31
- status, header, response = app.call(env)
31
+ status, headers, response = app.call(env)
32
32
  status.should == 400
33
33
  response.first.should include '"error":"invalid_request"'
34
34
  end
@@ -43,7 +43,7 @@ describe Rack::OAuth2::Server::Token do
43
43
  )
44
44
  end
45
45
  it 'should ignore duplicates' do
46
- status, header, response = app.call(env)
46
+ status, headers, response = app.call(env)
47
47
  status.should == 200
48
48
  end
49
49
  end
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.21.2
4
+ version: 1.21.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-12 00:00:00.000000000 Z
11
+ date: 2022-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -175,6 +175,7 @@ extra_rdoc_files:
175
175
  files:
176
176
  - ".document"
177
177
  - ".github/FUNDING.yml"
178
+ - ".github/workflows/spec.yml"
178
179
  - ".gitignore"
179
180
  - ".rspec"
180
181
  - ".travis.yml"
@@ -300,7 +301,7 @@ homepage: https://github.com/nov/rack-oauth2
300
301
  licenses:
301
302
  - MIT
302
303
  metadata: {}
303
- post_install_message:
304
+ post_install_message:
304
305
  rdoc_options:
305
306
  - "--charset=UTF-8"
306
307
  require_paths:
@@ -316,8 +317,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
317
  - !ruby/object:Gem::Version
317
318
  version: '0'
318
319
  requirements: []
319
- rubygems_version: 3.1.6
320
- signing_key:
320
+ rubygems_version: 3.3.7
321
+ signing_key:
321
322
  specification_version: 4
322
323
  summary: OAuth 2.0 Server & Client Library - Both Bearer and MAC token type are supported
323
324
  test_files: