omniauth-google-oauth2 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Get your API key at https://code.google.com/apis/console/
|
|
6
6
|
|
7
7
|
## License
|
8
8
|
|
9
|
-
Copyright (c)
|
9
|
+
Copyright (c) 2012 by Josh Ellithorpe
|
10
10
|
|
11
11
|
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:
|
12
12
|
|
@@ -8,7 +8,7 @@ module OmniAuth
|
|
8
8
|
DEFAULT_SCOPE = "userinfo.email,userinfo.profile"
|
9
9
|
|
10
10
|
option :name, 'google_oauth2'
|
11
|
-
option :authorize_options, [:scope, :approval_prompt, :access_type, :
|
11
|
+
option :authorize_options, [:scope, :approval_prompt, :access_type, :hd]
|
12
12
|
|
13
13
|
option :client_options, {
|
14
14
|
:site => 'https://accounts.google.com',
|
@@ -21,7 +21,6 @@ module OmniAuth
|
|
21
21
|
super.tap do |params|
|
22
22
|
scopes = (params[:scope] || DEFAULT_SCOPE).split(",")
|
23
23
|
scopes.map! { |s| s =~ /^https?:\/\// ? s : "#{base_scope_url}#{s}" }
|
24
|
-
params[:state] = request.params['state'] if request.params['state']
|
25
24
|
params[:scope] = scopes.join(' ')
|
26
25
|
# This makes sure we get a refresh_token.
|
27
26
|
# http://googlecode.blogspot.com/2011/10/upcoming-changes-to-oauth-20-endpoint.html
|
@@ -29,7 +28,8 @@ module OmniAuth
|
|
29
28
|
params[:approval_prompt] = 'force' if params[:approval_prompt].nil?
|
30
29
|
# allow overriding approval_prompt on the request itself
|
31
30
|
params[:approval_prompt] = request.params['approval_prompt'] if request_has_approval_prompt
|
32
|
-
|
31
|
+
# hd ("Hosted Domain") can be set to a Google Apps domain to force a login to that domain
|
32
|
+
params[:hd] = request.params['hd'] if request.params['hd']
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -44,7 +44,7 @@ module OmniAuth
|
|
44
44
|
:image => raw_info['picture']
|
45
45
|
})
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
extra do
|
49
49
|
hash = {}
|
50
50
|
hash[:raw_info] = raw_info unless skip_info?
|
@@ -74,4 +74,4 @@ module OmniAuth
|
|
74
74
|
|
75
75
|
end
|
76
76
|
end
|
77
|
-
end
|
77
|
+
end
|
@@ -2,14 +2,14 @@ require 'spec_helper'
|
|
2
2
|
require 'omniauth-google-oauth2'
|
3
3
|
|
4
4
|
describe OmniAuth::Strategies::GoogleOauth2 do
|
5
|
-
|
5
|
+
|
6
6
|
before :each do
|
7
7
|
@request = double('Request')
|
8
8
|
@request.stub(:params) { {} }
|
9
9
|
@request.stub(:cookies) { {} }
|
10
10
|
@request.stub(:env) { {} }
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
subject do
|
14
14
|
OmniAuth::Strategies::GoogleOauth2.new(nil, @options || {}).tap do |strategy|
|
15
15
|
strategy.stub(:request) { @request }
|
@@ -38,7 +38,7 @@ describe OmniAuth::Strategies::GoogleOauth2 do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
describe '#authorize_params' do
|
41
|
+
describe '#authorize_params' do
|
42
42
|
it 'should expand scope shortcuts' do
|
43
43
|
@options = { :authorize_options => [:scope], :scope => 'userinfo.email'}
|
44
44
|
subject.authorize_params['scope'].should eq('https://www.googleapis.com/auth/userinfo.email')
|
@@ -59,16 +59,6 @@ describe OmniAuth::Strategies::GoogleOauth2 do
|
|
59
59
|
subject.authorize_params['scope'].should eq('https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile')
|
60
60
|
end
|
61
61
|
|
62
|
-
it 'should set the state parameter' do
|
63
|
-
@options = {:state => "some_state"}
|
64
|
-
subject.authorize_params['state'].should eq('some_state')
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'should set the state parameter dynamically' do
|
68
|
-
subject.stub(:request) { double('Request', {:params => { 'state' => 'some_state' }, :env => {}}) }
|
69
|
-
subject.authorize_params['state'].should eq('some_state')
|
70
|
-
end
|
71
|
-
|
72
62
|
it 'should allow request parameter to override approval_prompt' do
|
73
63
|
@options = {:approval_prompt => ''} # non-nil prevent default 'force'
|
74
64
|
# stub the request
|
@@ -85,6 +75,11 @@ describe OmniAuth::Strategies::GoogleOauth2 do
|
|
85
75
|
@options = { :skip_info => true }
|
86
76
|
subject.extra.should_not have_key(:raw_info)
|
87
77
|
end
|
78
|
+
|
79
|
+
it 'should set the hd (hosted domain) parameter if present' do
|
80
|
+
@options = {:hd => "example.com"}
|
81
|
+
subject.authorize_params['hd'].should eq('example.com')
|
82
|
+
end
|
88
83
|
end
|
89
84
|
|
90
|
-
end
|
85
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-google-oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 11
|
10
|
+
version: 0.1.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Josh Ellithorpe
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-
|
19
|
+
date: 2012-07-08 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: omniauth
|