omniauth-github 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/LICENSE.txt +7 -0
- data/lib/omniauth-github/version.rb +1 -1
- data/lib/omniauth/strategies/github.rb +11 -9
- data/omniauth-github.gemspec +4 -3
- data/spec/omniauth/strategies/github_spec.rb +60 -51
- metadata +37 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7986a2ed4311a685808c9e48398b32f6139ebd8
|
4
|
+
data.tar.gz: 36aba37491bc6a201d890367e072cd6b15313c99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c4e0eb536076fb833f47dfe595d341080d4423baf1c4ec4ef6ada5c3edaca4b988014b33a9e8b843d5702481d5c02dd29daca1b9a5ee0f14dbb9411a36a69b1
|
7
|
+
data.tar.gz: f391830a231cfa72d82c413084d1978c1a7de3d3794552504e42ba26a442ee4b88fae13fd4b1ff85ca3d4c6a625e6703c0e8c24bd1c0a354b66ab7c61ca0f99e
|
data/Gemfile
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2011 Michael Bleigh and Intridea, Inc.
|
2
|
+
|
3
|
+
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:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -12,7 +12,7 @@ module OmniAuth
|
|
12
12
|
def request_phase
|
13
13
|
super
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def authorize_params
|
17
17
|
super.tap do |params|
|
18
18
|
%w[scope client_options].each do |v|
|
@@ -28,18 +28,18 @@ module OmniAuth
|
|
28
28
|
info do
|
29
29
|
{
|
30
30
|
'nickname' => raw_info['login'],
|
31
|
-
'email' =>
|
31
|
+
'email' => primary_email,
|
32
32
|
'name' => raw_info['name'],
|
33
33
|
'image' => raw_info['avatar_url'],
|
34
34
|
'urls' => {
|
35
|
-
'GitHub' =>
|
35
|
+
'GitHub' => raw_info['html_url'],
|
36
36
|
'Blog' => raw_info['blog'],
|
37
37
|
},
|
38
38
|
}
|
39
39
|
end
|
40
40
|
|
41
41
|
extra do
|
42
|
-
{:raw_info => raw_info}
|
42
|
+
{:raw_info => raw_info, :all_emails => emails}
|
43
43
|
end
|
44
44
|
|
45
45
|
def raw_info
|
@@ -48,12 +48,12 @@ module OmniAuth
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def email
|
51
|
-
|
51
|
+
(email_access_allowed?) ? primary_email : raw_info['email']
|
52
52
|
end
|
53
53
|
|
54
54
|
def primary_email
|
55
|
-
primary = emails.find{|i| i['primary'] }
|
56
|
-
primary && primary['email'] ||
|
55
|
+
primary = emails.find{ |i| i['primary'] && i['verified'] }
|
56
|
+
primary && primary['email'] || nil
|
57
57
|
end
|
58
58
|
|
59
59
|
# The new /user/emails API - http://developer.github.com/v3/users/emails/#future-response
|
@@ -64,9 +64,11 @@ module OmniAuth
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def email_access_allowed?
|
67
|
-
options['scope']
|
67
|
+
return false unless options['scope']
|
68
|
+
email_scopes = ['user', 'user:email']
|
69
|
+
scopes = options['scope'].split(',')
|
70
|
+
(scopes & email_scopes).any?
|
68
71
|
end
|
69
|
-
|
70
72
|
end
|
71
73
|
end
|
72
74
|
end
|
data/omniauth-github.gemspec
CHANGED
@@ -7,6 +7,7 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.description = %q{Official OmniAuth strategy for GitHub.}
|
8
8
|
gem.summary = %q{Official OmniAuth strategy for GitHub.}
|
9
9
|
gem.homepage = "https://github.com/intridea/omniauth-github"
|
10
|
+
gem.license = "MIT"
|
10
11
|
|
11
12
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
13
|
gem.files = `git ls-files`.split("\n")
|
@@ -15,9 +16,9 @@ Gem::Specification.new do |gem|
|
|
15
16
|
gem.require_paths = ["lib"]
|
16
17
|
gem.version = OmniAuth::GitHub::VERSION
|
17
18
|
|
18
|
-
gem.add_dependency 'omniauth', '~> 1.
|
19
|
-
gem.add_dependency 'omniauth-oauth2', '
|
20
|
-
gem.add_development_dependency 'rspec', '~>
|
19
|
+
gem.add_dependency 'omniauth', '~> 1.3.2'
|
20
|
+
gem.add_dependency 'omniauth-oauth2', '>= 1.4.0', '< 2.0'
|
21
|
+
gem.add_development_dependency 'rspec', '~> 3.5'
|
21
22
|
gem.add_development_dependency 'rack-test'
|
22
23
|
gem.add_development_dependency 'simplecov'
|
23
24
|
gem.add_development_dependency 'webmock'
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe OmniAuth::Strategies::GitHub do
|
4
|
-
let(:access_token) {
|
5
|
-
let(:parsed_response) {
|
6
|
-
let(:response) {
|
4
|
+
let(:access_token) { instance_double('AccessToken', :options => {}) }
|
5
|
+
let(:parsed_response) { instance_double('ParsedResponse') }
|
6
|
+
let(:response) { instance_double('Response', :parsed => parsed_response) }
|
7
7
|
|
8
8
|
let(:enterprise_site) { 'https://some.other.site.com/api/v3' }
|
9
9
|
let(:enterprise_authorize_url) { 'https://some.other.site.com/login/oauth/authorize' }
|
@@ -25,111 +25,120 @@ describe OmniAuth::Strategies::GitHub do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
before(:each) do
|
28
|
-
subject.
|
28
|
+
allow(subject).to receive(:access_token).and_return(access_token)
|
29
29
|
end
|
30
30
|
|
31
|
-
context
|
31
|
+
context 'client options' do
|
32
32
|
it 'should have correct site' do
|
33
|
-
subject.options.client_options.site.
|
33
|
+
expect(subject.options.client_options.site).to eq('https://api.github.com')
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should have correct authorize url' do
|
37
|
-
subject.options.client_options.authorize_url.
|
37
|
+
expect(subject.options.client_options.authorize_url).to eq('https://github.com/login/oauth/authorize')
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should have correct token url' do
|
41
|
-
subject.options.client_options.token_url.
|
41
|
+
expect(subject.options.client_options.token_url).to eq('https://github.com/login/oauth/access_token')
|
42
42
|
end
|
43
43
|
|
44
|
-
describe
|
45
|
-
it
|
46
|
-
enterprise.options.client_options.site.
|
44
|
+
describe 'should be overrideable' do
|
45
|
+
it 'for site' do
|
46
|
+
expect(enterprise.options.client_options.site).to eq(enterprise_site)
|
47
47
|
end
|
48
48
|
|
49
|
-
it
|
50
|
-
enterprise.options.client_options.authorize_url.
|
49
|
+
it 'for authorize url' do
|
50
|
+
expect(enterprise.options.client_options.authorize_url).to eq(enterprise_authorize_url)
|
51
51
|
end
|
52
52
|
|
53
|
-
it
|
54
|
-
enterprise.options.client_options.token_url.
|
53
|
+
it 'for token url' do
|
54
|
+
expect(enterprise.options.client_options.token_url).to eq(enterprise_token_url)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
context
|
60
|
-
it
|
61
|
-
subject.options['scope'].
|
62
|
-
subject.
|
59
|
+
context '#email_access_allowed?' do
|
60
|
+
it 'should not allow email if scope is nil' do
|
61
|
+
expect(subject.options['scope']).to be_nil
|
62
|
+
expect(subject).to_not be_email_access_allowed
|
63
63
|
end
|
64
64
|
|
65
|
-
it
|
65
|
+
it 'should allow email if scope is user' do
|
66
66
|
subject.options['scope'] = 'user'
|
67
|
-
subject.
|
67
|
+
expect(subject).to be_email_access_allowed
|
68
68
|
end
|
69
69
|
|
70
|
-
it
|
70
|
+
it 'should allow email if scope is a bunch of stuff including user' do
|
71
71
|
subject.options['scope'] = 'public_repo,user,repo,delete_repo,gist'
|
72
|
-
subject.
|
72
|
+
expect(subject).to be_email_access_allowed
|
73
73
|
end
|
74
74
|
|
75
|
-
it
|
76
|
-
subject.options['scope'] = 'repo'
|
77
|
-
subject.
|
75
|
+
it 'should not allow email if scope does not grant email access' do
|
76
|
+
subject.options['scope'] = 'repo,user:follow'
|
77
|
+
expect(subject).to_not be_email_access_allowed
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
80
|
+
it 'should assume email access not allowed if scope is something currently not documented' do
|
81
81
|
subject.options['scope'] = 'currently_not_documented'
|
82
|
-
subject.
|
82
|
+
expect(subject).to_not be_email_access_allowed
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
context
|
87
|
-
it
|
88
|
-
subject.
|
89
|
-
subject.email.
|
86
|
+
context '#email' do
|
87
|
+
it 'should return email from raw_info if available' do
|
88
|
+
allow(subject).to receive(:raw_info).and_return({ 'email' => 'you@example.com' })
|
89
|
+
expect(subject.email).to eq('you@example.com')
|
90
90
|
end
|
91
91
|
|
92
|
-
it
|
93
|
-
subject.
|
94
|
-
subject.email.
|
92
|
+
it 'should return nil if there is no raw_info and email access is not allowed' do
|
93
|
+
allow(subject).to receive(:raw_info).and_return({})
|
94
|
+
expect(subject.email).to be_nil
|
95
95
|
end
|
96
96
|
|
97
|
-
it
|
97
|
+
it 'should not return the primary email if there is no raw_info and email access is allowed' do
|
98
98
|
emails = [
|
99
99
|
{ 'email' => 'secondary@example.com', 'primary' => false },
|
100
100
|
{ 'email' => 'primary@example.com', 'primary' => true }
|
101
101
|
]
|
102
|
-
subject.
|
102
|
+
allow(subject).to receive(:raw_info).and_return({})
|
103
103
|
subject.options['scope'] = 'user'
|
104
|
-
subject.
|
105
|
-
subject.email.
|
104
|
+
allow(subject).to receive(:emails).and_return(emails)
|
105
|
+
expect(subject.email).to be_nil
|
106
106
|
end
|
107
107
|
|
108
|
-
it
|
108
|
+
it 'should not return the first email if there is no raw_info and email access is allowed' do
|
109
109
|
emails = [
|
110
110
|
{ 'email' => 'first@example.com', 'primary' => false },
|
111
111
|
{ 'email' => 'second@example.com', 'primary' => false }
|
112
112
|
]
|
113
|
-
subject.
|
113
|
+
allow(subject).to receive(:raw_info).and_return({})
|
114
114
|
subject.options['scope'] = 'user'
|
115
|
-
subject.
|
116
|
-
subject.email.
|
115
|
+
allow(subject).to receive(:emails).and_return(emails)
|
116
|
+
expect(subject.email).to be_nil
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
-
context
|
121
|
-
it
|
122
|
-
access_token.
|
123
|
-
subject.raw_info.
|
120
|
+
context '#raw_info' do
|
121
|
+
it 'should use relative paths' do
|
122
|
+
expect(access_token).to receive(:get).with('user').and_return(response)
|
123
|
+
expect(subject.raw_info).to eq(parsed_response)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
-
context
|
128
|
-
it
|
129
|
-
access_token.
|
127
|
+
context '#emails' do
|
128
|
+
it 'should use relative paths' do
|
129
|
+
expect(access_token).to receive(:get).with('user/emails', :headers => {
|
130
|
+
'Accept' => 'application/vnd.github.v3'
|
131
|
+
}).and_return(response)
|
132
|
+
|
130
133
|
subject.options['scope'] = 'user'
|
131
|
-
subject.emails.
|
134
|
+
expect(subject.emails).to eq(parsed_response)
|
132
135
|
end
|
133
136
|
end
|
134
137
|
|
138
|
+
context '#info.urls' do
|
139
|
+
it 'should use html_url from raw_info' do
|
140
|
+
allow(subject).to receive(:raw_info).and_return({ 'login' => 'me', 'html_url' => 'http://enterprise/me' })
|
141
|
+
expect(subject.info['urls']['GitHub']).to eq('http://enterprise/me')
|
142
|
+
end
|
143
|
+
end
|
135
144
|
end
|
metadata
CHANGED
@@ -1,97 +1,103 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.3.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.3.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: omniauth-oauth2
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.4.0
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '2.0'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- -
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.4.0
|
44
|
+
- - "<"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
46
|
+
version: '2.0'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: rspec
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- - ~>
|
51
|
+
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
53
|
+
version: '3.5'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- - ~>
|
58
|
+
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
60
|
+
version: '3.5'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: rack-test
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- -
|
65
|
+
- - ">="
|
60
66
|
- !ruby/object:Gem::Version
|
61
67
|
version: '0'
|
62
68
|
type: :development
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
|
-
- -
|
72
|
+
- - ">="
|
67
73
|
- !ruby/object:Gem::Version
|
68
74
|
version: '0'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: simplecov
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
|
-
- -
|
79
|
+
- - ">="
|
74
80
|
- !ruby/object:Gem::Version
|
75
81
|
version: '0'
|
76
82
|
type: :development
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
|
-
- -
|
86
|
+
- - ">="
|
81
87
|
- !ruby/object:Gem::Version
|
82
88
|
version: '0'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: webmock
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
|
-
- -
|
93
|
+
- - ">="
|
88
94
|
- !ruby/object:Gem::Version
|
89
95
|
version: '0'
|
90
96
|
type: :development
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
|
-
- -
|
100
|
+
- - ">="
|
95
101
|
- !ruby/object:Gem::Version
|
96
102
|
version: '0'
|
97
103
|
description: Official OmniAuth strategy for GitHub.
|
@@ -101,10 +107,11 @@ executables: []
|
|
101
107
|
extensions: []
|
102
108
|
extra_rdoc_files: []
|
103
109
|
files:
|
104
|
-
- .gitignore
|
105
|
-
- .rspec
|
110
|
+
- ".gitignore"
|
111
|
+
- ".rspec"
|
106
112
|
- Gemfile
|
107
113
|
- Guardfile
|
114
|
+
- LICENSE.txt
|
108
115
|
- README.md
|
109
116
|
- Rakefile
|
110
117
|
- lib/omniauth-github.rb
|
@@ -114,7 +121,8 @@ files:
|
|
114
121
|
- spec/omniauth/strategies/github_spec.rb
|
115
122
|
- spec/spec_helper.rb
|
116
123
|
homepage: https://github.com/intridea/omniauth-github
|
117
|
-
licenses:
|
124
|
+
licenses:
|
125
|
+
- MIT
|
118
126
|
metadata: {}
|
119
127
|
post_install_message:
|
120
128
|
rdoc_options: []
|
@@ -122,19 +130,20 @@ require_paths:
|
|
122
130
|
- lib
|
123
131
|
required_ruby_version: !ruby/object:Gem::Requirement
|
124
132
|
requirements:
|
125
|
-
- -
|
133
|
+
- - ">="
|
126
134
|
- !ruby/object:Gem::Version
|
127
135
|
version: '0'
|
128
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
137
|
requirements:
|
130
|
-
- -
|
138
|
+
- - ">="
|
131
139
|
- !ruby/object:Gem::Version
|
132
140
|
version: '0'
|
133
141
|
requirements: []
|
134
142
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.6.4
|
136
144
|
signing_key:
|
137
145
|
specification_version: 4
|
138
146
|
summary: Official OmniAuth strategy for GitHub.
|
139
|
-
test_files:
|
140
|
-
|
147
|
+
test_files:
|
148
|
+
- spec/omniauth/strategies/github_spec.rb
|
149
|
+
- spec/spec_helper.rb
|