omniauth-google-oauth2 1.1.2 → 1.2.1

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: adbd87cbf3dc07abbc3f14d2923a655b78cae9701432c0f0866e959eeb946606
4
- data.tar.gz: f4b975b570dd5b96032402766be88e8537f419ea361564275b2e84b97bd2cdb9
3
+ metadata.gz: fb04de5f033f4c247c0cd004619d2e8cbb9f54b29a1861c5810d539608c278c0
4
+ data.tar.gz: a0a71c285455501e4904ea4c184db32298907be93f1def96d3a180ca60df9684
5
5
  SHA512:
6
- metadata.gz: 0445f4e07feba58d9b850dcf6d0a45e256a9e6557de6f5a248b0ac8e42004446eb9bc31cfa3dd3f61cb0baab276b3d85b17f302863f81f0560c4532f58a05115
7
- data.tar.gz: 4a7c65a13c017c7da47d8a82e86615e51af46c32d20dcf25d4fcc6451b81299a63c291b78b3b956ddc4c015d97e2d2c855efa6647ad29f7cda25171746231e4a
6
+ metadata.gz: 3cd913d3979e3c3e9dd93f76ed40aeff42bc95a8841db4b4287e92d28a00fe85a4bbc14483b25478fbdde0552877617d4b32c57eb03c67472e43fd857c1e9180
7
+ data.tar.gz: '0078d9d52c2661b12895509ce17320818360aa968904742d45665158334af0a219064999cabe71e1af9ce93cddd45481b7aee263d729d582f99d088b68242905'
@@ -0,0 +1 @@
1
+ github: [zquestz]
@@ -7,7 +7,7 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', truffleruby-head]
10
+ ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', truffleruby-head]
11
11
 
12
12
  steps:
13
13
  - uses: actions/checkout@v2
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ test/version_tmp
20
20
  tmp
21
21
  .powenv
22
22
  .idea/
23
+ examples/Gemfile.lock
data/.rubocop.yml CHANGED
@@ -6,7 +6,7 @@ Metrics/BlockLength:
6
6
  ExcludedMethods: ['describe', 'context', 'shared_examples']
7
7
  Metrics/CyclomaticComplexity:
8
8
  Enabled: false
9
- Metrics/LineLength:
9
+ Layout/LineLength:
10
10
  Enabled: false
11
11
  Metrics/MethodLength:
12
12
  Enabled: false
@@ -18,3 +18,15 @@ Style/MutableConstant:
18
18
  Enabled: false
19
19
  Gemspec/RequiredRubyVersion:
20
20
  Enabled: false
21
+ Lint/RaiseException:
22
+ Enabled: false
23
+ Lint/StructNewOverride:
24
+ Enabled: false
25
+ Style/HashEachMethods:
26
+ Enabled: false
27
+ Style/HashTransformKeys:
28
+ Enabled: false
29
+ Style/HashTransformValues:
30
+ Enabled: false
31
+ AllCops:
32
+ NewCops: enable
data/CHANGELOG.md CHANGED
@@ -1,6 +1,51 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 1.2.1 - 2025-01-18
5
+
6
+ ### Added
7
+ - Use jwt v2.9.2's public claims verification API - https://github.com/zquestz/omniauth-google-oauth2/pull/465
8
+
9
+ ### Deprecated
10
+ - Nothing.
11
+
12
+ ### Removed
13
+ - Support for jwt < 2.9.2.
14
+
15
+ ### Fixed
16
+ - Nothing.
17
+
18
+ ## 1.2.0 - 2024-09-15
19
+
20
+ ### Added
21
+ - jwt 2.9.0 support for their updated claims code.
22
+
23
+ ### Deprecated
24
+ - Nothing.
25
+
26
+ ### Removed
27
+ - Ruby 2.3 and 2.4 support.
28
+ - Support for jwt < 2.9.0.
29
+
30
+ ### Fixed
31
+ - Fixed image sizing code.
32
+ - Rubocop configuration updates.
33
+
34
+ ## 1.1.3 - 2024-08-29
35
+
36
+ ### Added
37
+ - Updated to use POST instead of GET for tokeninfo endpoint.
38
+
39
+ ### Deprecated
40
+ - Nothing.
41
+
42
+ ### Removed
43
+ - Nothing.
44
+
45
+ ### Fixed
46
+ - Documentation typos.
47
+ - Rubocop configuration updates.
48
+
4
49
  ## 1.1.2 - 2024-03-28
