omniauth-google-oauth2 0.5.3 → 0.5.4

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: b272ef7383811111988e246c36713b9cb05808ee
4
- data.tar.gz: bcfc5288908b05a8b6b12694e1a5fffb423f3a25
3
+ metadata.gz: 2a7656373110c92e06996caa456eea2a5dd429b6
4
+ data.tar.gz: 54fa84ae8d29ab08e9387e79a7dde7796b4f5ddf
5
5
  SHA512:
6
- metadata.gz: 20e8acd4f1a5936771232d7eb36f45bd94c652f2732827235d0c14e0d0cfd57db34a6fd0f9205838eecb922e8ca4a429c84fc5f21af971b119bc467a3de76313
7
- data.tar.gz: 906640488bc922b90bb224027c2f748e40bd6ae5554ed49a5e63210bbdfeeda17d3e058e21e89ab4a0442468fcebb883afcdf29486b734b6be49003fba085928
6
+ metadata.gz: d8c0b4beb4561a205866bbb36ef4fe5b438d95e07cf8832f1e657e48f04657e98d99c28bf69ad3f53b564c47017435cc8d38a7c9eb48700a0b07a642a6012624
7
+ data.tar.gz: 7e3fd2adca8bb3227da30c0492c5738fdbeb7e50c8ccb8df2dac2379407ad5230092d26f4942e1654fdf680c2c961556ad111ab71d5fb788f48dcc1e24f3f324
@@ -4,3 +4,4 @@ rvm:
4
4
  - '2.2.7'
5
5
  - '2.3.4'
6
6
  - '2.4.1'
7
+ - '2.5.0'
@@ -1,6 +1,20 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 0.5.4 - 2018-12-07
5
+
6
+ ### Added
7
+ - New recommended endpoints for Google OAuth.
8
+
9
+ ### Deprecated
10
+ - Nothing.
11
+
12
+ ### Removed
13
+ - Nothing.
14
+
15
+ ### Fixed
16
+ - Nothing.
17
+
4
18
  ## 0.5.3 - 2018-01-25
5
19
 
6
20
  ### Added
@@ -20,7 +34,7 @@ All notable changes to this project will be documented in this file.
20
34
  ## 0.5.2 - 2017-07-30
21
35
 
22
36
  ### Added
23
- - Nothing
37
+ - Nothing.
24
38
 
25
39
  ### Deprecated
26
40
  - Nothing.
@@ -29,7 +43,7 @@ All notable changes to this project will be documented in this file.
29
43
  - New `authorize_url` and `token_url` endpoints are reverted until JWT 2.0 ships.
30
44
 
31
45
  ### Fixed
32
- - Nothing
46
+ - Nothing.
33
47
 
34
48
  ## 0.5.1 - 2017-07-19
35
49
 
data/README.md CHANGED
@@ -95,8 +95,7 @@ Here's an example of a possible configuration where the strategy name is changed
95
95
  Rails.application.config.middleware.use OmniAuth::Builder do
96
96
  provider :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'],
