omniauth-google-oauth2 0.5.0 → 0.5.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: 65ffc15faaed3d23a1c4a7ca2d5fa07f8ffda0f5
4
- data.tar.gz: 6c70bafaec2478b78b8293bca662a898d4d4e019
3
+ metadata.gz: e8856da55d4dd3541aa24210676726e43c9f7afb
4
+ data.tar.gz: 8d34f80f64977b8eef82858f8521c31d4cb4b000
5
5
  SHA512:
6
- metadata.gz: 55b5b27e600710e73ddd27d4ec9886faed3d76a2909f05090e46da59bde030d5e2cc567ac3a92d213fc9737a3938be4c1507d7f9631d8cfbd1b1962a87ca56b9
7
- data.tar.gz: f4091407c27f7fb9d05751a927cd2963f2f9447e7ad8ce9af32f2769bc5759f0a0dc488a273ea79b32bd56e44fd5a9f2e4ffc177e96fac096a9bc93400368b71
6
+ metadata.gz: 30137b2edafdad7c71b22f9a0f6b4f7f2897719348326facad7ad2e8a6c5ab3f22f9040cfd2a06cba42995496fcc2f644946ea467b1e0e9d76139a42b39113b6
7
+ data.tar.gz: 153076648f4c1eac3971a2bf67c67c75b43ddff1bca0e6c9ca1c86885fb31cdc01cdf306507f2b527931051c6b1cb8029bf93b0b928c4723d84e8de91c7b554e
@@ -1,6 +1,21 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 0.5.1 - 2017-07-19
5
+
6
+ ### Added
7
+ - JWT iss verification can be enabled/disabled with the `verify_iss` flag.
8
+ - Authorize options now includes `device_id` and `device_name` for private ip ranges.
9
+
10
+ ### Deprecated
11
+ - Nothing.
12
+
13
+ ### Removed
14
+ - Nothing.
15
+
16
+ ### Fixed
17
+ - Updated `authorize_url` and `token_url` to new endpoints.
18
+
4
19
  ## 0.5.0 - 2017-05-29
5
20
 
6
21
  ### Added
data/README.md CHANGED
@@ -87,6 +87,8 @@ You can configure several options, which you pass in to the `provider` method vi
87
87
 
88
88
  * `openid_realm`: Set the OpenID realm value, to allow upgrading from OpenID based authentication to OAuth 2 based authentication. When this is set correctly an `openid_id` value will be set in `[:extra][:id_info]` in the authentication hash with the value of the user's OpenID ID URL.
89
89
 
90
+ * `verify_iss`: Allows you to disable iss validation when decoding the JWT. This was added since Google now returns either `accounts.google.com` or `https://accounts.google.com`, and there is no way to predict what they will return, causing JWT validation failures.
91
+
90
92
  Here's an example of a possible configuration where the strategy name is changed, the user is asked for extra permissions, the user is always prompted to select his account when logging in and the user's profile picture is returned as a thumbnail:
91
93
 