5
50
 
6
51
  ### Added
data/README.md CHANGED
@@ -40,7 +40,7 @@ You can now access the OmniAuth Google OAuth2 URL: `/auth/google_oauth2`
40
40
 
41
41
  For more examples please check out `examples/omni_auth.rb`
42
42
 
43
- [Using Devise? Skip the above and jump down to the Devise section!](#devise) After setting up the provider via Devise, you can reference the confdiurations below.
43
+ [Using Devise? Skip the above and jump down to the Devise section!](#devise) After setting up the provider via Devise, you can reference the configurations below.
44
44
 
45
45
  NOTE: While developing your application, if you change the scope in the initializer you will need to restart your app server. Remember that either the 'email' or 'profile' scope is required!
46
46
 
@@ -64,6 +64,7 @@ You can configure several options, which you pass in to the `provider` method vi
64
64
  * `image_aspect_ratio`: The shape of the user's profile picture. Possible values are:
65
65
  * `original`: Picture maintains its original aspect ratio.
66
66
  * `square`: Picture presents equal width and height.
67
+ * `smart`: Picture presents equal width and height with smart cropping.
67
68
 
68
69
  Defaults to `original`.
69
70
 
@@ -195,7 +196,8 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
195
196
  flash[:notice] = I18n.t 'devise.omniauth_callbacks.success', kind: 'Google'
196
197
  sign_in_and_redirect @user, event: :authentication
197
198
  else
198
- session['devise.google_data'] = request.env['omniauth.auth'].except('extra') # Removing extra as it can overflow some session stores
199
+ # Useful for debugging login failures. Uncomment for development.
200
+ # session['devise.google_data'] = request.env['omniauth.auth'].except('extra') # Removing extra as it can overflow some session stores
199
201
  redirect_to new_user_registration_url, alert: @user.errors.full_messages.join("\n")
200
202
  end
201
203
  end
@@ -205,6 +207,8 @@ end
205
207
  and bind to or create the user
206
208
 
207
209
  ```ruby
210
+ # app/models/user.rb
211
+
208
212
  def self.from_omniauth(access_token)
209
213
  data = access_token.info
210
214
  user = User.where(email: data['email']).first
@@ -233,7 +237,7 @@ For your views you can login using:
233
237
  <%= link_to "Sign in with Google", user_omniauth_authorize_path(:google_oauth2) %>
234
238
  ```
235
239
 
236
- An overview is available at https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
240
+ An overview is available at https://github.com/heartcombo/devise/wiki/OmniAuth:-Overview
237
241
 
238
242
  ### One-time Code Flow (Hybrid Authentication)
239
243
 
data/examples/Gemfile CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'omniauth-google-oauth2', '~> 1.1.2'
5
+ gem 'omniauth-google-oauth2', path: '..'
6
6
  gem 'rubocop'
7
- gem 'sinatra', '~> 1.4'
7
+ gem 'sinatra'
8
8
  gem 'webrick'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module GoogleOauth2
5
- VERSION = '1.1.2'
5
+ VERSION = '1.2.1'
6
6
  end
7
7
  end
@@ -76,17 +76,11 @@ module OmniAuth
76
76
 
77
77
  # We have to manually verify the claims because the third parameter to
78
78
  # JWT.decode is false since no verification key is provided.
79
- ::JWT::Verify.verify_claims(decoded,
80
- verify_iss: true,
81
- iss: ALLOWED_ISSUERS,
82
- verify_aud: true,
83
- aud: options.client_id,
84
- verify_sub: false,
85
- verify_expiration: true,
86
- verify_not_before: true,
87
- verify_iat: false,
88
- verify_jti: false,
89
- leeway: options[:jwt_leeway])
79
+ ::JWT::Claims.verify_payload!(decoded,
80
+ iss: ALLOWED_ISSUERS,
81
+ aud: options.client_id,
82
+ exp: { leeway: options.jwt_leeway },
83
+ nbf: { leeway: options.jwt_leeway })
90
84
 
91
85
  hash[:id_info] = decoded
92
86
  end
@@ -178,17 +172,16 @@ module OmniAuth
178
172
  def image_url
179
173
  return nil unless raw_info['picture']
180
174
 
181
- u = URI.parse(raw_info['picture'].gsub('https:https', 'https'))
175
+ u = URI.parse(raw_info['picture'])
182
176
 
183
- path_index = u.path.to_s.index('/photo.jpg')
177
+ md = u.path.to_s.match(/(.*)(=((w[0-9]*|h[0-9]*|s[0-9]*|c|p)-?)*)$/)
184
178
 
185
- if path_index && image_size_opts_passed?
186
- u.path.insert(path_index, image_params)
187
- u.path = u.path.gsub('//', '/')
179
+ # Check for sizing, remove if present.
180
+ u.path = md[1] if md && !md[1].nil? && !md[2].nil?
188
181
 
189
- # Check if the image is already sized!
190
- split_path = u.path.split('/')
191
- u.path = u.path.sub("/#{split_path[-3]}", '') if split_path[-3] =~ IMAGE_SIZE_REGEXP
182
+ if image_size_opts_passed?
183
+ u.path += image_params
184
+ u.path = u.path.gsub('//', '/')
192
185
  end
193
186
 
194
187
  u.query = strip_unnecessary_query_parameters(u.query)
@@ -202,15 +195,17 @@ module OmniAuth
202
195
 
203
196
  def image_params
204
197
  image_params = []
205
- if options[:image_size].is_a?(Integer)
198
+ case options[:image_size]
199
+ when Integer
206
200
  image_params << "s#{options[:image_size]}"
207
- elsif options[:image_size].is_a?(Hash)
201
+ when Hash
208
202
  image_params << "w#{options[:image_size][:width]}" if options[:image_size][:width]
209
203
  image_params << "h#{options[:image_size][:height]}" if options[:image_size][:height]
210
204
  end
211
205
  image_params << 'c' if options[:image_aspect_ratio] == 'square'
206
+ image_params << 'p' if options[:image_aspect_ratio] == 'smart'
212
207
 
213
- '/' + image_params.join('-')
208
+ "=#{image_params.join('-')}"
214
209
  end
215
210
 
216
211
  def strip_unnecessary_query_parameters(query_parameters)
@@ -231,7 +226,7 @@ module OmniAuth
231
226
  return nil unless access_token
232
227
 
233
228
  @token_info ||= Hash.new do |h, k|
234
- h[k] = client.request(:get, 'https://www.googleapis.com/oauth2/v3/tokeninfo', params: { access_token: access_token }).parsed
229
+ h[k] = client.request(:post, 'https://www.googleapis.com/oauth2/v3/tokeninfo', body: { access_token: access_token }).parsed
235
230
  end
236
231
 
237
232
  @token_info[access_token]
@@ -18,9 +18,9 @@ Gem::Specification.new do |gem|
18
18
  gem.files = `git ls-files`.split("\n")
19
19
  gem.require_paths = ['lib']
20
20
 
21
- gem.required_ruby_version = '>= 2.2'
21
+ gem.required_ruby_version = '>= 2.5'
22
22
 
23
- gem.add_runtime_dependency 'jwt', '>= 2.0'
23
+ gem.add_runtime_dependency 'jwt', '>= 2.9.2'
24
24
  gem.add_runtime_dependency 'oauth2', '~> 2.0'
25
25
  gem.add_runtime_dependency 'omniauth', '~> 2.0'
26
26
  gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.8'
@@ -324,20 +324,20 @@ describe OmniAuth::Strategies::GoogleOauth2 do
324
324
  it 'has the correct default callback path' do
325
325
  allow(subject).to receive(:full_host) { base_url }
326
326
  allow(subject).to receive(:script_name) { '' }
327
- expect(subject.send(:callback_url)).to eq(base_url + '/auth/google_oauth2/callback')
327
+ expect(subject.send(:callback_url)).to eq("#{base_url}/auth/google_oauth2/callback")
328
328
  end
329
329
 
330
330
  it 'should set the callback path with script_name if present' do
331
331
  allow(subject).to receive(:full_host) { base_url }
332
332
  allow(subject).to receive(:script_name) { '/v1' }
333
- expect(subject.send(:callback_url)).to eq(base_url + '/v1/auth/google_oauth2/callback')
333
+ expect(subject.send(:callback_url)).to eq("#{base_url}/v1/auth/google_oauth2/callback")
334
334
  end
335
335
 
336
336
  it 'should set the callback_path parameter if present' do
337
337
  @options = { callback_path: '/auth/foo/callback' }
338
338
  allow(subject).to receive(:full_host) { base_url }
339
339
  allow(subject).to receive(:script_name) { '' }
340
- expect(subject.send(:callback_url)).to eq(base_url + '/auth/foo/callback')
340
+ expect(subject.send(:callback_url)).to eq("#{base_url}/auth/foo/callback")
341
341
  end
342
342
  end
343
343
 
@@ -384,7 +384,7 @@ describe OmniAuth::Strategies::GoogleOauth2 do
384
384
  subject.options.client_options[:connection_build] = proc do |builder|
385
385
  builder.request :url_encoded
386
386
  builder.adapter :test do |stub|
387
- stub.get('/oauth2/v3/tokeninfo?access_token=valid_access_token') do
387
+ stub.post('/oauth2/v3/tokeninfo', 'access_token=valid_access_token') do
388
388
  [200, { 'Content-Type' => 'application/json; charset=UTF-8' }, JSON.dump(
389
389
  aud: '000000000000.apps.googleusercontent.com',
390
390
  sub: '123456789',
@@ -544,103 +544,146 @@ describe OmniAuth::Strategies::GoogleOauth2 do
544
544
  describe 'when a picture is returned from google' do
545
545
  it 'should return the image with size specified in the `image_size` option' do
546
546
  @options = { image_size: 50 }
547
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } }
548
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg')
547
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
548
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50')
549
549
  end
550
550
 
551
551
  it 'should return the image with size specified in the `image_size` option when sizing is in the picture' do
552
552
  @options = { image_size: 50 }
553
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh4.googleusercontent.com/url/s96-c/photo.jpg' } }
554
- expect(subject.info[:image]).to eq('https://lh4.googleusercontent.com/url/s50/photo.jpg')
553
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s96' } }
554
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50')
555
555
  end
556
556
 
557
- it 'should handle a picture with too many slashes correctly' do
557
+ it 'should return the image with size specified in the `image_size` option when sizing is in the picture and cropped' do
558
558
  @options = { image_size: 50 }
559
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url//photo.jpg' } }
560
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg')
559
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s96-c' } }
560
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50')
561
561
  end
562
562
 
563
- it 'should handle a picture with a size query parameter correctly' do
563
+ it 'should handle a picture with too many slashes' do
564
564
  @options = { image_size: 50 }
565
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg?sz=50' } }
566
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg')
565
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a//ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
566
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50')
567
+ end
568
+
569
+ it 'should handle a picture with a size query parameter' do
570
+ @options = { image_size: 50 }
571
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0?sz=96' } }
572
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50')
573
+ end
574
+
575
+ it 'should handle a picture with a size query parameter and sizing is in the picture' do
576
+ @options = { image_size: 50 }
577
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s96-c?sz=96' } }
578
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50')
567
579
  end
568
580
 
569
581
  it 'should handle a picture with a size query parameter and other valid query parameters correctly' do
570
582
  @options = { image_size: 50 }
571
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg?sz=50&hello=true&life=42' } }
572
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg?hello=true&life=42')
583
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0?sz=50&hello=true&life=42' } }
584
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50?hello=true&life=42')
585
+ end
586
+
587
+ it 'should handle a picture with a size query parameter, other valid query parameters and sizing is in the picture correctly' do
588
+ @options = { image_size: 50 }
589
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s96-c?sz=50&hello=true&life=42' } }
590
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50?hello=true&life=42')
573
591
  end
574
592
 
575
593
  it 'should handle a picture with other valid query parameters correctly' do
576
594
  @options = { image_size: 50 }
577
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg?hello=true&life=42' } }
578
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg?hello=true&life=42')
595
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0?hello=true&life=42' } }
596
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50?hello=true&life=42')
579
597
  end
580
598
 
581
599
  it 'should return the image with width and height specified in the `image_size` option' do
582
600
  @options = { image_size: { width: 50, height: 40 } }
583
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } }
584
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/w50-h40/photo.jpg')
601
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
602
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w50-h40')
585
603
  end
