omniauth-oauth2 1.8.0 → 1.9.0

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: f5cd52cdcb930eb0df65da3d7659a8e46f19db3426e0ecd8b3565b51e951331f
4
- data.tar.gz: 6ed5b399aef49e82b265ff6175c849c44415f8b19f81ee5eb5d988ebb6c95fc8
3
+ metadata.gz: a61f10acb3f0765bd7f4e3eea6b6fa3cf4a0a882c5e2a09e37d17417050e9ff2
4
+ data.tar.gz: c558846dc4e8313e580b5ac32705da006227287ef5a0e20df63cf30df4bb8150
5
5
  SHA512:
6
- metadata.gz: e6bc5b97b326e37aa1e2ebb294b3459b57ba5dbb4d1e8b7e1709ed2dc9cfb8cc3b1b6f70ebbd0d5d830834af2472afe5b34762cf63f99a508334edee0d86b15a
7
- data.tar.gz: 5c6cea848d8c9895495f7e931a3acfcee6e5e773824714e4de8bacfdc7aa70c3e40ad5cbce92b9a0d115f1dbd1f26aea7dc2b7a7bc02b1050cf38c501c3b7d45
6
+ metadata.gz: e6fe7535a2b86388f19ff959bed28ec44582e6994bca1442e775c7cdbcb61158a6133a72d2fa86a60252432f05eb12080aa4fb78f01d5de1ae2137f97f07d25a
7
+ data.tar.gz: e2aadabef58d24f214bd83bcdb15426c1a93ac3e8009823285c304467168cfbe9de3ad3a51c6756bd382dadc129d57ab0fef00d0a218d1c5c1d27b19ce958d8d
@@ -8,60 +8,40 @@ on:
8
8
 
9
9
  jobs:
10
10
  test:
11
- runs-on: ubuntu-18.04
11
+ runs-on: ${{ matrix.os }}
12
+ timeout-minutes: 30
12
13
  strategy:
13
14
  fail-fast: false
14
15
  matrix:
15
- os: [ubuntu, macos]
16
- ruby: [2.5, 2.6, 2.7, '3.0', 3.1, head, debug, truffleruby, truffleruby-head]
16
+ os: [ubuntu-latest, macos-latest]
17
+ ruby: [2.5, 2.6, 2.7, '3.0', 3.1, 3.2, head, debug, truffleruby, truffleruby-head, jruby, jruby-head]
17
18
  steps:
18
- - uses: actions/checkout@v2
19
+ - uses: actions/checkout@v3
19
20
  - name: Set up Ruby
20
21
  uses: ruby/setup-ruby@v1
21
22
  with:
22
23
  ruby-version: ${{ matrix.ruby }}
23
24
  bundler-cache: true
24
- - name: Install dependencies
25
- run: bundle install
25
+ - name: Set JRUBY_OPTS environment variable
26
+ run: echo "JRUBY_OPTS=--debug" >> "$GITHUB_ENV"
27
+ if: ${{ startsWith(matrix.ruby, 'jruby') }}
26
28
  - name: Run tests
27
29
  run: bundle exec rake
28
- test-jruby:
29
- runs-on: ubuntu-18.04
30
- strategy:
31
- fail-fast: false
32
- matrix:
33
- os: [ubuntu, macos]
34
- jruby: [jruby, jruby-head]
35
- steps:
36
- - uses: actions/checkout@v2
37
- - name: Set up Ruby
38
- uses: ruby/setup-ruby@v1
30
+ - uses: actions/upload-artifact@v3
31
+ if: ${{ matrix.os == 'ubuntu-latest' && matrix.ruby == '3.0' }}
39
32
  with:
40
- ruby-version: ${{ matrix.jruby }}
41
- bundler-cache: true
42
- - name: Install dependencies
43
- env:
44
- JRUBY_OPTS: --debug
45
- run: bundle install
46
- - name: Run tests
47
- env:
48
- JRUBY_OPTS: --debug
49
- run: bundle exec rake
33
+ name: coverage
34
+ path: coverage/
35
+ retention-days: 1
36
+
50
37
  coveralls:
51
- runs-on: ubuntu-18.04
38
+ needs: test
39
+ runs-on: ubuntu-latest
40
+ timeout-minutes: 30
52
41
  steps:
53
- - uses: actions/checkout@v2
54
- - name: Set up Ruby
55
- uses: ruby/setup-ruby@v1
42
+ - uses: actions/download-artifact@v3
56
43
  with:
57
- ruby-version: 2.6
58
- bundler-cache: true
59
- - name: Install dependencies
60
- run: bundle install
61
- - name: Run tests
62
- run: bundle exec rake
44
+ name: coverage
45
+ path: coverage/
63
46
  - name: Coveralls GitHub Action
