omniauth-zooniverse 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/omniauth/strategies/zooniverse.rb +21 -0
- data/lib/omniauth/zooniverse/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1cac300621628bea9ad6742c3bd60ba0749c9db
|
4
|
+
data.tar.gz: 53501e81a0b65a94c1ec1f4c00619ea2ee3c6a15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15c21e53693ec787a70d374091c1f9f1454a769ff05f7de0b01db62b77c9de14df106d55467955e04fa99b4f752f49fcfe11f80797fb2e45b5a62dba39ce9682
|
7
|
+
data.tar.gz: 3b4ad6ab24bec6dad8be0dfdb90a2c408a8e9a4e94c8683dd1a8fc8642bc5c7643b73f3b2e1a20f5acc73a4d61bf567b51f970b9e6b3f20d99c6522bc7da5f59
|
@@ -6,13 +6,33 @@ module OmniAuth
|
|
6
6
|
# change the class name and the :name option to match your application name
|
7
7
|
option :name, :zooniverse
|
8
8
|
|
9
|
+
BASE_SCOPES = %w[user public]
|
10
|
+
DEFAULT_SCOPE = "user,public"
|
11
|
+
|
9
12
|
option :client_options, {
|
10
13
|
:site => "https://panoptes-staging.zooniverse.org",
|
11
14
|
:authorize_url => "/oauth/authorize",
|
15
|
+
:scope => "user, public"
|
12
16
|
}
|
13
17
|
|
14
18
|
uid { raw_info["id"] }
|
15
19
|
|
20
|
+
option :authorize_options, [:user, :public]
|
21
|
+
|
22
|
+
|
23
|
+
def authorize_params
|
24
|
+
super.tap do |params|
|
25
|
+
options[:authorize_options].each do |k|
|
26
|
+
params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
|
27
|
+
end
|
28
|
+
|
29
|
+
raw_scope = params[:scope] || DEFAULT_SCOPE
|
30
|
+
scope_list = raw_scope.split(" ").map {|item| item.split(",")}.flatten
|
31
|
+
scope_list.map! { |s| s =~ /^https?:\/\// || BASE_SCOPES.include?(s) ? s : "#{BASE_SCOPE_URL}#{s}" }
|
32
|
+
params[:scope] = scope_list.join(" ")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
16
36
|
info do
|
17
37
|
{
|
18
38
|
:email => raw_info["email"],
|
@@ -20,6 +40,7 @@ module OmniAuth
|
|
20
40
|
}
|
21
41
|
end
|
22
42
|
|
43
|
+
|
23
44
|
def raw_info
|
24
45
|
raw = JSON.parse(access_token.get('/api/me', headers: {'Accept' => "application/vnd.api+json; version=1"}).body)
|
25
46
|
@raw_info ||= raw["users"][0]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-zooniverse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Lynn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|