586
604
 
587
605
  it 'should return the image with width and height specified in the `image_size` option when sizing is in the picture' do
588
606
  @options = { image_size: { width: 50, height: 40 } }
589
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/w100-h80-c/photo.jpg' } }
590
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/w50-h40/photo.jpg')
607
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w100-h80-c' } }
608
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w50-h40')
591
609
  end
592
610
 
593
- it 'should return square image when `image_aspect_ratio` is specified' do
611
+ it 'should return square image when square `image_aspect_ratio` is specified' do
594
612
  @options = { image_aspect_ratio: 'square' }
595
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } }
596
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/c/photo.jpg')
613
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
614
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=c')
597
615
  end
598
616
 
599
- it 'should return square image when `image_aspect_ratio` is specified and sizing is in the picture' do
617
+ it 'should return square image when square `image_aspect_ratio` is specified and sizing is in the picture' do
600
618
  @options = { image_aspect_ratio: 'square' }
601
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/c/photo.jpg' } }
602
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/c/photo.jpg')
619
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50-c' } }
620
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=c')
621
+ end
622
+
623
+ it 'should return smart image when smart `image_aspect_ratio` is specified' do
624
+ @options = { image_aspect_ratio: 'smart' }
625
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
626
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=p')
603
627
  end
604
628
 
