omniauth-google-oauth2 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +40 -6
- data/examples/omni_auth.rb +7 -1
- data/lib/omniauth/google_oauth2/version.rb +1 -1
- data/lib/omniauth/strategies/google_oauth2.rb +59 -10
- data/{omniauth-contrib.gemspec → omniauth-google-oauth2.gemspec} +11 -10
- data/spec/omniauth/strategies/google_oauth2_spec.rb +90 -3
- metadata +54 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f461d098165edee4d446b4259828d42c27cfbd61
|
4
|
+
data.tar.gz: db0ae27a82e6ef6715bb322cba8eed6f3bb87619
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14d16969c1422d4785ff9295e08d91c4de2290f9ba6f11cef19d5714ef3537907d379b83af21920898c48e28db9c88deaa60af419aea72c0339edfe7da6c1972
|
7
|
+
data.tar.gz: 3f42cbe18583148a414b39d1b0784bbb83cee2eba1728747e8019b306bdf959ac1e041649c7a5eaafbd58613f6a4e8d83e3b1e0c852d79c2cf2a9ca8630b7c74
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## 0.2.7 - 2014-10-26
|
5
|
+
|
6
|
+
### Added
|
7
|
+
- Now strips out the 'sz' parameter from profile image urls.
|
8
|
+
- Now uses 'addressable' gem for URI actions.
|
9
|
+
- Added image data to extras hash.
|
10
|
+
- Override validation on JWT token for open_id token.
|
11
|
+
- Handle authorization codes coming from an installed applications.
|
12
|
+
|
13
|
+
### Deprecated
|
14
|
+
- Nothing.
|
15
|
+
|
16
|
+
### Removed
|
17
|
+
- Nothing.
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
- Fixes double slashes in google image urls.
|
21
|
+
|
4
22
|
## 0.2.6 - 2014-10-26
|
5
23
|
|
6
24
|
### Added
|
data/README.md
CHANGED
@@ -24,7 +24,7 @@ Then `bundle install`.
|
|
24
24
|
* Select your project.
|
25
25
|
* Click 'APIs & auth'
|
26
26
|
* Make sure "Contacts API" and "Google+ API" are on.
|
27
|
-
* Go to
|
27
|
+
* Go to Credentials, then select the "OAuth consent screen" tab on top, and provide an 'EMAIL ADDRESS' and a 'PRODUCT NAME'
|
28
28
|
* Wait 10 minutes for changes to take effect.
|
29
29
|
|
30
30
|
## Usage
|
@@ -69,10 +69,14 @@ You can configure several options, which you pass in to the `provider` method vi
|
|
69
69
|
|
70
70
|
* `access_type`: Defaults to `offline`, so a refresh token is sent to be used when the user is not present at the browser. Can be set to `online`. Note that if you need a refresh token, google requires you to also to specify the option `prompt: 'consent'`, which is not a default.
|
71
71
|
|
72
|
+
* `hd`: (Optional) Limit sign-in to a particular Google Apps hosted domain. More information at: https://developers.google.com/accounts/docs/OpenIDConnect#hd-param
|
73
|
+
|
72
74
|
* `login_hint`: When your app knows which user it is trying to authenticate, it can provide this parameter as a hint to the authentication server. Passing this hint suppresses the account chooser and either pre-fill the email box on the sign-in form, or select the proper session (if the user is using multiple sign-in), which can help you avoid problems that occur if your app logs in the wrong user account. The value can be either an email address or the sub string, which is equivalent to the user's Google+ ID.
|
73
75
|
|
74
76
|
* `include_granted_scopes`: If this is provided with the value true, and the authorization request is granted, the authorization will include any previous authorizations granted to this user/application combination for other scopes. See Google's [Incremental Autorization](https://developers.google.com/accounts/docs/OAuth2WebServer#incrementalAuth) for additional details.
|
75
77
|
|
78
|
+
* `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.
|
79
|
+
|
76
80
|
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:
|
77
81
|
|
78
82
|
```ruby
|
@@ -123,6 +127,18 @@ Here's an example of an authentication hash available in the callback by accessi
|
|
123
127
|
:birthday => "0000-06-25",
|
124
128
|
:locale => "en",
|
125
129
|
:hd => "company_name.com"
|
130
|
+
},
|
131
|
+
:id_info => {
|
132
|
+
"iss" => "accounts.google.com",
|
133
|
+
"at_hash" => "HK6E_P6Dh8Y93mRNtsDB1Q",
|
134
|
+
"email_verified" => "true",
|
135
|
+
"sub" => "10769150350006150715113082367",
|
136
|
+
"azp" => "APP_ID",
|
137
|
+
"email" => "jsmith@example.com",
|
138
|
+
"aud" => "APP_ID",
|
139
|
+
"iat" => 1353601026,
|
140
|
+
"exp" => 1353604926,
|
141
|
+
"openid_id" => "https://www.google.com/accounts/o8/id?id=ABCdfdswawerSDFDsfdsfdfjdsf"
|
126
142
|
}
|
127
143
|
}
|
128
144
|
}
|
@@ -130,10 +146,10 @@ Here's an example of an authentication hash available in the callback by accessi
|
|
130
146
|
|
131
147
|
### Devise
|
132
148
|
|
133
|
-
First define your application id and secret in
|
149
|
+
First define your application id and secret in `config/initializers/devise.rb`. Do not use the snippet mentioned in the [Usage](https://github.com/zquestz/omniauth-google-oauth2#usage) section.
|
134
150
|
|
135
151
|
```ruby
|
136
|
-
config.omniauth :google_oauth2, "
|
152
|
+
config.omniauth :google_oauth2, "GOOGLE_CLIENT_ID", "GOOGLE_CLIENT_SECRET", { }
|
137
153
|
```
|
138
154
|
|
139
155
|
Then add the following to 'config/routes.rb' so the callback routes are defined.
|
@@ -154,7 +170,7 @@ Then make sure your callbacks controller is setup.
|
|
154
170
|
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
155
171
|
def google_oauth2
|
156
172
|
# You need to implement the method below in your model (e.g. app/models/user.rb)
|
157
|
-
@user = User.
|
173
|
+
@user = User.from_omniauth(request.env["omniauth.auth"])
|
158
174
|
|
159
175
|
if @user.persisted?
|
160
176
|
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Google"
|
@@ -170,7 +186,7 @@ end
|
|
170
186
|
and bind to or create the user
|
171
187
|
|
172
188
|
```ruby
|
173
|
-
def self.
|
189
|
+
def self.from_omniauth(access_token)
|
174
190
|
data = access_token.info
|
175
191
|
user = User.where(:email => data["email"]).first
|
176
192
|
|
@@ -240,6 +256,24 @@ window.gpAsyncInit = function() {
|
|
240
256
|
};
|
241
257
|
```
|
242
258
|
|
259
|
+
### Omniauth state
|
260
|
+
|
261
|
+
If you'd like to use omniauth state param, you can implement it by yourself using rails csrf token. For example:
|
262
|
+
|
263
|
+
```ruby
|
264
|
+
class ApplicationController < ActionController::Base
|
265
|
+
before_action :initialize_omniauth_state
|
266
|
+
|
267
|
+
protected
|
268
|
+
|
269
|
+
def initialize_omniauth_state
|
270
|
+
session['omniauth.state'] = response.headers['X-CSRF-Token'] = form_authenticity_token
|
271
|
+
end
|
272
|
+
...
|
273
|
+
```
|
274
|
+
|
275
|
+
and add ```skip_before_filter :verify_authenticity_token``` in your omniauth callback controller because it is already verified by omniauth state. And then you no need to add ```:provider_ignores_state => true``` in your omniauth initializer.
|
276
|
+
|
243
277
|
|
244
278
|
## Build Status
|
245
279
|
[![Build Status](https://travis-ci.org/zquestz/omniauth-google-oauth2.png)](https://travis-ci.org/zquestz/omniauth-google-oauth2)
|
@@ -247,7 +281,7 @@ window.gpAsyncInit = function() {
|
|
247
281
|
|
248
282
|
## License
|
249
283
|
|
250
|
-
Copyright (c)
|
284
|
+
Copyright (c) 2015 by Josh Ellithorpe
|
251
285
|
|
252
286
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
253
287
|
|
data/examples/omni_auth.rb
CHANGED
@@ -38,4 +38,10 @@ Rails.application.config.middleware.use OmniAuth::Builder do
|
|
38
38
|
# :skip_friends => false,
|
39
39
|
# :scope => "email,profile,plus.login"
|
40
40
|
# }
|
41
|
-
|
41
|
+
|
42
|
+
# If you need to acquire whether user picture is a default one or uploaded by user.
|
43
|
+
#
|
44
|
+
# provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], {
|
45
|
+
# :skip_image_info => false
|
46
|
+
# }
|
47
|
+
end
|
@@ -1,4 +1,7 @@
|
|
1
|
+
require 'multi_json'
|
2
|
+
require 'jwt'
|
1
3
|
require 'omniauth/strategies/oauth2'
|
4
|
+
require 'addressable/uri'
|
2
5
|
|
3
6
|
module OmniAuth
|
4
7
|
module Strategies
|
@@ -11,7 +14,9 @@ module OmniAuth
|
|
11
14
|
|
12
15
|
option :skip_friends, true
|
13
16
|
|
14
|
-
option :
|
17
|
+
option :skip_image_info, true
|
18
|
+
|
19
|
+
option :authorize_options, [:access_type, :hd, :login_hint, :prompt, :request_visible_actions, :scope, :state, :redirect_uri, :include_granted_scopes, :openid_realm]
|
15
20
|
|
16
21
|
option :client_options, {
|
17
22
|
:site => 'https://accounts.google.com',
|
@@ -30,6 +35,7 @@ module OmniAuth
|
|
30
35
|
scope_list.map! { |s| s =~ /^https?:\/\// || BASE_SCOPES.include?(s) ? s : "#{BASE_SCOPE_URL}#{s}" }
|
31
36
|
params[:scope] = scope_list.join(" ")
|
32
37
|
params[:access_type] = 'offline' if params[:access_type].nil?
|
38
|
+
params['openid.realm'] = params.delete(:openid_realm) unless params[:openid_realm].nil?
|
33
39
|
|
34
40
|
session['omniauth.state'] = params[:state] if params['state']
|
35
41
|
end
|
@@ -53,8 +59,23 @@ module OmniAuth
|
|
53
59
|
extra do
|
54
60
|
hash = {}
|
55
61
|
hash[:id_token] = access_token['id_token']
|
62
|
+
if !access_token['id_token'].nil?
|
63
|
+
hash[:id_info] = JWT.decode(
|
64
|
+
access_token['id_token'], nil, false, {
|
65
|
+
:verify_iss => true,
|
66
|
+
'iss' => 'accounts.google.com',
|
67
|
+
:verify_aud => true,
|
68
|
+
'aud' => options.client_id,
|
69
|
+
:verify_sub => false,
|
70
|
+
:verify_expiration => true,
|
71
|
+
:verify_not_before => true,
|
72
|
+
:verify_iat => true,
|
73
|
+
:verify_jti => false
|
74
|
+
}).first
|
75
|
+
end
|
56
76
|
hash[:raw_info] = raw_info unless skip_info?
|
57
77
|
hash[:raw_friend_info] = raw_friend_info(raw_info['sub']) unless skip_info? || options[:skip_friends]
|
78
|
+
hash[:raw_image_info] = raw_image_info(raw_info['sub']) unless skip_info? || options[:skip_image_info]
|
58
79
|
prune! hash
|
59
80
|
end
|
60
81
|
|
@@ -66,11 +87,18 @@ module OmniAuth
|
|
66
87
|
@raw_friend_info ||= access_token.get("https://www.googleapis.com/plus/v1/people/#{id}/people/visible").parsed
|
67
88
|
end
|
68
89
|
|
90
|
+
def raw_image_info(id)
|
91
|
+
@raw_image_info ||= access_token.get("https://www.googleapis.com/plus/v1/people/#{id}?fields=image").parsed
|
92
|
+
end
|
93
|
+
|
69
94
|
def custom_build_access_token
|
70
95
|
if request.xhr? && request.params['code']
|
71
96
|
verifier = request.params['code']
|
72
|
-
client.auth_code.get_token(verifier,
|
73
|
-
|
97
|
+
client.auth_code.get_token(verifier, get_token_options('postmessage'), deep_symbolize(options.auth_token_params || {}))
|
98
|
+
elsif request.params['code'] && request.params['redirect_uri']
|
99
|
+
verifier = request.params['code']
|
100
|
+
redirect_uri = request.params['redirect_uri']
|
101
|
+
client.auth_code.get_token(verifier, get_token_options(redirect_uri), deep_symbolize(options.auth_token_params || {}))
|
74
102
|
elsif verify_token(request.params['id_token'], request.params['access_token'])
|
75
103
|
::OAuth2::AccessToken.from_hash(client, request.params.dup)
|
76
104
|
else
|
@@ -82,6 +110,10 @@ module OmniAuth
|
|
82
110
|
|
83
111
|
private
|
84
112
|
|
113
|
+
def get_token_options(redirect_uri)
|
114
|
+
{ :redirect_uri => redirect_uri }.merge(token_params.to_hash(:symbolize_keys => true))
|
115
|
+
end
|
116
|
+
|
85
117
|
def prune!(hash)
|
86
118
|
hash.delete_if do |_, v|
|
87
119
|
prune!(v) if v.is_a?(Hash)
|
@@ -94,15 +126,20 @@ module OmniAuth
|
|
94
126
|
end
|
95
127
|
|
96
128
|
def image_url
|
97
|
-
|
98
|
-
original_url = original_url.gsub("https:https://", "https://") if original_url
|
99
|
-
params_index = original_url.index('/photo.jpg') if original_url
|
129
|
+
return nil unless raw_info['picture']
|
100
130
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
131
|
+
u = Addressable::URI.parse(raw_info['picture'].gsub('https:https', 'https'))
|
132
|
+
|
133
|
+
path_index = u.path.to_s.index('/photo.jpg')
|
134
|
+
|
135
|
+
if path_index && image_size_opts_passed?
|
136
|
+
u.path.insert(path_index, image_params)
|
137
|
+
u.path = u.path.gsub('//', '/')
|
105
138
|
end
|
139
|
+
|
140
|
+
u.query_values = strip_unnecessary_query_parameters(u.query_values)
|
141
|
+
|
142
|
+
u.to_s
|
106
143
|
end
|
107
144
|
|
108
145
|
def image_size_opts_passed?
|
@@ -122,6 +159,18 @@ module OmniAuth
|
|
122
159
|
'/' + image_params.join('-')
|
123
160
|
end
|
124
161
|
|
162
|
+
def strip_unnecessary_query_parameters(query_values)
|
163
|
+
# strip `sz` parameter (defaults to sz=50) which overrides `image_size` options
|
164
|
+
return nil unless query_values
|
165
|
+
|
166
|
+
query_hash = query_values.delete_if { |key, value| key == "sz" }
|
167
|
+
|
168
|
+
# an empty Hash would cause a ? character in the URL: http://image.url?
|
169
|
+
return nil if query_hash.empty?
|
170
|
+
|
171
|
+
query_hash
|
172
|
+
end
|
173
|
+
|
125
174
|
def verify_token(id_token, access_token)
|
126
175
|
return false unless (id_token && access_token)
|
127
176
|
|
@@ -2,22 +2,23 @@
|
|
2
2
|
require File.expand_path(File.join('..', 'lib', 'omniauth', 'google_oauth2', 'version'), __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.
|
6
|
-
|
5
|
+
gem.name = "omniauth-google-oauth2"
|
6
|
+
gem.version = OmniAuth::GoogleOauth2::VERSION
|
7
|
+
gem.license = 'MIT'
|
8
|
+
gem.summary = %q{A Google OAuth2 strategy for OmniAuth 1.x}
|
9
|
+
gem.description = %q{A Google OAuth2 strategy for OmniAuth 1.x}
|
7
10
|
gem.authors = ["Josh Ellithorpe", "Yury Korolev"]
|
8
11
|
gem.email = ["quest@mac.com"]
|
9
|
-
gem.
|
10
|
-
gem.summary = %q{A Google OAuth2 strategy for OmniAuth 1.x}
|
11
|
-
gem.homepage = ""
|
12
|
+
gem.homepage = "https://github.com/zquestz/omniauth-google-oauth2"
|
12
13
|
|
13
|
-
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
14
14
|
gem.files = `git ls-files`.split("\n")
|
15
|
-
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
16
|
-
gem.name = "omniauth-google-oauth2"
|
17
15
|
gem.require_paths = ["lib"]
|
18
|
-
gem.version = OmniAuth::GoogleOauth2::VERSION
|
19
16
|
|
20
|
-
gem.add_runtime_dependency 'omniauth
|
17
|
+
gem.add_runtime_dependency 'omniauth', '>= 1.1.1'
|
18
|
+
gem.add_runtime_dependency 'omniauth-oauth2', '>= 1.1.1'
|
19
|
+
gem.add_runtime_dependency 'jwt', '~> 1.0'
|
20
|
+
gem.add_runtime_dependency 'multi_json', '~> 1.3'
|
21
|
+
gem.add_runtime_dependency 'addressable', '~> 2.3'
|
21
22
|
|
22
23
|
gem.add_development_dependency 'rspec', '>= 2.14.0'
|
23
24
|
gem.add_development_dependency 'rake'
|
@@ -267,6 +267,7 @@ describe OmniAuth::Strategies::GoogleOauth2 do
|
|
267
267
|
builder.adapter :test do |stub|
|
268
268
|
stub.get('/plus/v1/people/me/openIdConnect') {|env| [200, {'content-type' => 'application/json'}, '{"sub": "12345"}']}
|
269
269
|
stub.get('/plus/v1/people/12345/people/visible') {|env| [200, {'content-type' => 'application/json'}, '[{"foo":"bar"}]']}
|
270
|
+
stub.get('/plus/v1/people/12345?fields=image') {|env| [200, {'content-type' => 'application/json'}, '{"image":"imageData"}']}
|
270
271
|
end
|
271
272
|
end
|
272
273
|
end
|
@@ -276,10 +277,24 @@ describe OmniAuth::Strategies::GoogleOauth2 do
|
|
276
277
|
|
277
278
|
describe 'id_token' do
|
278
279
|
context 'when the id_token is passed into the access token' do
|
279
|
-
|
280
|
+
token_info =
|
281
|
+
{
|
282
|
+
'abc' => 'xyz',
|
283
|
+
'exp' => Time.now.to_i + 3600,
|
284
|
+
'nbf' => Time.now.to_i - 60,
|
285
|
+
'iat' => Time.now.to_i,
|
286
|
+
'aud' => 'appid',
|
287
|
+
'iss' => 'accounts.google.com',
|
288
|
+
}
|
289
|
+
id_token = JWT.encode(token_info, 'secret')
|
290
|
+
let(:access_token) { OAuth2::AccessToken.from_hash(client, {'id_token' => id_token}) }
|
280
291
|
|
281
292
|
it 'should include id_token when set on the access_token' do
|
282
|
-
expect(subject.extra).to include(:id_token =>
|
293
|
+
expect(subject.extra).to include(:id_token => id_token)
|
294
|
+
end
|
295
|
+
|
296
|
+
it 'should include id_info when id_token set on the access_token' do
|
297
|
+
expect(subject.extra).to include(:id_info => token_info)
|
283
298
|
end
|
284
299
|
end
|
285
300
|
|
@@ -287,6 +302,10 @@ describe OmniAuth::Strategies::GoogleOauth2 do
|
|
287
302
|
it 'should not include id_token' do
|
288
303
|
expect(subject.extra).not_to have_key(:id_token)
|
289
304
|
end
|
305
|
+
|
306
|
+
it 'should not include id_info' do
|
307
|
+
expect(subject.extra).not_to have_key(:id_info)
|
308
|
+
end
|
290
309
|
end
|
291
310
|
end
|
292
311
|
|
@@ -337,6 +356,36 @@ describe OmniAuth::Strategies::GoogleOauth2 do
|
|
337
356
|
end
|
338
357
|
end
|
339
358
|
end
|
359
|
+
|
360
|
+
describe 'raw_image_info' do
|
361
|
+
context 'when skip_info is true' do
|
362
|
+
before { subject.options[:skip_info] = true }
|
363
|
+
|
364
|
+
it 'should not include raw_image_info' do
|
365
|
+
expect(subject.extra).not_to have_key(:raw_image_info)
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
context 'when skip_info is false' do
|
370
|
+
before { subject.options[:skip_info] = false }
|
371
|
+
|
372
|
+
context 'when skip_image_info is true' do
|
373
|
+
before { subject.options[:skip_image_info] = true }
|
374
|
+
|
375
|
+
it 'should not include raw_image_info' do
|
376
|
+
expect(subject.extra).not_to have_key(:raw_image_info)
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
context 'when skip_image_info is false' do
|
381
|
+
before { subject.options[:skip_image_info] = false }
|
382
|
+
|
383
|
+
it 'should include raw_image_info' do
|
384
|
+
expect(subject.extra[:raw_image_info]).to eq({'image' => 'imageData'})
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
340
389
|
end
|
341
390
|
|
342
391
|
describe 'populate auth hash urls' do
|
@@ -365,6 +414,30 @@ describe OmniAuth::Strategies::GoogleOauth2 do
|
|
365
414
|
expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg')
|
366
415
|
end
|
367
416
|
|
417
|
+
it 'should handle a picture with too many slashes correctly' do
|
418
|
+
@options = {:image_size => 50}
|
419
|
+
allow(subject).to receive(:raw_info) { {'picture' => 'https://lh3.googleusercontent.com/url//photo.jpg'} }
|
420
|
+
expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg')
|
421
|
+
end
|
422
|
+
|
423
|
+
it 'should handle a picture with a size query parameter correctly' do
|
424
|
+
@options = {:image_size => 50}
|
425
|
+
allow(subject).to receive(:raw_info) { {'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg?sz=50'} }
|
426
|
+
expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg')
|
427
|
+
end
|
428
|
+
|
429
|
+
it 'should handle a picture with a size query parameter and other valid query parameters correctly' do
|
430
|
+
@options = {:image_size => 50}
|
431
|
+
allow(subject).to receive(:raw_info) { {'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg?sz=50&hello=true&life=42'} }
|
432
|
+
expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg?hello=true&life=42')
|
433
|
+
end
|
434
|
+
|
435
|
+
it 'should handle a picture with other valid query parameters correctly' do
|
436
|
+
@options = {:image_size => 50}
|
437
|
+
allow(subject).to receive(:raw_info) { {'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg?hello=true&life=42'} }
|
438
|
+
expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg?hello=true&life=42')
|
439
|
+
end
|
440
|
+
|
368
441
|
it 'should return the image with width and height specified in the `image_size` option' do
|
369
442
|
@options = {:image_size => {:width => 50, :height => 40}}
|
370
443
|
allow(subject).to receive(:raw_info) { {'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg'} }
|
@@ -400,7 +473,7 @@ describe OmniAuth::Strategies::GoogleOauth2 do
|
|
400
473
|
allow(subject).to receive(:raw_info) { {'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg'} }
|
401
474
|
expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/photo.jpg')
|
402
475
|
end
|
403
|
-
|
476
|
+
|
404
477
|
it 'should return correct image if google image url has double https' do
|
405
478
|
allow(subject).to receive(:raw_info) { {'picture' => 'https:https://lh3.googleusercontent.com/url/photo.jpg'} }
|
406
479
|
expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/photo.jpg')
|
@@ -422,6 +495,20 @@ describe OmniAuth::Strategies::GoogleOauth2 do
|
|
422
495
|
subject.build_access_token
|
423
496
|
end
|
424
497
|
|
498
|
+
it 'should use the request_uri from params if this not an AJAX request (request from installed app) with a code parameter' do
|
499
|
+
allow(request).to receive(:xhr?).and_return(false)
|
500
|
+
allow(request).to receive(:params).and_return('code' => 'valid_code', 'redirect_uri' => 'redirect_uri')
|
501
|
+
|
502
|
+
client = double(:client)
|
503
|
+
auth_code = double(:auth_code)
|
504
|
+
allow(client).to receive(:auth_code).and_return(auth_code)
|
505
|
+
expect(subject).to receive(:client).and_return(client)
|
506
|
+
expect(auth_code).to receive(:get_token).with('valid_code', { :redirect_uri => 'redirect_uri'}, {})
|
507
|
+
|
508
|
+
expect(subject).not_to receive(:orig_build_access_token)
|
509
|
+
subject.build_access_token
|
510
|
+
end
|
511
|
+
|
425
512
|
it 'should read access_token from hash if this is not an AJAX request with a code parameter' do
|
426
513
|
allow(request).to receive(:xhr?).and_return(false)
|
427
514
|
allow(request).to receive(:params).and_return('id_token' => 'valid_id_token', 'access_token' => 'valid_access_token')
|
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.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Ellithorpe
|
@@ -9,36 +9,78 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 1.1.1
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 1.1.1
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: omniauth-oauth2
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.1.1
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.1.1
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: jwt
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
19
47
|
- !ruby/object:Gem::Version
|
20
48
|
version: '1.0'
|
21
49
|
type: :runtime
|
22
50
|
prerelease: false
|
23
51
|
version_requirements: !ruby/object:Gem::Requirement
|
24
52
|
requirements:
|
25
|
-
- - "
|
53
|
+
- - "~>"
|
26
54
|
- !ruby/object:Gem::Version
|
27
55
|
version: '1.0'
|
28
56
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
57
|
+
name: multi_json
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.3'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.3'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: addressable
|
30
72
|
requirement: !ruby/object:Gem::Requirement
|
31
73
|
requirements:
|
32
74
|
- - "~>"
|
33
75
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
76
|
+
version: '2.3'
|
35
77
|
type: :runtime
|
36
78
|
prerelease: false
|
37
79
|
version_requirements: !ruby/object:Gem::Requirement
|
38
80
|
requirements:
|
39
81
|
- - "~>"
|
40
82
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
83
|
+
version: '2.3'
|
42
84
|
- !ruby/object:Gem::Dependency
|
43
85
|
name: rspec
|
44
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,11 +129,12 @@ files:
|
|
87
129
|
- lib/omniauth/google_oauth2.rb
|
88
130
|
- lib/omniauth/google_oauth2/version.rb
|
89
131
|
- lib/omniauth/strategies/google_oauth2.rb
|
90
|
-
- omniauth-
|
132
|
+
- omniauth-google-oauth2.gemspec
|
91
133
|
- spec/omniauth/strategies/google_oauth2_spec.rb
|
92
134
|
- spec/spec_helper.rb
|
93
|
-
homepage:
|
94
|
-
licenses:
|
135
|
+
homepage: https://github.com/zquestz/omniauth-google-oauth2
|
136
|
+
licenses:
|
137
|
+
- MIT
|
95
138
|
metadata: {}
|
96
139
|
post_install_message:
|
97
140
|
rdoc_options: []
|
@@ -109,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
152
|
version: '0'
|
110
153
|
requirements: []
|
111
154
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
155
|
+
rubygems_version: 2.4.3
|
113
156
|
signing_key:
|
114
157
|
specification_version: 4
|
115
158
|
summary: A Google OAuth2 strategy for OmniAuth 1.x
|