omniauth-orcid 1.0.10 → 1.0.11
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.
- checksums.yaml +4 -4
- data/lib/omniauth/orcid/version.rb +1 -1
- data/lib/omniauth/strategies/orcid.rb +57 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cae9a23c2fe7fc6f767bb8aa638d37d1327a93fb
|
4
|
+
data.tar.gz: 77ee76452d7e695350a3ad3bf150363815dc125c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb95dc9ba8c53b0a589dacc8e1a65d378ba4c456b2896af6a48d45836828a7cc09eaffacdfd943fc8f94572ca3e83fda315dc1d6289fa806495cc6f59db9b493
|
7
|
+
data.tar.gz: 33da7a618b8598201711ca89ca6b601ed4beab6954bbb5e9e3dc7e3e82acd16f12c6dbae56f6879d3fc9a08d4c2a0184c6044cdfddbce96122321be05a88c395
|
@@ -7,15 +7,21 @@ module OmniAuth
|
|
7
7
|
class ORCID < OmniAuth::Strategies::OAuth2
|
8
8
|
|
9
9
|
DEFAULT_SCOPE = '/authenticate'
|
10
|
+
DEFAULT_NAMESPACE = '/authenticate'
|
10
11
|
API_VERSION = '1.2'
|
11
12
|
|
12
13
|
option :name, "orcid"
|
13
14
|
|
14
|
-
option :
|
15
|
+
option :member, false
|
16
|
+
option :sandbox, false
|
17
|
+
|
18
|
+
option :authorize_options, [:redirect_uri, :show_login]
|
15
19
|
|
16
20
|
option :client_options, {
|
17
|
-
site:
|
18
|
-
authorize_url:
|
21
|
+
site: site,
|
22
|
+
authorize_url: authorize_url,
|
23
|
+
token_url: token_url,
|
24
|
+
scope: scope
|
19
25
|
}
|
20
26
|
|
21
27
|
def authorize_params
|
@@ -31,6 +37,53 @@ module OmniAuth
|
|
31
37
|
end
|
32
38
|
end
|
33
39
|
|
40
|
+
# URLs for ORCID OAuth: http://members.orcid.org/api/tokens-through-3-legged-oauth-authorization
|
41
|
+
def namespace
|
42
|
+
if option[:member] && option[:sandbox]
|
43
|
+
'sandbox'
|
44
|
+
elsif option[:member]
|
45
|
+
'production'
|
46
|
+
elsif option[:sandbox]
|
47
|
+
'public_sandbox'
|
48
|
+
else
|
49
|
+
'public'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def site
|
54
|
+
case namespace
|
55
|
+
when 'sandbox' then 'http://api.sandbox.orcid.org'
|
56
|
+
when 'production' then 'http://api.orcid.org'
|
57
|
+
when 'public_sandbox' then 'http://pub.sandbox.orcid.org/'
|
58
|
+
when 'public' then 'http://pub.orcid.org'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def authorize_url
|
63
|
+
if option[:sandbox]
|
64
|
+
'https://sandbox.orcid.org/oauth/authorize'
|
65
|
+
else
|
66
|
+
'https://orcid.org/oauth/authorize'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def token_url
|
71
|
+
case namespace
|
72
|
+
when 'sandbox' then 'https://api.sandbox.orcid.org/oauth/token'
|
73
|
+
when 'production' then 'https://api.orcid.org/oauth/token'
|
74
|
+
when 'public_sandbox' then 'https://pub.sandbox.orcid.org/oauth/token'
|
75
|
+
when 'public' then 'https://pub.orcid.org/oauth/token'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def scope
|
80
|
+
if option[:member]
|
81
|
+
'/orcid-profile/read-limited /orcid-works/create'
|
82
|
+
else
|
83
|
+
'/authenticate'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
34
87
|
uid { access_token.params["orcid"] }
|
35
88
|
|
36
89
|
info do
|
@@ -44,7 +97,7 @@ module OmniAuth
|
|
44
97
|
end
|
45
98
|
|
46
99
|
def raw_info
|
47
|
-
@raw_info ||= access_token.get("
|
100
|
+
@raw_info ||= access_token.get("#{site}/v#{API_VERSION}/#{uid}/orcid-bio").parsed
|
48
101
|
end
|
49
102
|
end
|
50
103
|
end
|