605
- it 'should return square sized image when `image_aspect_ratio` and `image_size` is set' do
629
+ it 'should return smart image when smart `image_aspect_ratio` is specified and sizing is in the picture' do
630
+ @options = { image_aspect_ratio: 'smart' }
631
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50-c' } }
632
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=p')
633
+ end
634
+
635
+ it 'should return square sized image when square `image_aspect_ratio` and `image_size` is set' do
606
636
  @options = { image_aspect_ratio: 'square', image_size: 50 }
607
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } }
608
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50-c/photo.jpg')
637
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
638
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50-c')
609
639
  end
610
640
 
611
- it 'should return square sized image when `image_aspect_ratio` and `image_size` is set and sizing is in the picture' do
641
+ it 'should return square sized image when square `image_aspect_ratio` and `image_size` is set and sizing is in the picture' do
612
642
  @options = { image_aspect_ratio: 'square', image_size: 50 }
613
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/s90/photo.jpg' } }
614
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50-c/photo.jpg')
643
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s90' } }
644
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50-c')
645
+ end
646
+
647
+ it 'should return smart sized image when smart `image_aspect_ratio` and `image_size` is set' do
648
+ @options = { image_aspect_ratio: 'smart', image_size: 50 }
649
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
650
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50-p')
651
+ end
652
+
653
+ it 'should return smart sized image when smart `image_aspect_ratio` and `image_size` is set and sizing is in the picture' do
654
+ @options = { image_aspect_ratio: 'smart', image_size: 50 }
655
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s90' } }
656
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=s50-p')
615
657
  end
