omniauth-gplus-signin 0.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.
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +6 -0
- data/Rakefile +31 -0
- data/lib/omniauth-googleplus.rb +5 -0
- data/lib/omniauth/googleplus/version.rb +5 -0
- data/lib/omniauth/strategies/googleplus.rb +86 -0
- data/omniauth-gplus-signin.gemspec +30 -0
- metadata +183 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Tom Waddington
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'yard'
|
6
|
+
|
7
|
+
begin
|
8
|
+
Bundler.setup :default, :development
|
9
|
+
rescue Bundler::BundlerError => error
|
10
|
+
$stderr.puts error.message
|
11
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
12
|
+
exit error.status_code
|
13
|
+
end
|
14
|
+
|
15
|
+
Bundler::GemHelper.install_tasks
|
16
|
+
|
17
|
+
desc "Run all of the tests"
|
18
|
+
Rake::TestTask.new do |config|
|
19
|
+
config.libs << 'test'
|
20
|
+
config.pattern = 'test/**/*_test*'
|
21
|
+
# config.verbose = true
|
22
|
+
# config.warning = true
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Generate all of the docs"
|
26
|
+
YARD::Rake::YardocTask.new do |config|
|
27
|
+
config.files = Dir['lib/**/*.rb']
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Default: run tests, and generate docs'
|
31
|
+
task :default => [ :test, :yard ]
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class GooglePlus < OmniAuth::Strategies::OAuth2
|
6
|
+
DEFAULT_SCOPE = "userinfo.email,plus.login"
|
7
|
+
|
8
|
+
|
9
|
+
option :name, 'googleplus'
|
10
|
+
option :authorize_options, [:scope, :approval_prompt, :access_type, :state, :hd]
|
11
|
+
|
12
|
+
option :client_options, {
|
13
|
+
:site => 'https://accounts.google.com',
|
14
|
+
:authorize_url => '/o/oauth2/auth',
|
15
|
+
:token_url => '/o/oauth2/token'
|
16
|
+
}
|
17
|
+
|
18
|
+
def authorize_params
|
19
|
+
base_scope_url = "https://www.googleapis.com/auth/"
|
20
|
+
|
21
|
+
super.tap do |params|
|
22
|
+
# Read the params if passed directly to omniauth_authorize_path
|
23
|
+
%w(scope approval_prompt access_type state hd user_id request_visible_actions).each do |k|
|
24
|
+
params[k.to_sym] = request.params[k] unless [nil, ''].include?(request.params[k])
|
25
|
+
end
|
26
|
+
scopes = (params[:scope] || DEFAULT_SCOPE).split(",")
|
27
|
+
scopes.map! { |s| s =~ /^https?:\/\// ? s : "#{base_scope_url}#{s}" }
|
28
|
+
params[:scope] = scopes.join(' ')
|
29
|
+
|
30
|
+
# Override the state per request
|
31
|
+
session['omniauth.state'] = params[:state] if request.params['state']
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
uid{ raw_info['id'] || verified_email }
|
36
|
+
|
37
|
+
info do
|
38
|
+
prune!({
|
39
|
+
:name => raw_info['displayName'],
|
40
|
+
:email => verified_email,
|
41
|
+
:first_name => raw_info['name']['givenName'],
|
42
|
+
:last_name => raw_info['name']['familyName'],
|
43
|
+
:image => raw_info['image']['url'],
|
44
|
+
:location => location,
|
45
|
+
:description=> CGI::unescapeHTML(raw_info['aboutMe']),
|
46
|
+
:urls => {
|
47
|
+
'Google' => raw_info['link']
|
48
|
+
}
|
49
|
+
})
|
50
|
+
end
|
51
|
+
|
52
|
+
extra do
|
53
|
+
hash = {}
|
54
|
+
hash[:raw_info] = raw_info unless skip_info?
|
55
|
+
prune! hash
|
56
|
+
end
|
57
|
+
|
58
|
+
def email_info
|
59
|
+
@email_info ||= access_token.get('https://www.googleapis.com/oauth2/v1/userinfo').parsed
|
60
|
+
end
|
61
|
+
|
62
|
+
def location
|
63
|
+
raw_info['currentLocation'] || raw_info['placesLived'].select { |place| place.has_key?('primary') }.first['value'] rescue nil
|
64
|
+
end
|
65
|
+
|
66
|
+
def raw_info
|
67
|
+
#GET https://www.googleapis.com/plus/v1/people/userId
|
68
|
+
@raw_info ||= access_token.get('https://www.googleapis.com/plus/v1/people/me').parsed
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def prune!(hash)
|
74
|
+
hash.delete_if do |_, value|
|
75
|
+
prune!(value) if value.is_a?(Hash)
|
76
|
+
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def verified_email
|
81
|
+
email_info['verified_email'] ? email_info['email'] : nil
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'omniauth/googleplus/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "omniauth-gplus-signin"
|
7
|
+
spec.version = OmniAuth::GooglePlus::VERSION
|
8
|
+
spec.authors = ["Tom Waddington"]
|
9
|
+
spec.email = ["tom@tomwaddington.co.uk"]
|
10
|
+
spec.summary = %q{A Google+ Sign In OAuth2 strategy for Omniauth}
|
11
|
+
spec.description = spec.summary
|
12
|
+
spec.homepage = "http://www.github.com/tomwaddington/omniauth-googleplus"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = [] #spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency "omniauth-oauth2", '~> 1.1'
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "mocha"
|
25
|
+
spec.add_development_dependency 'yard'
|
26
|
+
spec.add_development_dependency 'kramdown'
|
27
|
+
spec.add_development_dependency 'pry'
|
28
|
+
spec.add_development_dependency 'coveralls'
|
29
|
+
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-gplus-signin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tom Waddington
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth2
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.1'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: mocha
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: yard
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: kramdown
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: pry
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: coveralls
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
description: A Google+ Sign In OAuth2 strategy for Omniauth
|
143
|
+
email:
|
144
|
+
- tom@tomwaddington.co.uk
|
145
|
+
executables: []
|
146
|
+
extensions: []
|
147
|
+
extra_rdoc_files: []
|
148
|
+
files:
|
149
|
+
- .gitignore
|
150
|
+
- Gemfile
|
151
|
+
- LICENSE.txt
|
152
|
+
- README.md
|
153
|
+
- Rakefile
|
154
|
+
- lib/omniauth-googleplus.rb
|
155
|
+
- lib/omniauth/googleplus/version.rb
|
156
|
+
- lib/omniauth/strategies/googleplus.rb
|
157
|
+
- omniauth-gplus-signin.gemspec
|
158
|
+
homepage: http://www.github.com/tomwaddington/omniauth-googleplus
|
159
|
+
licenses:
|
160
|
+
- MIT
|
161
|
+
post_install_message:
|
162
|
+
rdoc_options: []
|
163
|
+
require_paths:
|
164
|
+
- lib
|
165
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
+
none: false
|
167
|
+
requirements:
|
168
|
+
- - ! '>='
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
none: false
|
173
|
+
requirements:
|
174
|
+
- - ! '>='
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
requirements: []
|
178
|
+
rubyforge_project:
|
179
|
+
rubygems_version: 1.8.24
|
180
|
+
signing_key:
|
181
|
+
specification_version: 3
|
182
|
+
summary: A Google+ Sign In OAuth2 strategy for Omniauth
|
183
|
+
test_files: []
|