64
- uses: coverallsapp/github-action@v1.1.2
65
- with:
66
- github-token: ${{ secrets.github_token }}
67
- path-to-lcov: './coverage/lcov/omniauth-oauth2.lcov'
47
+ uses: coverallsapp/github-action@v2
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- ## [v1.8.0](https://github.com/omniauth/omniauth-oauth2/releases/tag/v1.7.3)
1
+ ## [v1.9.0](https://github.com/omniauth/omniauth-oauth2/releases/tag/v1.9.0)
2
+ - Prevent timing attacks [#174](https://github.com/omniauth/omniauth-oauth2/pull/174)
3
+ - Rescue OAuth2 timeouts [#169](https://github.com/omniauth/omniauth-oauth2/pull/169)
4
+
5
+ ## [v1.8.0](https://github.com/omniauth/omniauth-oauth2/releases/tag/v1.8.0)
2
6
  - Relaxes allowed versions of the oauth2 gem. [#146](https://github.com/omniauth/omniauth-oauth2/pull/146)
3
7
  - Requires omniauth `~> 2.0` [#152](https://github.com/omniauth/omniauth-oauth2/pull/152)
4
8
 
data/README.md CHANGED
@@ -72,4 +72,5 @@ Available as part of the Tidelift Subscription.
72
72
  The maintainers of OmniAuth-OAuth2 and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. [Learn more.](https://tidelift.com/subscription/pkg/rubygems-omniauth-oauth2?utm_source=undefined&utm_medium=referral&utm_campaign=enterprise)
73
73
 
74
74
  ## Supported Ruby Versions
75
- OmniAuth is tested under 2.5, 2.6, 2.7, truffleruby, and JRuby.
75
+
76
+ OmniAuth is tested under 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, truffleruby, and JRuby.
@@ -83,7 +83,7 @@ module OmniAuth
83
83
 
84
84
  def callback_phase # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
85
85
  error = request.params["error_reason"] || request.params["error"]
86
- if !options.provider_ignores_state && (request.params["state"].to_s.empty? || request.params["state"] != session.delete("omniauth.state"))
86
+ if !options.provider_ignores_state && (request.params["state"].to_s.empty? || !secure_compare(request.params["state"], session.delete("omniauth.state")))
87
87
  fail!(:csrf_detected, CallbackError.new(:csrf_detected, "CSRF detected"))
88
88
  elsif error
89
89
  fail!(error, CallbackError.new(request.params["error"], request.params["error_description"] || request.params["error_reason"], request.params["error_uri"]))
@@ -94,7 +94,7 @@ module OmniAuth
94
94
  end
95
95
  rescue ::OAuth2::Error, CallbackError => e
96
96
  fail!(:invalid_credentials, e)
97
- rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
97
+ rescue ::Timeout::Error, ::Errno::ETIMEDOUT, ::OAuth2::TimeoutError, ::OAuth2::ConnectionError => e
98
98
  fail!(:timeout, e)
99
99
  rescue ::SocketError => e
100
100
  fail!(:failed_to_connect, e)
@@ -144,6 +144,17 @@ module OmniAuth
144
144
  hash
145
145
  end
146
146
 
147
+ # constant-time comparison algorithm to prevent timing attacks
148
+ def secure_compare(string_a, string_b)
149
+ return false unless string_a.bytesize == string_b.bytesize
150
+
151
+ l = string_a.unpack "C#{string_a.bytesize}"
152
+
153
+ res = 0
154
+ string_b.each_byte { |byte| res |= byte ^ l.shift }
155
+ res.zero?
156
+ end
157
+
147
158
  # An error that is indicated in the OAuth 2.0 callback.
148
159
  # This could be a `redirect_uri_mismatch` or other
149
160
  class CallbackError < StandardError
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module OAuth2
3
- VERSION = "1.8.0".freeze
3
+ VERSION = "1.9.0".freeze
4
4
  end
5
5
  end
@@ -3,8 +3,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require "omniauth-oauth2/version"
4
4
 
5
5
  Gem::Specification.new do |gem|
6
- gem.add_dependency "oauth2", [">= 1.4", "< 3"]
7
- gem.add_dependency "omniauth", "~> 2.0"
6
+ gem.add_dependency "oauth2", [">= 2.0.2", "< 3"]
7
+ gem.add_dependency "omniauth", "~> 2.0"
8
8
 
9
9
  gem.add_development_dependency "bundler", "~> 2.0"
10
10
 
@@ -140,6 +140,43 @@ describe OmniAuth::Strategies::OAuth2 do
140
140
  expect(instance).to receive(:fail!).with(:csrf_detected, anything)
141
141
  instance.callback_phase
142
142
  end
143
+
144
+ describe 'exception handlings' do
145
+ let(:params) do
146
+ {"code" => "code", "state" => state}
147
+ end
148
+
149
+ before do
150
+ allow_any_instance_of(OmniAuth::Strategies::OAuth2).to receive(:build_access_token).and_raise(exception)
151
+ end
152
+
153
+ {
154
+ :invalid_credentials => [OAuth2::Error, OmniAuth::Strategies::OAuth2::CallbackError],
155
+ :timeout => [Timeout::Error, Errno::ETIMEDOUT, OAuth2::TimeoutError, OAuth2::ConnectionError],
156
+ :failed_to_connect => [SocketError]
157
+ }.each do |error_type, exceptions|
158
+ exceptions.each do |klass|
159
+ context "when #{klass}" do
160
+ let(:exception) { klass.new 'error' }
161
+
162
+ it do
163
+ expect(instance).to receive(:fail!).with(error_type, exception)
164
+ instance.callback_phase
165
+ end
166
+ end
167
+ end
168
+ end
169
+ end
170
+ end
171
+
172
+ describe "#secure_compare" do
173
+ subject { fresh_strategy }
174
+
175
+ it "returns true when the two inputs are the same and false otherwise" do
176
+ instance = subject.new("abc", "def")
177
+ expect(instance.send(:secure_compare, "a", "a")).to be true
178
+ expect(instance.send(:secure_compare, "b", "a")).to be false
179
+ end
143
180
  end
144
181
  end
145
182
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-06-18 00:00:00.000000000 Z
13
+ date: 2025-12-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: oauth2
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '1.4'
21
+ version: 2.0.2
22
22
  - - "<"
23
23
  - !ruby/object:Gem::Version
24
24
  version: '3'
@@ -28,7 +28,7 @@ dependencies:
28
28
  requirements:
29
29
  - - ">="
30
30
  - !ruby/object:Gem::Version
31
- version: '1.4'
31
+ version: 2.0.2
32
32
  - - "<"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '3'
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  requirements: []
108
- rubygems_version: 3.2.32
108
+ rubygems_version: 3.5.11
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: An abstract OAuth2 strategy for OmniAuth.