616
658
 
617
- it 'should return square sized image when `image_aspect_ratio` and `image_size` has height and width' do
659
+ it 'should return square sized image when square `image_aspect_ratio` and `image_size` has height and width' do
618
660
  @options = { image_aspect_ratio: 'square', image_size: { width: 50, height: 40 } }
619
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } }
620
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/w50-h40-c/photo.jpg')
661
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
662
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w50-h40-c')
621
663
  end
622
664
 
623
- it 'should return square sized image when `image_aspect_ratio` and `image_size` has height and width and sizing is in the picture' do
665
+ it 'should return square sized image when square `image_aspect_ratio` and `image_size` has height and width and sizing is in the picture' do
624
666
  @options = { image_aspect_ratio: 'square', image_size: { width: 50, height: 40 } }
625
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/w100-h80/photo.jpg' } }
626
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/w50-h40-c/photo.jpg')
667
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w100-h80-c' } }
668
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w50-h40-c')
627
669
  end
628
670
 
629
- it 'should return original image if image url does not end in `photo.jpg`' do
630
- @options = { image_size: 50 }
631
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photograph.jpg' } }
632
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/photograph.jpg')
671
+ it 'should return smart sized image when smart `image_aspect_ratio` and `image_size` has height and width' do
672
+ @options = { image_aspect_ratio: 'smart', image_size: { width: 50, height: 40 } }
673
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
674
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w50-h40-p')
633
675
  end