92
94
  ```ruby
@@ -191,7 +193,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
191
193
  flash[:notice] = I18n.t 'devise.omniauth_callbacks.success', kind: 'Google'
192
194
  sign_in_and_redirect @user, event: :authentication
193
195
  else
194
- session['devise.google_data'] = request.env['omniauth.auth'].except(:extra) #Removing extra as it can overflow some session stores
196
+ session['devise.google_data'] = request.env['omniauth.auth'].except(:extra) # Removing extra as it can overflow some session stores
195
197
  redirect_to new_user_registration_url, alert: @user.errors.full_messages.join("\n")
196
198
  end
197
199
  end
@@ -114,7 +114,8 @@ use Rack::Session::Cookie, secret: ENV['RACK_COOKIE_SECRET']
114
114
  use OmniAuth::Builder do
115
115
  # For additional provider examples please look at 'omni_auth.rb'
116
116
  # The key provider_ignores_state is only for AJAX flows. It is not recommended for normal logins.
117
- provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], access_type: 'offline', prompt: 'consent', provider_ignores_state: true, scope: 'email,profile,calendar'
117
+ # Also, verify_iss is disabled because google now returns an unpredictable value for iss.
118
+ provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], verify_iss: false, access_type: 'offline', prompt: 'consent', provider_ignores_state: true, scope: 'email,profile,calendar'
118
119
  end
119
120
 
120
121
  run App.new
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module GoogleOauth2
5
- VERSION = '0.5.0'
5
+ VERSION = '0.5.1'
6
6
  end
7
7
  end
@@ -18,13 +18,13 @@ module OmniAuth
18
18
  option :skip_image_info, true
19
19
  option :skip_jwt, false
20
20
  option :jwt_leeway, 60
21
- option :authorize_options, %i[access_type hd login_hint prompt request_visible_actions scope state redirect_uri include_granted_scopes openid_realm]
21
+ option :authorize_options, %i[access_type hd login_hint prompt request_visible_actions scope state redirect_uri include_granted_scopes openid_realm device_id device_name]
22
22
  option :authorized_client_ids, []
23
+ option :verify_iss, true
23
24
 
24
25
  option :client_options,
25
- site: 'https://accounts.google.com',
26
- authorize_url: '/o/oauth2/auth',
27
- token_url: '/o/oauth2/token'
26
+ authorize_url: 'https://accounts.google.com/o/oauth2/v2/auth',
27
+ token_url: 'https://www.googleapis.com/oauth2/v4/token'
28
28
 
29
29
  def authorize_params
30
30
  super.tap do |params|
@@ -60,7 +60,7 @@ module OmniAuth
60
60
  hash[:id_token] = access_token['id_token']
61
61
  if !options[:skip_jwt] && !access_token['id_token'].nil?
62
62
  hash[:id_info] = JWT.decode(
63
- access_token['id_token'], nil, false, verify_iss: true,
63
+ access_token['id_token'], nil, false, verify_iss: options.verify_iss,
64
64
  iss: 'accounts.google.com',
65
65
  verify_aud: true,
66
66
  aud: options.client_id,
@@ -28,16 +28,16 @@ describe OmniAuth::Strategies::GoogleOauth2 do
28
28
  end
29
29
 
30
30
  describe '#client_options' do
31
- it 'has correct site' do
32
- expect(subject.client.site).to eq('https://accounts.google.com')
31
+ it 'does not have site' do
32
+ expect(subject.client.site).to eq(nil)
33
33
  end
34
34
 
35
35
  it 'has correct authorize_url' do
36
- expect(subject.client.options[:authorize_url]).to eq('/o/oauth2/auth')
36
+ expect(subject.client.options[:authorize_url]).to eq('https://accounts.google.com/o/oauth2/v2/auth')
37
37
  end
38
38
 
39
39
  it 'has correct token_url' do
40
- expect(subject.client.options[:token_url]).to eq('/o/oauth2/token')
40
+ expect(subject.client.options[:token_url]).to eq('https://www.googleapis.com/oauth2/v4/token')
41
41
  end
42
42
 
43
43
  describe 'overrides' do
@@ -78,7 +78,7 @@ describe OmniAuth::Strategies::GoogleOauth2 do
78
78
  end
79
79
 
80
80
  describe '#authorize_options' do
81
- %i[access_type hd login_hint prompt scope state].each do |k|
81
+ %i[access_type hd login_hint prompt scope state device_id device_name].each do |k|
82
82
  it "should support #{k}" do
83
83
  @options = { k => 'http://someval' }
84
84
  expect(subject.authorize_params[k.to_s]).to eq('http://someval')
@@ -593,6 +593,37 @@ describe OmniAuth::Strategies::GoogleOauth2 do
593
593
  end
594
594
  end
595
595
 
596
+ describe 'verify_iss option' do
597
+ before(:each) do
598
+ subject.options.client_options[:connection_build] = proc do |builder|
599
+ builder.request :url_encoded
600
+ builder.adapter :test do |stub|
601
+ stub.get('/oauth2/v3/tokeninfo?access_token=invalid_iss_token') do
602
+ [200, { 'Content-Type' => 'application/json; charset=UTF-8' },
603
+ MultiJson.encode(
604
+ aud: '000000000000.apps.googleusercontent.com',
605
+ sub: '123456789',
606
+ email_verified: 'true',
607
+ email: 'example@example.com',
608
+ access_type: 'offline',
609
+ scope: 'profile email',
610
+ expires_in: 436,
611
+ iss: 'foobar.com'
612
+ )]
613
+ end
614
+ end
615
+ end
616
+ subject.options.authorized_client_ids = ['000000000000.apps.googleusercontent.com']
617
+ subject.options.client_id = '000000000000.apps.googleusercontent.com'
618
+ subject.options[:verify_iss] = false
619
+ end
620
+
621
+ it 'should verify token if the iss does not match options.expected_iss' do
622
+ result = subject.send(:verify_token, 'invalid_iss_token')
623
+ expect(result).to eq(true)
624
+ end
625
+ end
626
+
596
627
  describe 'verify_token' do
597
628
  before(:each) do
598
629
  subject.options.client_options[:connection_build] = proc do |builder|
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: 0.5.0
4
+ version: 0.5.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: 2017-05-30 00:00:00.000000000 Z
12
+ date: 2017-07-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth