omniauth-doximity_oauth2 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d0528585c187c9b4bf252edf0ef753021451e956
4
+ data.tar.gz: 661b8bb8853f7be199138475c3693f36b5a656a4
5
+ SHA512:
6
+ metadata.gz: bb698f6c5036c715ada2b78ff84a589d917f10ab1505a3047693f672007940e15328494ea19917c0bbb130e3c922c40ea33f2a96fafc84e73eb96a29059dd21f
7
+ data.tar.gz: ed7a1054bd1a7efccb5b68f3bc7830de24040c537a129962c797342cb0ad59cd777d09f083442121e04b5ceaf4b7e6cc27abe627db5d18bbf0c2ac99f875e841
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-doximity_oauth2.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Aaron Kuehler
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # Omniauth::DoximityOauth2
2
+
3
+ A [Doximity](http://www.doximity.com) OAuth2 Strategy for [OmniAuth](https://github.com/intridea/omniauth)
4
+
5
+ Doximity API Information at http://developer.doximity.com/oauth.html
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'omniauth-doximity_oauth2'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-doximity_oauth2
20
+
21
+ ## Usage
22
+
23
+ 1. Request OAuth Application Credentials from the Doximity team: http://developer.doximity.com/preferred/
24
+ 1. Enable the Strategy
25
+ ```ruby
26
+ # Rails
27
+ Rails.application.config.middleware.use OmniAuth::Builder do
28
+ provider :doximity,
29
+ ENV['DOXIMITY_OAUTH_CLIENT_ID'],
30
+ ENV['DOXIMITY_OAUTH_CLIENT_SECRET']
31
+ end
32
+ ```
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it ( https://github.com/indiebrain/omniauth-doximity_oauth2/fork )
37
+ 1. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 1. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 1. Push to the branch (`git push origin my-new-feature`)
40
+ 1. Create a new Pull Request
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,9 @@
1
+ require 'omniauth-oauth2'
2
+ require "omniauth/doximity_oauth2/version"
3
+ require 'omniauth/strategies/doximity'
4
+
5
+ module Omniauth
6
+ module DoximityOauth2
7
+
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module DoximityOauth2
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,56 @@
1
+ module OmniAuth
2
+ module Strategies
3
+ class Doximity < OmniAuth::Strategies::OAuth2
4
+
5
+ option :name, 'doximity'
6
+ option :client_options, {
7
+ site: 'http://www.doximity.com',
8
+ authorize_url: 'https://www.doximity.com/oauth/authorize',
9
+ token_url: 'https://www.doximity.com/oauth/token'
10
+ }
11
+
12
+ option :authorize_params, {
13
+ type: 'login',
14
+ response_type: 'code',
15
+ scope: 'basic'
16
+ }
17
+
18
+ def user_profile
19
+ @user_profile ||= access_token.
20
+ get('/api/v1/users/current').
21
+ parsed
22
+ end
23
+
24
+ uid do
25
+ user_profile['id']
26
+ end
27
+
28
+ info do
29
+ {
30
+ 'name' => user_profile['full_name'],
31
+ 'email' => user_profile['email'],
32
+ 'first_name' => user_profile['first_name'],
33
+ 'last_name' => user_profile['last_name'],
34
+ 'description' => user_profile['description'],
35
+ 'image' => user_profile['profile_photo'],
36
+ 'location' => [
37
+ user_profile['address_1'],
38
+ user_profile['address_2'],
39
+ user_profile['city'],
40
+ user_profile['state'],
41
+ user_profile['zip'],
42
+ user_profile['country']
43
+ ].reject(&:nil?).join(' ')
44
+ }
45
+ end
46
+
47
+ extra do
48
+ {
49
+ 'raw_info' => user_profile
50
+ }
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ OmniAuth.config.add_camelization 'doximity', 'Doximity'
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/doximity_oauth2/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-doximity_oauth2"
8
+ spec.version = Omniauth::DoximityOauth2::VERSION
9
+ spec.authors = ["Aaron Kuehler"]
10
+ spec.email = ["aaron.kuehler@gmail.com"]
11
+ spec.summary = %q{A Doximity OAuth2 Strategy for OmniAuth}
12
+ spec.description = %q{An OmniAuth strategy implementation for obtaining access to the Doximity API; API documentation at: http://developer.doximity.com/}
13
+ spec.homepage = "https://github.com/indiebrain/omniauth-doximity_oauth2"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency 'rake', '~> 10.3'
23
+ spec.add_development_dependency 'rspec', '~> 3.0'
24
+ spec.add_development_dependency 'simplecov', '~> 0.8'
25
+
26
+ spec.add_runtime_dependency 'omniauth', '~> 1.0'
27
+ spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.1'
28
+ end
@@ -0,0 +1,323 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Doximity do
4
+
5
+ it 'provides the Doximity camelization' do
6
+ expect(
7
+ OmniAuth::Utils.camelize('doximity')
8
+ ).to eq(
9
+ 'Doximity'
10
+ )
11
+ end
12
+
13
+ subject(:strategy) do
14
+ OmniAuth::Strategies::Doximity.new(nil)
15
+ end
16
+
17
+ describe '#name' do
18
+ it 'is doximity' do
19
+ expect(
20
+ strategy.name
21
+ ).to eq(
22
+ 'doximity'
23
+ )
24
+ end
25
+ end
26
+
27
+ describe '#client' do
28
+
29
+ let(:client) do
30
+ strategy.client
31
+ end
32
+
33
+ describe '#site' do
34
+ it 'is the URL to the Doximity Site' do
35
+ expect(
36
+ client.site
37
+ ).to eq(
38
+ 'http://www.doximity.com'
39
+ )
40
+ end
41
+ end
42
+
43
+ describe '#authorize_url' do
44
+ it 'is the Doximity OAuth 2.0 authorization url' do
45
+ expect(
46
+ client.authorize_url
47
+ ).to eq(
48
+ 'https://www.doximity.com/oauth/authorize'
49
+ )
50
+ end
51
+ end
52
+
53
+ describe '#token_url' do
54
+ it 'is the Doximity User Access Token resource URL' do
55
+ expect(
56
+ client.token_url
57
+ ).to eq(
58
+ 'https://www.doximity.com/oauth/token'
59
+ )
60
+ end
61
+ end
62
+ end
63
+
64
+ describe '#callback_path' do
65
+ it 'calls back to /auth/doximity/callback' do
66
+ expect(
67
+ strategy.callback_path
68
+ ).to eq(
69
+ '/auth/doximity/callback'
70
+ )
71
+ end
72
+ end
73
+
74
+ describe '#user_profile' do
75
+ it 'is a parsed user profile response' do
76
+ user_profile = {'id' => 'user_profile_id'}
77
+
78
+ access_token = double(::OAuth2::AccessToken)
79
+ response = double('response',
80
+ parsed: user_profile)
81
+
82
+ expect(
83
+ access_token
84
+ ).to receive(:get).
85
+ with('/api/v1/users/current').
86
+ and_return(response)
87
+
88
+ allow(
89
+ strategy
90
+ ).to receive(:access_token).
91
+ and_return(access_token)
92
+
93
+ expect(
94
+ strategy.user_profile
95
+ ).to eq(
96
+ user_profile
97
+ )
98
+ end
99
+ end
100
+
101
+ describe '#uid' do
102
+ it 'is user_profile id' do
103
+ user_profile_id = 'user_profile_id'
104
+
105
+ allow(
106
+ strategy
107
+ ).to receive(:user_profile).
108
+ and_return({
109
+ 'id' => user_profile_id
110
+ })
111
+
112
+ expect(
113
+ strategy.uid
114
+ ).to eq(
115
+ user_profile_id
116
+ )
117
+ end
118
+ end
119
+
120
+ describe '#info' do
121
+ describe "['name']" do
122
+ it 'is the user_profile full_name' do
123
+ user_profile_name = 'user_profile_name'
124
+
125
+ allow(strategy).
126
+ to receive(:user_profile).
127
+ and_return({
128
+ 'full_name' => user_profile_name
129
+ })
130
+
131
+ expect(
132
+ strategy.info['name']
133
+ ).to eq(
134
+ user_profile_name
135
+ )
136
+ end
137
+ end
138
+
139
+ describe "['email']" do
140
+ it 'is the user_profile email' do
141
+ user_profile_email = 'user_profile_email'
142
+
143
+ allow(strategy).
144
+ to receive(:user_profile).
145
+ and_return({
146
+ 'email' => user_profile_email
147
+ })
148
+
149
+ expect(
150
+ strategy.info['email']
151
+ ).to eq(
152
+ user_profile_email
153
+ )
154
+ end
155
+ end
156
+
157
+ describe "['first_name']" do
158
+ it 'is the user_profile first_name' do
159
+ user_profile_first_name = 'user_profile_first_name'
160
+ allow(strategy).
161
+ to receive(:user_profile).
162
+ and_return({
163
+ 'first_name' => user_profile_first_name
164
+ })
165
+
166
+ expect(
167
+ strategy.info['first_name']
168
+ ).to eq(
169
+ user_profile_first_name
170
+ )
171
+ end
172
+ end
173
+
174
+ describe "['last_name']" do
175
+ it 'is the user_profile last_name' do
176
+ user_profile_last_name = 'user_profile_last_name'
177
+
178
+ allow(strategy).
179
+ to receive(:user_profile).
180
+ and_return({
181
+ 'last_name' => user_profile_last_name
182
+ })
183
+
184
+ expect(
185
+ strategy.info['last_name']
186
+ ).to eq(
187
+ user_profile_last_name
188
+ )
189
+ end
190
+ end
191
+
192
+ describe "['description']" do
193
+ it 'is the user_profile description' do
194
+ user_profile_description = 'user_profile_description'
195
+ allow(strategy).
196
+ to receive(:user_profile).
197
+ and_return({
198
+ 'description' => user_profile_description
199
+ })
200
+
201
+ expect(
202
+ strategy.info['description']
203
+ ).to eq(
204
+ user_profile_description
205
+ )
206
+ end
207
+ end
208
+
209
+ describe "['image']" do
210
+ it 'is the user_profile profile_photo' do
211
+ user_profile_profile_photo = 'user_profile_profile_photo'
212
+ allow(strategy).
213
+ to receive(:user_profile).
214
+ and_return({
215
+ 'profile_photo' => user_profile_profile_photo
216
+ })
217
+
218
+ expect(
219
+ strategy.info['image']
220
+ ).to eq(
221
+ user_profile_profile_photo
222
+ )
223
+ end
224
+ end
225
+
226
+ describe "['location']" do
227
+ it 'is the location described by the user_profile' do
228
+ user_profile_address_1 = 'user_profile_address_1'
229
+ user_profile_address_2 = 'user_profile_address_2'
230
+ user_profile_city = 'user_profile_city'
231
+ user_profile_state = 'user_profile_state'
232
+ user_profile_zip = 'user_profile_zip'
233
+ user_profile_country = 'user_profile_country'
234
+
235
+ allow(strategy).
236
+ to receive(:user_profile).
237
+ and_return({
238
+ 'address_1' => user_profile_address_1,
239
+ 'address_2' => user_profile_address_2,
240
+ 'city' => user_profile_city,
241
+ 'state' => user_profile_state,
242
+ 'zip' => user_profile_zip,
243
+ 'country' => user_profile_country
244
+ })
245
+
246
+ user_profile_location = [
247
+ user_profile_address_1,
248
+ user_profile_address_2,
249
+ user_profile_city,
250
+ user_profile_state,
251
+ user_profile_zip,
252
+ user_profile_country
253
+ ].join(' ')
254
+ expect(
255
+ strategy.info['location']
256
+ ).to eq(
257
+ user_profile_location
258
+ )
259
+ end
260
+ end
261
+ end
262
+
263
+ describe '#extra' do
264
+ it 'includes the raw user profile response' do
265
+ user_profile = {
266
+ 'id' => 'user_profile_id'
267
+ }
268
+
269
+ allow(
270
+ strategy
271
+ ).to receive(:user_profile).
272
+ and_return(user_profile)
273
+
274
+ expect(
275
+ strategy.extra
276
+ ).to eq({
277
+ 'raw_info' => user_profile
278
+ })
279
+ end
280
+ end
281
+
282
+ describe '#authorize_params' do
283
+ describe 'default' do
284
+ describe 'redirect_url' do
285
+ it 'is nil' do
286
+ expect(
287
+ strategy.authorize_params['redirect_uri']
288
+ ).to be_nil
289
+ end
290
+ end
291
+
292
+ describe 'scope' do
293
+ it 'is basic' do
294
+ expect(
295
+ strategy.authorize_params['scope']
296
+ ).to eq(
297
+ 'basic'
298
+ )
299
+ end
300
+ end
301
+
302
+ describe 'response_type' do
303
+ it 'is code' do
304
+ expect(
305
+ strategy.authorize_params['response_type']
306
+ ).to eq(
307
+ 'code'
308
+ )
309
+ end
310
+ end
311
+
312
+ describe 'type' do
313
+ it 'is login' do
314
+ expect(
315
+ strategy.authorize_params['type']
316
+ ).to eq(
317
+ 'login'
318
+ )
319
+ end
320
+ end
321
+ end
322
+ end
323
+ end
@@ -0,0 +1,13 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'simplecov'
5
+ SimpleCov.start
6
+
7
+ require 'omniauth/doximity_oauth2'
8
+
9
+ Dir["spec/support/**/*.rb"].each { |f| require File.expand_path(f) }
10
+
11
+ RSpec.configure do |config|
12
+ config.order = 'random'
13
+ end
@@ -0,0 +1 @@
1
+ OmniAuth.config.test_mode = true
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-doximity_oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Aaron Kuehler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: omniauth
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: omniauth-oauth2
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.1'
97
+ description: 'An OmniAuth strategy implementation for obtaining access to the Doximity
98
+ API; API documentation at: http://developer.doximity.com/'
99
+ email:
100
+ - aaron.kuehler@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - lib/omniauth/doximity_oauth2.rb
112
+ - lib/omniauth/doximity_oauth2/version.rb
113
+ - lib/omniauth/strategies/doximity.rb
114
+ - omniauth-doximity_oauth2.gemspec
115
+ - spec/omniauth/strategies/doximity_spec.rb
116
+ - spec/spec_helper.rb
117
+ - spec/support/omniauth.rb
118
+ homepage: https://github.com/indiebrain/omniauth-doximity_oauth2
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.2.2
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: A Doximity OAuth2 Strategy for OmniAuth
142
+ test_files:
143
+ - spec/omniauth/strategies/doximity_spec.rb
144
+ - spec/spec_helper.rb
145
+ - spec/support/omniauth.rb