omniauth-orcid 1.0.10 → 1.0.11

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
  SHA1:
3
- metadata.gz: 376112ae004c49e54e84390daeea37b92223cd6c
4
- data.tar.gz: 68ec2c3fadfda9b1706c751bb75cd3b2092150cd
3
+ metadata.gz: cae9a23c2fe7fc6f767bb8aa638d37d1327a93fb
4
+ data.tar.gz: 77ee76452d7e695350a3ad3bf150363815dc125c
5
5
  SHA512:
6
- metadata.gz: 1d89f7b21a36a9570e237433357464de73b82de59a509f2fb27f74b9fbd1656bb1ef0eef5ff3c1d35c4a6c82d8b29bc8605870a0acc24c1f73a66ed175606bbb
7
- data.tar.gz: 53ff86abe5974d7dfcb6566c4c01e2120ba99bfc8f856ef976be7a0f403e1b975d126d6dc536542a031e0e2e72d8f5e4e0c37d46298800dff2e8c7908b0b3f34
6
+ metadata.gz: bb95dc9ba8c53b0a589dacc8e1a65d378ba4c456b2896af6a48d45836828a7cc09eaffacdfd943fc8f94572ca3e83fda315dc1d6289fa806495cc6f59db9b493
7
+ data.tar.gz: 33da7a618b8598201711ca89ca6b601ed4beab6954bbb5e9e3dc7e3e82acd16f12c6dbae56f6879d3fc9a08d4c2a0184c6044cdfddbce96122321be05a88c395
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Orcid
3
- VERSION = "1.0.10"
3
+ VERSION = "1.0.11"
4
4
  end
5
5
  end
@@ -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 :authorize_options, [:scope, :redirect_uri, :show_login, :lang]
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: 'https://pub.orcid.org',
18
- authorize_url: 'https://orcid.org/oauth/authorize'
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("https://pub.orcid.org//v#{API_VERSION}/#{uid}/orcid-bio").parsed
100
+ @raw_info ||= access_token.get("#{site}/v#{API_VERSION}/#{uid}/orcid-bio").parsed
48
101
  end
49
102
  end
50
103
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-orcid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gudmundur A. Thorisson