634
- end
635
676
 
636
- it 'should return original image if no options are provided' do
637
- allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } }
638
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/photo.jpg')
677
+ it 'should return smart sized image when smart `image_aspect_ratio` and `image_size` has height and width and sizing is in the picture' do
678
+ @options = { image_aspect_ratio: 'smart', image_size: { width: 50, height: 40 } }
679
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w100-h80-c' } }
680
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0=w50-h40-p')
681
+ end
639
682
  end
640
683
 
641
- it 'should return correct image if google image url has double https' do
642
- allow(subject).to receive(:raw_info) { { 'picture' => 'https:https://lh3.googleusercontent.com/url/photo.jpg' } }
643
- expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/photo.jpg')
684
+ it 'should return original image if no options are provided' do
685
+ allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0' } }
686
+ expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/a/ACg8ocKN8F32STvmW-LG0Rl_9re5-Pv2cCn0ayodas6BQFPGEArMOtn0')
644
687
  end
645
688
  end
646
689
 
@@ -781,7 +824,7 @@ describe OmniAuth::Strategies::GoogleOauth2 do
781
824
  subject.options.client_options[:connection_build] = proc do |builder|
782
825
  builder.request :url_encoded
783
826
  builder.adapter :test do |stub|
784
- stub.get('/oauth2/v3/tokeninfo?access_token=valid_access_token') do
827
+ stub.post('/oauth2/v3/tokeninfo', 'access_token=valid_access_token') do
785
828
  [200, { 'Content-Type' => 'application/json; charset=UTF-8' }, JSON.dump(
786
829
  aud: '000000000000.apps.googleusercontent.com',
787
830
  sub: '123456789',
@@ -792,7 +835,7 @@ describe OmniAuth::Strategies::GoogleOauth2 do
792
835
  expires_in: 436
793
836
  )]
794
837
  end
795
- stub.get('/oauth2/v3/tokeninfo?access_token=invalid_access_token') do
838
+ stub.post('/oauth2/v3/tokeninfo', 'access_token=invalid_access_token') do
796
839
  [400, { 'Content-Type' => 'application/json; charset=UTF-8' }, JSON.dump(error_description: 'Invalid Value')]
797
840
  end
798
841
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-google-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Ellithorpe
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-03-29 00:00:00.000000000 Z
12
+ date: 2025-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jwt
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '2.0'
20
+ version: 2.9.2
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '2.0'
27
+ version: 2.9.2
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: oauth2
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -117,6 +117,7 @@ executables: []
117
117
  extensions: []
118
118
  extra_rdoc_files: []
119
119
  files:
120
+ - ".github/FUNDING.yml"
120
121
  - ".github/workflows/ci.yml"
121
122
  - ".gitignore"
122
123
  - ".rubocop.yml"
@@ -147,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
148
  requirements:
148
149
  - - ">="
149
150
  - !ruby/object:Gem::Version
150
- version: '2.2'
151
+ version: '2.5'
151
152
  required_rubygems_version: !ruby/object:Gem::Requirement
152
153
  requirements:
153
154
  - - ">="