97
97
  {
98
- name: 'google',
99
- scope: 'email, profile, plus.me, http://gdata.youtube.com',
98
+ scope: 'userinfo.email, userinfo.profile, plus.me, http://gdata.youtube.com',
100
99
  prompt: 'select_account',
101
100
  image_aspect_ratio: 'square',
102
101
  image_size: 50
@@ -168,6 +167,7 @@ Configuration options can be passed as the last parameter here as key/value pair
168
167
  ```ruby
169
168
  config.omniauth :google_oauth2, 'GOOGLE_CLIENT_ID', 'GOOGLE_CLIENT_SECRET', {}
170
169
  ```
170
+ NOTE: If you are using this gem with devise with above snippet in `config/initializers/devise.rb` then do not create `config/initializers/omniauth.rb` which will conflict with devise configurations.
171
171
 
172
172
  Then add the following to 'config/routes.rb' so the callback routes are defined.
173
173
 
@@ -303,7 +303,7 @@ If you're making POST requests to `/auth/google_oauth2/callback` from another do
303
303
  Just set the `full_host` in OmniAuth based on the Rails.env.
304
304
 
305
305
  ```
306
- # config/initialisers/omniauth.rb
306
+ # config/initializers/omniauth.rb
307
307
  OmniAuth.config.full_host = Rails.env.production? ? 'https://domain.com' : 'http://localhost:3000'
308
308
  ```
309
309
 
@@ -21,63 +21,63 @@ OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
21
21
  class App < Sinatra::Base
22
22
  get '/' do
23
23
  <<-HTML
24
- <!DOCTYPE html>
25
- <html>
26
- <head>
27
- <title>Google OAuth2 Example</title>
28
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
29
- <script>
30
- jQuery(function() {
31
- return $.ajax({
32
- url: 'https://apis.google.com/js/client:plus.js?onload=gpAsyncInit',
33
- dataType: 'script',
34
- cache: true
35
- });
36
- });
24
+ <!DOCTYPE html>
25
+ <html>
26
+ <head>
27
+ <title>Google OAuth2 Example</title>
28
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
29
+ <script>
30
+ jQuery(function() {
31
+ return $.ajax({
32
+ url: 'https://apis.google.com/js/client:plus.js?onload=gpAsyncInit',
33
+ dataType: 'script',
34
+ cache: true
35
+ });
36
+ });
37
37
 
38
- window.gpAsyncInit = function() {
39
- gapi.auth.authorize({
40
- immediate: true,
41
- response_type: 'code',
42
- cookie_policy: 'single_host_origin',
43
- client_id: '#{ENV['GOOGLE_KEY']}',
44
- scope: 'email profile'
45
- }, function(response) {
46
- return;
47
- });
48
- $('.googleplus-login').click(function(e) {
49
- e.preventDefault();
50
- gapi.auth.authorize({
51
- immediate: false,
52
- response_type: 'code',
53
- cookie_policy: 'single_host_origin',
54
- client_id: '#{ENV['GOOGLE_KEY']}',
55
- scope: 'email profile'
56
- }, function(response) {
57
- if (response && !response.error) {
58
- // google authentication succeed, now post data to server.
59
- jQuery.ajax({type: 'POST', url: "/auth/google_oauth2/callback", data: response,
60
- success: function(data) {
61
- // Log the data returning from google.
62
- console.log(data)
38
+ window.gpAsyncInit = function() {
39
+ gapi.auth.authorize({
40
+ immediate: true,
41
+ response_type: 'code',
42
+ cookie_policy: 'single_host_origin',
43
+ client_id: '#{ENV['GOOGLE_KEY']}',
44
+ scope: 'email profile'
45
+ }, function(response) {
46
+ return;
47
+ });
48
+ $('.googleplus-login').click(function(e) {
49
+ e.preventDefault();
50
+ gapi.auth.authorize({
51
+ immediate: false,
52
+ response_type: 'code',
53
+ cookie_policy: 'single_host_origin',
54
+ client_id: '#{ENV['GOOGLE_KEY']}',
55
+ scope: 'email profile'
56
+ }, function(response) {
57
+ if (response && !response.error) {
58
+ // google authentication succeed, now post data to server.
59
+ jQuery.ajax({type: 'POST', url: "/auth/google_oauth2/callback", data: response,
60
+ success: function(data) {
61
+ // Log the data returning from google.
62
+ console.log(data)
63
+ }
64
+ });
65
+ } else {
66
+ // google authentication failed.
67
+ console.log("FAILED")
63
68
  }
64
69
  });
65
- } else {
66
- // google authentication failed.
67
- console.log("FAILED")
68
- }
69
- });
70
- });
71
- };
72
- </script>
73
- </head>
74
- <body>
75
- <ul>
76
- <li><a href='/auth/google_oauth2'>Sign in with Google</a></li>
77
- <li><a href='#' class="googleplus-login">Sign in with Google via AJAX</a></li>
78
- </ul>
79
- </body>
80
- </html>
70
+ });
71
+ };
72
+ </script>
73
+ </head>
74
+ <body>
75
+ <ul>
76
+ <li><a href='/auth/google_oauth2'>Sign in with Google</a></li>
77
+ <li><a href='#' class="googleplus-login">Sign in with Google via AJAX</a></li>
78
+ </ul>
79
+ </body>
80
+ </html>
81
81
  HTML
82
82
  end
83
83
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module GoogleOauth2
5
- VERSION = '0.5.3'
5
+ VERSION = '0.5.4'
6
6
  end
7
7
  end
@@ -22,9 +22,9 @@ module OmniAuth
22
22
  option :verify_iss, true
23
23
 
24
24
  option :client_options,
25
- site: 'https://accounts.google.com',
26
- authorize_url: '/o/oauth2/auth',
27
- token_url: '/o/oauth2/token'
25
+ site: 'https://oauth2.googleapis.com',
26
+ authorize_url: 'https://accounts.google.com/o/oauth2/auth',
27
+ token_url: '/token'
28
28
 
29
29
  def authorize_params
30
30
  super.tap do |params|
@@ -193,6 +193,7 @@ module OmniAuth
193
193
 
194
194
  def verify_token(access_token)
195
195
  return false unless access_token
196
+
196
197
  raw_response = client.request(:get, 'https://www.googleapis.com/oauth2/v3/tokeninfo',
197
198
  params: { access_token: access_token }).parsed
198
199
  raw_response['aud'] == options.client_id || options.authorized_client_ids.include?(raw_response['aud'])
@@ -200,12 +201,14 @@ module OmniAuth
200
201
 
201
202
  def verify_hd(access_token)
202
203
  return true unless options.hd
204
+
203
205
  @raw_info ||= access_token.get('https://www.googleapis.com/plus/v1/people/me/openIdConnect').parsed
204
206
 
205
207
  options.hd = options.hd.call if options.hd.is_a? Proc
206
208
  allowed_hosted_domains = Array(options.hd)
207
209
 
208
210
  raise CallbackError.new(:invalid_hd, 'Invalid Hosted Domain') unless allowed_hosted_domains.include?(@raw_info['hd']) || options.hd == '*'
211
+
209
212
  true
210
213
  end
211
214
  end
@@ -30,15 +30,15 @@ describe OmniAuth::Strategies::GoogleOauth2 do
30
30
 
31
31
  describe '#client_options' do
32
32
  it 'has correct site' do
33
- expect(subject.client.site).to eq('https://accounts.google.com')
33
+ expect(subject.client.site).to eq('https://oauth2.googleapis.com')
34
34
  end
35
35
 
36
36
  it 'has correct authorize_url' do
37
- expect(subject.client.options[:authorize_url]).to eq('/o/oauth2/auth')
37
+ expect(subject.client.options[:authorize_url]).to eq('https://accounts.google.com/o/oauth2/auth')
38
38
  end
39
39
 
40
40
  it 'has correct token_url' do
41
- expect(subject.client.options[:token_url]).to eq('/o/oauth2/token')
41
+ expect(subject.client.options[:token_url]).to eq('/token')
42
42
  end
43
43
 
44
44
  describe 'overrides' do
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.3
4
+ version: 0.5.4
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: 2018-01-26 00:00:00.000000000 Z
12
+ date: 2018-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jwt
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  version: '0'
142
142
  requirements: []
143
143
  rubyforge_project:
144
- rubygems_version: 2.6.11
144
+ rubygems_version: 2.6.13
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: A Google OAuth2 strategy for OmniAuth 1.x