omniauth-github-organization 0.1.1 → 0.1.2
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0de1670bdccb65312021de8fa605c7b1f916927d461e254bedcf78e6705809c7
|
4
|
+
data.tar.gz: 52d3f97602da9b052a931efbf83ce0bdf61b78fd6e3ae0f86274ea6503693c44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14bc8f4374cf6646f01de5c0aabbc57591ad727c9cc0b8c6a0428ba565a4518ee16889f2e21e7503f48786a588290c0659f8216cc0bfab1f5a2084aa649968ca
|
7
|
+
data.tar.gz: 131fae3accfb3fe29ef2fb1eed03aa51f605e0787b900301f9fb37477345b26c260a5eb505594c7dfd6a1d13a6f8cfbf5398ed993aa9f647d635cdb54615454b
|
@@ -28,14 +28,25 @@ module OmniAuth
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def callback_phase
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
error = request.params["error_reason"] || request.params["error"]
|
32
|
+
if error
|
33
|
+
fail!(error, CallbackError.new(request.params["error"], request.params["error_description"] || request.params["error_reason"], request.params["error_uri"]))
|
34
|
+
elsif !options.provider_ignores_state && (request.params["state"].to_s.empty? || request.params["state"] != session.delete("omniauth.state"))
|
35
|
+
fail!(:csrf_detected, CallbackError.new(:csrf_detected, "CSRF detected"))
|
36
|
+
else
|
37
|
+
self.access_token = build_access_token
|
38
|
+
self.access_token = access_token.refresh! if access_token.expired?
|
39
|
+
self.access_token.options[:mode] = :query
|
40
|
+
organizations = self.access_token.get('user/orgs', headers: { 'Accept' => 'application/vnd.github.v3' }).parsed
|
41
|
+
fail!(:user_denied, CallbackError.new(:user_denied, options['organization'])) unless organizations.map { |x| x['login'] }.include? options['organization']
|
42
|
+
super
|
43
|
+
end
|
44
|
+
rescue ::OAuth2::Error, CallbackError => e
|
45
|
+
fail!(:invalid_credentials, e)
|
46
|
+
rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
|
47
|
+
fail!(:timeout, e)
|
48
|
+
rescue ::SocketError => e
|
49
|
+
fail!(:failed_to_connect, e)
|
39
50
|
end
|
40
51
|
|
41
52
|
uid { raw_info['id'].to_s }
|
@@ -46,7 +57,6 @@ module OmniAuth
|
|
46
57
|
'email' => email,
|
47
58
|
'name' => raw_info['name'],
|
48
59
|
'image' => raw_info['avatar_url'],
|
49
|
-
'organizations' => organizations,
|
50
60
|
'urls' => {
|
51
61
|
'GitHub' => raw_info['html_url'],
|
52
62
|
'Blog' => raw_info['blog'],
|
@@ -26,10 +26,15 @@ describe OmniAuth::Strategies::GitHubOrganization do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
before(:each) do
|
29
|
+
OmniAuth.config.test_mode = true
|
29
30
|
allow(subject).to receive(:access_token).and_return(access_token)
|
30
31
|
allow(subject).to receive(:organizations).and_return(%w[example test])
|
31
32
|
end
|
32
33
|
|
34
|
+
after do
|
35
|
+
OmniAuth.config.test_mode = false
|
36
|
+
end
|
37
|
+
|
33
38
|
context 'client options' do
|
34
39
|
it 'should have correct site' do
|
35
40
|
expect(subject.options.client_options.site).to eq('https://api.github.com')
|
@@ -169,10 +174,4 @@ describe OmniAuth::Strategies::GitHubOrganization do
|
|
169
174
|
end
|
170
175
|
end
|
171
176
|
|
172
|
-
it 'is should return error if organization not match' do
|
173
|
-
allow(subject).to receive(:organizations).and_return(%w[not_match])
|
174
|
-
expect(subject).to receive(:fail!).with(:user_denied, anything)
|
175
|
-
subject.callback_phase
|
176
|
-
end
|
177
|
-
|
178
177
|
end
|