omniauth-orcid 0.6 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0ede20a0539d30bcbe25b46fd7a809208b01ec57
4
+ data.tar.gz: c3258e160fd3f4716810e6ca021302bde2157706
5
+ SHA512:
6
+ metadata.gz: 06f5b7f7610aec0fc91254d5ed04e1a37c9ffabf6618dbd77354401c3d5d0d0340d3939772524b2acaaa820187604a61678d211149e681be8f365e1fda9f6eec
7
+ data.tar.gz: 8028010218d38d7ff715b5772e01a06de1d6acd7a6695c410a85ce0ff2e4b87940c9f87567247bc61a1743e2f80c29d2208a710c2c04774f5e641d11a373517d
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## v.1.0 (July 25, 2015)
2
+
3
+ [onmiauth-orcid 1.0](https://github.com/datacite/omniauth-orcid/releases/tag/v.1.0) was released on July 25, 2015 with the following changes:
4
+
5
+ * changed default scope to `authenticate`, and use the public API `https://pub.orcid.org` by default. These settings work for non-members.
6
+ * added `name` and `email` to the `info` hash returned by omniauth (`email` will be empty in almost all cases)
7
+ * cleaned up documentation in `README.md`
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (C) 2012, Gudmundur A. Thorisson
3
+ Copyright (C) 2012-2015, Gudmundur A. Thorisson
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # OmniAuth ORCID
2
2
 
3
- ORCID OAuth 2.0 Strategy for the wonderful [OmniAuth Ruby authentication framework](http://www.omniauth.org).
3
+ [![DOI](https://zenodo.org/badge/15088/datacite/omniauth-orcid.svg)](https://zenodo.org/badge/latestdoi/15088/datacite/omniauth-orcid)
4
+
5
+ ORCID OAuth 2.0 Strategy for the [OmniAuth Ruby authentication framework](http://www.omniauth.org).
4
6
 
5
7
  Provides basic support for connecting a client application to the [Open Researcher & Contributor ID registry service](http://orcid.org).
6
8
 
7
9
  Originally created for the [ORCID example client application in Rails](https://github.com/gthorisson/ORCID-example-client-app-rails), then turned into a gem.
8
10
 
9
11
 
10
-
11
12
  ## Installation
12
13
 
13
14
  The usual way with Bundler: add the following to your `Gemfile` to install the current version of the gem:
@@ -16,66 +17,63 @@ The usual way with Bundler: add the following to your `Gemfile` to install the c
16
17
  gem 'omniauth-orcid'
17
18
  ```
18
19
 
19
- Or, if you're impatient, you can install straight from GitHub
20
-
21
- ```ruby
22
- gem 'omniauth-orcid' , :git => 'git://github.com/gthorisson/omniauth-orcid.git'
23
- ```
24
-
25
20
  Then run `bundle install` to install into your environment.
26
21
 
27
22
  You can also install the gem system-wide in the usual way:
28
23
 
29
24
  ```bash
30
- [mummi@nfmac07]gem install omniauth-orcid
25
+ gem install omniauth-orcid
31
26
  ```
32
27
 
28
+
33
29
  ## Getting started
34
30
 
35
31
  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
32
 
37
-
38
33
  By default the module connects to the live ORCID service. In the very simplest usage, all you have to provide are your client app credentials ([see more here](http://support.orcid.org/knowledgebase/articles/116739)):
39
34
 
40
35
  ```ruby
41
36
  use OmniAuth::Builder do
42
- provider :orcid, ENV['ORCID_KEY'], ENV['ORCID_SECRET']
37
+ provider :orcid, ENV['ORCID_CLIENT_ID'], ENV['ORCID_CLIENT_SECRET']
43
38
  end
44
39
  ```
45
40
 
41
+ 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`:
42
+
43
+ * for non-members (the default): Register your client application in the `Developer Tools` section of your ORCID profile. Use `https://pub.orcid.org` as `site URL`
44
+ * for members (production): Register your client application [here](http://orcid.org/content/register-client-application). Use https://api.orcid.org as `site URL`
45
+ * for development (sandbox): Register your client application [here](https://orcid.org/content/register-client-application-sandbox). Use https://sandbox.orcid.org as `site URL`
46
+
46
47
  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:
47
48
 
48
49
  ```json
49
50
  {
50
- provider: "orcid",
51
- uid: "0000-0003-2012-0010",
52
- info: {
53
- name: null
54
- },
55
- credentials: {
56
- token: "e82938fa-a287-42cf-a2ce-f48ef68c9a35",
57
- refresh_token: "f94c58dd-b452-44f4-8863-0bf8486a0071",
58
- expires_at: 1979903874,
59
- expires: true
60
- },
61
- extra: { }
51
+ "provider": "orcid",
52
+ "uid": "0000-0003-2012-0010",
53
+ "info": {
54
+ "name": "John Smith",
55
+ "email": null
56
+ },
57
+ "credentials": {
58
+ "token": "e82938fa-a287-42cf-a2ce-f48ef68c9a35",
59
+ "refresh_token": "f94c58dd-b452-44f4-8863-0bf8486a0071",
60
+ "expires_at": 1979903874,
61
+ "expires": true
62
+ },
63
+ "extra": {
64
+ }
62
65
  }
63
66
  ```
64
67
 
65
- You have to implement a callback handler to grab at least the `uid` from the hash and (typically) save it in a session. This effectively provides basic "Log in with your ORCiD" functionality.
66
-
67
- Most likely, with the token in hand, you'll want to do something more sophisticated with the API, like retrieving profile data and do something cool with it. See the API guide for more details:
68
-
69
- http://support.orcid.org/knowledgebase/articles/116874-orcid-api-guide
70
-
68
+ You have to implement a callback handler to grab at least the `uid` from the hash and (typically) save it in a session. This effectively provides basic **Log in with your ORCID** functionality.
71
69
 
70
+ Most likely, with the token in hand, you'll want to do something more sophisticated with the API, like retrieving profile data and do something cool with it. See the [API documentation](http://members.orcid.org/api/api-calls) for more details:
72
71
 
73
72
  Here's how to get going with a couple of popular Rack-based frameworks:
74
73
 
75
74
 
76
75
  ### Sinatra
77
76
 
78
-
79
77
  Configure the strategy and implement a callback routine in your app:
80
78
 
81
79
  ```ruby
@@ -85,7 +83,7 @@ require 'omniauth-orcid'
85
83
  enable :sessions
86
84
 
87
85
  use OmniAuth::Builder do
88
- provider :orcid, ENV['ORCID_KEY'], ENV['ORCID_SECRET']
86
+ provider :orcid, ENV['ORCID_CLIENT_ID'], ENV['ORCID_CLIENT_SECRET']
89
87
  end
90
88
  ...
91
89
  get '/auth/orcid/callback' do
@@ -94,7 +92,7 @@ get '/auth/orcid/callback' do
94
92
  end
95
93
 
96
94
  get '/' do
97
-
95
+
98
96
  if session[:omniauth]
99
97
  @orcid = session[:omniauth][:uid]
100
98
  end
@@ -114,7 +112,7 @@ ruby demo.rb
114
112
  ```
115
113
 
116
114
 
117
- ### Rails
115
+ ### Rails
118
116
 
119
117
 
120
118
  Add this to `config/initializers/omniauth.rb` to configure the strategy:
@@ -123,7 +121,7 @@ Add this to `config/initializers/omniauth.rb` to configure the strategy:
123
121
  require 'omniauth-orcid'
124
122
 
125
123
  Rails.application.config.middleware.use OmniAuth::Builder do
126
- provider :orcid, ENV['ORCID_KEY'], ENV['ORCID_SECRET']
124
+ provider :orcid, ENV['ORCID_CLIENT_ID'], ENV['ORCID_CLIENT_SECRET']
127
125
  end
128
126
  ```
129
127
 
@@ -151,68 +149,35 @@ class AuthenticationsController < ApplicationController
151
149
 
152
150
  ## Configuration
153
151
 
154
- You can also grab parameters from a config file (recommended) and pass
155
- to the strategy, along with other options specific to your app. The OAuth scope or
152
+ 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. The OAuth scope or
156
153
  scopes in particular frequently need to be customized. Here's an example from the bundled Sinatra app in `demo.rb`:
157
154
 
158
- *UPDATE The [omniauth-oauth2 gem](https://github.com/intridea/omniauth-oauth2) was recently been updated to process options slightly differently. The `:scope` string must now be passed in via `:authorize_params`, see below*
159
-
160
155
  ```ruby
161
- config_file 'config.yml'
162
156
  use OmniAuth::Builder do
163
- provider :orcid, settings.client_id, settings.client_secret,
164
- :authorize_params => {
165
- :scope => '/orcid-profile/read-limited'
157
+ provider :orcid, ENV['ORCID_CLIENT_ID'], ENV['ORCID_CLIENT_SECRET'],
158
+ authorize_params: {
159
+ scope: '/orcid-profile/read-limited'
166
160
  },
167
- :client_options => {
168
- :site => settings.site,
169
- :authorize_url => settings.authorize_url,
170
- :token_url => settings.token_url
161
+ client_options: {
162
+ site: ENV['ORCID_URL'],
163
+ authorize_url: "#{ENV['ORCID_URL']}/oauth/authorize",
164
+ token_url: "#{ENV['ORCID_URL']}/oauth/token",
171
165
  }
172
166
  end
173
167
 
174
168
  ```
169
+ Where `ENV['ORCID_CLIENT_ID']` and `ENV['ORCID_CLIENT_SECRET']` are provided by ORCID when registering the application, and `ENV['ORCID_URL']` depends on the API you are using (see above).
175
170
 
176
- Different sets of params from `config.yml` are used for production environment (points to live ORCID service) vs. development environment (points to ORCID sandbox service).
177
-
178
- You can do something similar with in Rails with the same config file, or something . See a working example here: https://github.com/gthorisson/ORCID-example-client-app-rails
179
-
180
-
181
-
182
- ## More information
183
171
 
184
- ORCID Open Source Project - https://github.com/ORCID/ORCID-Source
185
- Developer Wiki - https://github.com/ORCID/ORCID-Source/wiki
186
- Technical community - http://orcid.org/about/community/orcid-technical-community
172
+ ## More information
187
173
 
174
+ * [ORCID Open Source Project](https://github.com/ORCID/ORCID-Source)
175
+ * [Developer Wiki](https://github.com/ORCID/ORCID-Source/wiki)
176
+ * [Technical community](http://orcid.org/about/community/orcid-technical-community)
188
177
 
189
178
 
190
179
  ## License
191
180
 
192
- The MIT License (OSI approved, see more at http://www.opensource.org/licenses/mit-license.php)
193
-
194
- =============================================================================
195
-
196
- Copyright (C) 2012 by Gudmundur A. Thorisson
197
-
198
- Permission is hereby granted, free of charge, to any person obtaining a copy
199
- of this software and associated documentation files (the "Software"), to deal
200
- in the Software without restriction, including without limitation the rights
201
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
202
- copies of the Software, and to permit persons to whom the Software is
203
- furnished to do so, subject to the following conditions:
204
-
205
- The above copyright notice and this permission notice shall be included in
206
- all copies or substantial portions of the Software.
207
-
208
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
209
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
210
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
211
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
212
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
213
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
214
- THE SOFTWARE.
215
-
216
- =============================================================================
181
+ The [MIT License](license.txt) (OSI approved, see more at http://www.opensource.org/licenses/mit-license.php)
217
182
 
218
183
  ![Open Source Initiative Approved License](http://www.opensource.org/trademarks/opensource/web/opensource-110x95.jpg)
data/demo.rb CHANGED
@@ -4,7 +4,6 @@
4
4
 
5
5
  require 'rubygems'
6
6
  require 'sinatra'
7
- require 'sinatra/config_file'
8
7
  require 'haml'
9
8
  require 'omniauth-orcid'
10
9
  require 'oauth2'
@@ -13,22 +12,24 @@ require 'json'
13
12
  enable :sessions
14
13
  use Rack::Session::Cookie
15
14
 
16
- config_file 'config.yml'
17
15
  if development?
18
16
  puts "Sinatra running in development mode"
19
17
  elsif production?
20
- puts "Sinatra running in production mode"
18
+ puts "Sinatra running in production mode"
21
19
  end
22
20
 
23
21
  puts "Connecting to ORCID API at " + settings.site + " as client app #{settings.client_id}"
24
22
 
25
23
  # Configure the ORCID strategy
26
24
  use OmniAuth::Builder do
27
- provider :orcid, settings.client_id, settings.client_secret,
28
- :client_options => {
29
- :site => settings.site,
30
- :authorize_url => settings.authorize_url,
31
- :token_url => settings.token_url
25
+ provider :orcid, ENV['ORCID_CLIENT_ID'], ENV['ORCID_CLIENT_SECRET'],
26
+ authorize_params: {
27
+ scope: '/orcid-profile/read-limited'
28
+ },
29
+ client_options: {
30
+ site: ENV['ORCID_URL'],
31
+ authorize_url: "#{ENV['ORCID_URL']}/oauth/authorize",
32
+ token_url: "#{ENV['ORCID_URL']}/oauth/token",
32
33
  }
33
34
  end
34
35
 
@@ -38,7 +39,7 @@ end
38
39
  get '/' do
39
40
 
40
41
  @orcid = ''
41
-
42
+
42
43
  if session[:omniauth]
43
44
  @orcid = session[:omniauth][:uid]
44
45
  end
@@ -1,2 +1 @@
1
- require "omniauth-orcid/version"
2
- require 'omniauth/strategies/orcid'
1
+ require 'omniauth/orcid'
@@ -0,0 +1,2 @@
1
+ require "omniauth/orcid/version"
2
+ require 'omniauth/strategies/orcid'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Orcid
3
+ VERSION = "1.0"
4
+ end
5
+ end
@@ -6,27 +6,29 @@ module OmniAuth
6
6
  module Strategies
7
7
  class ORCID < OmniAuth::Strategies::OAuth2
8
8
 
9
- DEFAULT_SCOPE = '/orcid-bio/read-limited'
9
+ DEFAULT_SCOPE = '/authenticate'
10
10
 
11
11
  option :client_options, {
12
12
  :site => 'http://api.orcid.org',
13
13
  :authorize_url => 'http://orcid.org/oauth/authorize',
14
- :token_url => 'https://api.orcid.org/oauth/token',
15
- :scope => '/orcid-profile/read-limited',
14
+ :token_url => 'https://pub.orcid.org/oauth/token',
15
+ :scope => '/authenticate',
16
16
  :response_type => 'code',
17
17
  :mode => :header
18
18
  }
19
19
 
20
-
21
20
  # Pull out unique ID for the user in the external system
22
- uid { access_token.params["orcid"] }
21
+ uid { access_token.params["orcid"] }
23
22
 
24
- info do{} end
23
+ info do
24
+ { name: access_token.params["name"],
25
+ email: access_token.params["email"] }
26
+ end
25
27
 
26
28
  # Customize the parameters passed to the OAuth provider in the authorization phase
27
29
  def authorize_params
28
-
29
- # Trick shamelessly borrowed from the omniauth-facebook gem!
30
+
31
+ # Trick shamelessly borrowed from the omniauth-facebook gem!
30
32
  super.tap do |params|
31
33
  %w[scope].each { |v| params[v.to_sym] = request.params[v] if request.params[v] }
32
34
  params[:scope] ||= DEFAULT_SCOPE # ensure that we're always request *some* default scope
@@ -1,18 +1,19 @@
1
1
  require "date"
2
- require File.expand_path("../lib/omniauth-orcid/version", __FILE__)
2
+ require File.expand_path("../lib/omniauth/orcid/version", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.authors = ["Gudmundur A. Thorisson"]
6
- s.email = %q{gthorisson@gmail.com}
5
+ s.authors = ["Gudmundur A. Thorisson", "Martin Fenner"]
6
+ s.email = ["gthorisson@gmail.com", "martin.fenner@datacite.org"]
7
7
  s.name = "omniauth-orcid"
8
- s.homepage = %q{https://github.com/gthorisson/omniauth-orcid}
8
+ s.homepage = %q{https://github.com/datacite/omniauth-orcid}
9
9
  s.summary = %q{ORCID OAuth 2.0 Strategy for OmniAuth 1.0}
10
10
  s.date = Date.today
11
11
  s.description = %q{Enables third-party client apps to connect to the ORCID API and access/update protected profile data }
12
- s.files = Dir["{lib}/**/*.rb", "bin/*", "LICENSE.txt", "*.md", "Rakefile", "Gemfile", "demo.rb", "config.yml", "omniauth-orcid.gemspec"]
12
+ s.files = Dir["{lib}/**/*.rb", "bin/*", "LICENSE.txt", "*.md", "Rakefile", "Gemfile", "demo.rb", "omniauth-orcid.gemspec"]
13
13
  s.require_paths = ["lib"]
14
- s.version = OmniAuth::ORCID::VERSION
14
+ s.version = OmniAuth::Orcid::VERSION
15
15
  s.extra_rdoc_files = ["README.md"]
16
+ s.license = 'MIT'
16
17
 
17
18
 
18
19
  # Declary dependencies here, rather than in the Gemfile
metadata CHANGED
@@ -1,88 +1,87 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-orcid
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
5
- prerelease:
4
+ version: '1.0'
6
5
  platform: ruby
7
6
  authors:
8
7
  - Gudmundur A. Thorisson
8
+ - Martin Fenner
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-22 00:00:00.000000000 Z
12
+ date: 2015-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth
16
16
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
17
  requirements:
19
- - - ~>
18
+ - - "~>"
20
19
  - !ruby/object:Gem::Version
21
20
  version: '1.0'
22
21
  type: :runtime
23
22
  prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
- - - ~>
25
+ - - "~>"
28
26
  - !ruby/object:Gem::Version
29
27
  version: '1.0'
30
28
  - !ruby/object:Gem::Dependency
31
29
  name: omniauth-oauth2
32
30
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
31
  requirements:
35
- - - ~>
32
+ - - "~>"
36
33
  - !ruby/object:Gem::Version
37
34
  version: '1.1'
38
35
  type: :runtime
39
36
  prerelease: false
40
37
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
38
  requirements:
43
- - - ~>
39
+ - - "~>"
44
40
  - !ruby/object:Gem::Version
45
41
  version: '1.1'
46
- description: ! 'Enables third-party client apps to connect to the ORCID API and access/update
42
+ description: 'Enables third-party client apps to connect to the ORCID API and access/update
47
43
  protected profile data '
48
- email: gthorisson@gmail.com
44
+ email:
45
+ - gthorisson@gmail.com
46
+ - martin.fenner@datacite.org
49
47
  executables: []
50
48
  extensions: []
51
49
  extra_rdoc_files:
52
50
  - README.md
53
51
  files:
54
- - lib/omniauth/strategies/orcid.rb
55
- - lib/omniauth-orcid/version.rb
56
- - lib/omniauth-orcid.rb
52
+ - CHANGELOG.md
53
+ - Gemfile
57
54
  - LICENSE.txt
58
55
  - README.md
59
56
  - Rakefile
60
- - Gemfile
61
57
  - demo.rb
62
- - config.yml
58
+ - lib/omniauth-orcid.rb
59
+ - lib/omniauth/orcid.rb
60
+ - lib/omniauth/orcid/version.rb
61
+ - lib/omniauth/strategies/orcid.rb
63
62
  - omniauth-orcid.gemspec
64
- homepage: https://github.com/gthorisson/omniauth-orcid
65
- licenses: []
63
+ homepage: https://github.com/datacite/omniauth-orcid
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
66
67
  post_install_message:
67
68
  rdoc_options: []
68
69
  require_paths:
69
70
  - lib
70
71
  required_ruby_version: !ruby/object:Gem::Requirement
71
- none: false
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  required_rubygems_version: !ruby/object:Gem::Requirement
77
- none: false
78
77
  requirements:
79
- - - ! '>='
78
+ - - ">="
80
79
  - !ruby/object:Gem::Version
81
80
  version: '0'
82
81
  requirements: []
83
82
  rubyforge_project:
84
- rubygems_version: 1.8.25
83
+ rubygems_version: 2.4.5
85
84
  signing_key:
86
- specification_version: 3
85
+ specification_version: 4
87
86
  summary: ORCID OAuth 2.0 Strategy for OmniAuth 1.0
88
87
  test_files: []
data/config.yml DELETED
@@ -1,15 +0,0 @@
1
- # Default endpoint URLs for the ORCID OAuth API
2
-
3
- production:
4
- site: https://api.orcid.org
5
- authorize_url: https://orcid.org/oauth/authorize
6
- token_url: https://api.orcid.org/oauth/token
7
- client_id:
8
- client_secret:
9
-
10
- development:
11
- site: http://api.sandbox-1.orcid.org
12
- authorize_url: http://sandbox-1.orcid.org/oauth/authorize
13
- token_url: http://api.sandbox-1.orcid.org/oauth/token
14
- client_id: 0000-0002-8831-0104
15
- client_secret: 7fb56071-0c68-4d42-af00-5a52804ae645
@@ -1,5 +0,0 @@
1
- module OmniAuth
2
- module ORCID
3
- VERSION = "0.6"
4
- end
5
- end