omniauth-orcid 1.0.14 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -27
- data/lib/omniauth/orcid/version.rb +1 -1
- data/spec/omniauth/strategies/orcid_spec.rb +57 -0
- data/spec/spec_helper.rb +16 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd6c27587a6e2d2720b024c7a31f5c6b76fc806a
|
4
|
+
data.tar.gz: a1bb1aa9e3bc2968318ea4ecdb759ca639a0078c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9e579ab4c49826b467ace7e6e423efa849c3cd7007667915dae2bea38615b9793b1ced1303a96db45b2babbd880589368326a85cbb09ccdd990e9f09922c511
|
7
|
+
data.tar.gz: 3d56ebbc1bb06f974b6a956f522df681125041996a10e6a1f5bef0710f839b930e94fc0a0de32abec05e3d4b4581406a9472430d7cea3c0874fac5d984a63a23
|
data/README.md
CHANGED
@@ -34,7 +34,13 @@ gem install omniauth-orcid
|
|
34
34
|
|
35
35
|
Like other OmniAuth strategies, `OmniAuth::Strategies::ORCID` is a piece of Rack middleware. Please read the OmniAuth documentation for detailed instructions: https://github.com/intridea/omniauth.
|
36
36
|
|
37
|
-
|
37
|
+
There are three ways to register a client application and obtain client app credentials (`client_id` and `client_secret`) as well as a `site URL`:
|
38
|
+
|
39
|
+
* for non-members (the default): Register your client application in the `Developer Tools` section of your ORCID profile.
|
40
|
+
* for members (production): Register your client application [here](http://orcid.org/content/register-client-application).
|
41
|
+
* for development (sandbox): Register your client application [here](https://orcid.org/content/register-client-application-sandbox).
|
42
|
+
|
43
|
+
By default the module connects to the live ORCID service for non-members. All you have to provide are your client app credentials ([see more here](http://support.orcid.org/knowledgebase/articles/116739)):
|
38
44
|
|
39
45
|
```ruby
|
40
46
|
use OmniAuth::Builder do
|
@@ -42,11 +48,13 @@ use OmniAuth::Builder do
|
|
42
48
|
end
|
43
49
|
```
|
44
50
|
|
45
|
-
|
51
|
+
To connect to the member API and/or sandbox, use the `member` and/or `sandbox` options, e.g.
|
46
52
|
|
47
|
-
|
48
|
-
|
49
|
-
|
53
|
+
```ruby
|
54
|
+
use OmniAuth::Builder do
|
55
|
+
provider :orcid, ENV['ORCID_CLIENT_ID'], ENV['ORCID_CLIENT_SECRET'], member: true, sandbox: true
|
56
|
+
end
|
57
|
+
```
|
50
58
|
|
51
59
|
OmniAuth takes care of the OAuth external-authentication handshake or "dance". All that the gem does is grab the identifier and tokens at the end of the dance and stick it into the OmniAuth hash which is subsequently accessible to your app via `request.env['omniauth.auth']` (see [AuthHashSchema](https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema)). The hash looks something like this:
|
52
60
|
|
@@ -150,28 +158,6 @@ class AuthenticationsController < ApplicationController
|
|
150
158
|
end
|
151
159
|
```
|
152
160
|
|
153
|
-
|
154
|
-
## Configuration
|
155
|
-
|
156
|
-
You can also grab parameters from a environment variables (e.g. using the [dotenv](https://github.com/bkeepers/dotenv) gem) and pass to the strategy, along with other options specific to your app. Here's an example from the bundled Sinatra app in `demo.rb`:
|
157
|
-
|
158
|
-
```ruby
|
159
|
-
use OmniAuth::Builder do
|
160
|
-
provider :orcid, ENV['ORCID_CLIENT_ID'], ENV['ORCID_CLIENT_SECRET'],
|
161
|
-
authorize_params: {
|
162
|
-
scope: '/orcid-profile/read-limited'
|
163
|
-
},
|
164
|
-
client_options: {
|
165
|
-
site: ENV['API_ORCID_URL'],
|
166
|
-
authorize_url: "#{ENV['ORCID_URL']}/oauth/authorize",
|
167
|
-
token_url: "#{ENV['API_ORCID_URL']}/oauth/token",
|
168
|
-
}
|
169
|
-
end
|
170
|
-
|
171
|
-
```
|
172
|
-
Where `ENV['ORCID_CLIENT_ID']` and `ENV['ORCID_CLIENT_SECRET']` are provided by ORCID when registering the application, and `ENV['API_ORCID_URL']` depends on the API you are using (see above).
|
173
|
-
|
174
|
-
|
175
161
|
## More information
|
176
162
|
|
177
163
|
* [ORCID Open Source Project](https://github.com/ORCID/ORCID-Source)
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::ORCID do
|
4
|
+
subject { OmniAuth::Strategies::ORCID.new({}) }
|
5
|
+
|
6
|
+
describe 'client options' do
|
7
|
+
it 'should have correct name' do
|
8
|
+
expect(subject.options.name).to eq('orcid')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should have correct site' do
|
12
|
+
expect(subject.options.client_options.site).to eq('http://pub.orcid.org')
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have correct authorize url' do
|
16
|
+
expect(subject.options.client_options.authorize_url).to eq('https://orcid.org/oauth/authorize')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should have correct scope' do
|
20
|
+
expect(subject.options.client_options.scope).to eq('/authenticate')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'uid' do
|
25
|
+
before do
|
26
|
+
allow(subject).to receive(:raw_info).and_return(raw_info_hash)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should return the uid' do
|
30
|
+
expect(subject.uid).to eq(raw_info_hash['orcid'])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'info' do
|
35
|
+
before do
|
36
|
+
allow(subject).to receive(:raw_info).and_return(raw_info_hash)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should returns the name' do
|
40
|
+
expect(subject.info[:name]).to eq(raw_info_hash['name'])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def raw_info_hash
|
48
|
+
{
|
49
|
+
"name" => "Josiah Carberry",
|
50
|
+
"access_token" => "e6394ba4-34bd-43a8-8c3d-a99752fe0bf9",
|
51
|
+
"expires_in" => 631138518,
|
52
|
+
"token_type" => "bearer",
|
53
|
+
"orcid" => "0000-0002-1825-0097",
|
54
|
+
"scope" => "/authenticate",
|
55
|
+
"refresh_token" => "c07df09f-2015-4b88-a387-61b7e2a89fb0"
|
56
|
+
}
|
57
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'rspec'
|
4
|
+
require 'rack/test'
|
5
|
+
require 'webmock/rspec'
|
6
|
+
require 'omniauth'
|
7
|
+
require 'omniauth-orcid'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.include WebMock::API
|
11
|
+
config.include Rack::Test::Methods
|
12
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
13
|
+
config.expect_with :rspec do |c|
|
14
|
+
c.syntax = :expect
|
15
|
+
end
|
16
|
+
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.
|
4
|
+
version: 1.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gudmundur A. Thorisson
|
@@ -61,6 +61,8 @@ files:
|
|
61
61
|
- lib/omniauth/orcid/version.rb
|
62
62
|
- lib/omniauth/strategies/orcid.rb
|
63
63
|
- omniauth-orcid.gemspec
|
64
|
+
- spec/omniauth/strategies/orcid_spec.rb
|
65
|
+
- spec/spec_helper.rb
|
64
66
|
homepage: https://github.com/datacite/omniauth-orcid
|
65
67
|
licenses:
|
66
68
|
- MIT
|
@@ -85,4 +87,6 @@ rubygems_version: 2.4.5.1
|
|
85
87
|
signing_key:
|
86
88
|
specification_version: 4
|
87
89
|
summary: ORCID OAuth 2.0 Strategy for OmniAuth 1.0
|
88
|
-
test_files:
|
90
|
+
test_files:
|
91
|
+
- spec/omniauth/strategies/orcid_spec.rb
|
92
|
+
- spec/spec_helper.rb
|