omniauth-scientist 1.0.0 → 2.0.0

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
  SHA256:
3
- metadata.gz: 60103e1cd9f35d1c4536365b3b174581ce4e1b58e4314cc50f2b501f28931720
4
- data.tar.gz: dec823994918653c5e8d563d128679ef192cd257468d6385e59a841478fbd08d
3
+ metadata.gz: 60f5d4986e0ec7f55a516595d3b199a65a29dbb16e1c55f6d0a739770244e8d8
4
+ data.tar.gz: 6b408a16846f342773d7e8c4b2bba5322313bdf5e62449394663d5c8861205d5
5
5
  SHA512:
6
- metadata.gz: 12fc82e60833aed5d672a8decb29fc2b49e3d6f04969eb480f6e0e540a01e12ed7a3283b3c522e368ecb90f2383838932ad0996d8772e0bc1a9e5dd5c13c0b07
7
- data.tar.gz: 395f62e98a7572ac5e5c3011040dc3c76281d344f4a80391eead74c8dc8486d04c36912493cf43199f40a9bf952040f24853754272582dcbe7e343e05c9de82e
6
+ metadata.gz: 3b557b19453d5c632c748f7226ab9feec444722dd444942836659f1c5e739eab38d2f75b485042377625defb5815c27e131244b45335431afaddd41e9434c8c6
7
+ data.tar.gz: 949c4bbafbc75633d70706ff68ac0f2b014dd3363be3814af4e31333341a6b535e93101a537b5282a5a04dd31b8ad0ceb3d88dbf1dd78d44acd2838db603bd29
@@ -0,0 +1,20 @@
1
+ name: Ruby
2
+
3
+ on: pull_request
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby-version: ['2.7', '3.0', '3.1', '3.2']
11
+
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+ - name: Set up Ruby ${{ matrix.ruby-version }}
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby-version }}
18
+ bundler-cache: true
19
+ - name: Build and test with Rake
20
+ run: bundle exec rake
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  ## Basic Usage
4
4
 
5
5
  ```ruby
6
- use OmniAuth::Builder do
6
+ Rails.application.config.middleware.use OmniAuth::Builder do
7
7
  provider :scientist, ENV['SCIENTIST_ID'], ENV['SCIENTIST_SECRET']
8
8
  end
9
9
  ```
@@ -11,19 +11,25 @@ end
11
11
  ## Enterprise Usage
12
12
 
13
13
  ```ruby
14
- provider :scientist, ENV['SCIENTIST_ID'], ENV['SCIENTIST_SECRET'],
15
- {
16
- client_options: {
17
- site: 'https://<YOURSUBDOMAIN>.scientist.com',
18
- authorize_url: 'https://<YOURSUBDOMAIN>.scientist.com/oauth/authorize',
19
- token_url: 'https://<YOURSUBDOMAIN>.scientist.com/oauth/token'
14
+ Rails.application.config.middleware.use OmniAuth::Builder do
15
+ provider :scientist, ENV['SCIENTIST_ID'], ENV['SCIENTIST_SECRET'],
16
+ {
17
+ client_options: {
18
+ site: 'https://<YOURSUBDOMAIN>.scientist.com',
19
+ authorize_url: 'https://<YOURSUBDOMAIN>.scientist.com/oauth/authorize',
20
+ token_url: 'https://<YOURSUBDOMAIN>.scientist.com/oauth/token'
21
+ }
20
22
  }
21
- }
23
+ end
22
24
  ```
23
25
 
26
+ ## Credits
27
+
28
+ Heavily inspired by: [omniauth-github](https://github.com/omniauth/omniauth-github)
29
+
24
30
  ## License
25
31
 
26
- Copyright (c) 2019 Assay Depot Inc. d/b/a Scientist.com
32
+ Copyright (c) 2024 Assay Depot Inc. d/b/a Scientist.com
27
33
 
28
34
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
29
35
 
@@ -4,9 +4,9 @@ module OmniAuth
4
4
  module Strategies
5
5
  class Scientist < OmniAuth::Strategies::OAuth2
6
6
  option :client_options, {
7
- :site => 'https://app.scientist.com',
8
- :authorize_url => 'https://app.scientist.com/oauth/authorize',
9
- :token_url => 'https://app.scientist.com/oauth/token'
7
+ site: 'https://app.scientist.com',
8
+ authorize_url: 'https://app.scientist.com/oauth/authorize',
9
+ token_url: 'https://app.scientist.com/oauth/token'
10
10
  }
11
11
 
12
12
  def request_phase
@@ -15,7 +15,7 @@ module OmniAuth
15
15
 
16
16
  def authorize_params
17
17
  super.tap do |params|
18
- %w[scope client_options].each do |v|
18
+ %w[client_options].each do |v|
19
19
  if request.params[v]
20
20
  params[v.to_sym] = request.params[v]
21
21
  end
@@ -23,19 +23,21 @@ module OmniAuth
23
23
  end
24
24
  end
25
25
 
26
- uid { user_attribute('id') }
26
+ uid {
27
+ raw_info['id'].to_s
28
+ }
27
29
 
28
30
  info do
29
31
  {
30
32
  'provider' => 'scientist',
31
33
  'uid' => uid,
32
34
  'email' => email,
33
- 'name' => "#{user_attribute('first_name')} #{user_attribute('last_name')}",
34
- 'first_name' => user_attribute('first_name'),
35
- 'last_name' => user_attribute('last_name'),
36
- 'title' => user_attribute('title'),
37
- 'company' => user_attribute('company'),
38
- 'site' => user_attribute('site')
35
+ 'name' => "#{raw_info['first_name']} #{raw_info['last_name']}",
36
+ 'first_name' => raw_info['first_name'],
37
+ 'last_name' => raw_info['last_name'],
38
+ 'title' => raw_info['title'],
39
+ 'company' => raw_info['company'],
40
+ 'site' => raw_info['site']
39
41
  }
40
42
  end
41
43
 
@@ -45,21 +47,15 @@ module OmniAuth
45
47
 
46
48
  def raw_info
47
49
  access_token.options[:mode] = :header
48
- @raw_info ||= { 'user' => access_token['user'] }
50
+ @raw_info ||= access_token["user"]
49
51
  end
50
52
 
51
53
  def email
52
- user_attribute('email')
54
+ raw_info['email']
53
55
  end
54
56
 
55
57
  def callback_url
56
- full_host + script_name + callback_path
57
- end
58
-
59
- protected
60
-
61
- def user_attribute(attribute)
62
- raw_info['user'][attribute] if raw_info['user']
58
+ full_host + callback_path
63
59
  end
64
60
  end
65
61
  end
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Scientist
3
- VERSION = "1.0.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -16,9 +16,9 @@ Gem::Specification.new do |gem|
16
16
  gem.require_paths = ["lib"]
17
17
  gem.version = OmniAuth::Scientist::VERSION
18
18
 
19
- gem.add_dependency 'omniauth', '~> 1.9'
20
- gem.add_dependency 'omniauth-oauth2', '>= 1.6.0', '< 2.0'
21
- gem.add_development_dependency 'rspec'
19
+ gem.add_dependency 'omniauth', '~> 2.0'
20
+ gem.add_dependency 'omniauth-oauth2', '~> 1.8'
21
+ gem.add_development_dependency 'rspec', '~> 3.5'
22
22
  gem.add_development_dependency 'rack-test'
23
23
  gem.add_development_dependency 'simplecov'
24
24
  gem.add_development_dependency 'webmock'
@@ -1,22 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::Scientist do
4
- let(:access_token) { instance_double('AccessToken', :options => {}) }
5
- let(:parsed_response) { instance_double('ParsedResponse') }
6
- let(:response) { instance_double('Response', :parsed => parsed_response) }
4
+ let(:access_token) { instance_double('AccessToken', :options => {}, :[] => 'user') }
7
5
 
8
- let(:enterprise_site) { 'https://some.other.site.com/' }
9
- let(:enterprise_authorize_url) { 'https://some.other.site.com/oauth/authorize' }
10
- let(:enterprise_token_url) { 'https://some.other.site.com/oauth/token' }
6
+ let(:enterprise_site) { 'https://some.other.site.com/api/v3' }
7
+ let(:enterprise_authorize_url) { 'https://some.other.site.com/login/oauth/authorize' }
8
+ let(:enterprise_token_url) { 'https://some.other.site.com/login/oauth/access_token' }
11
9
  let(:enterprise) do
12
- OmniAuth::Strategies::Scientist.new('SCIENTIST_ID', 'SCIENTIST_SECRET',
13
- {
14
- :client_options => {
15
- :site => enterprise_site,
16
- :authorize_url => enterprise_authorize_url,
17
- :token_url => enterprise_token_url
10
+ OmniAuth::Strategies::Scientist.new('SIENTIST_KEY', 'SIENTIST_SECRET',
11
+ {
12
+ :client_options => {
13
+ :site => enterprise_site,
14
+ :authorize_url => enterprise_authorize_url,
15
+ :token_url => enterprise_token_url
16
+ }
18
17
  }
19
- }
20
18
  )
21
19
  end
22
20
 
@@ -61,40 +59,6 @@ describe OmniAuth::Strategies::Scientist do
61
59
  allow(subject).to receive(:raw_info).and_return({ 'email' => 'you@example.com' })
62
60
  expect(subject.email).to eq('you@example.com')
63
61
  end
64
-
65
- it 'should return nil if there is no raw_info and email access is not allowed' do
66
- allow(subject).to receive(:raw_info).and_return({})
67
- expect(subject.email).to be_nil
68
- end
69
-
70
- it 'should not return the primary email if there is no raw_info and email access is allowed' do
71
- emails = [
72
- { 'email' => 'secondary@example.com', 'primary' => false },
73
- { 'email' => 'primary@example.com', 'primary' => true }
74
- ]
75
- allow(subject).to receive(:raw_info).and_return({})
76
- subject.options['scope'] = 'user'
77
- allow(subject).to receive(:emails).and_return(emails)
78
- expect(subject.email).to be_nil
79
- end
80
-
81
- it 'should not return the first email if there is no raw_info and email access is allowed' do
82
- emails = [
83
- { 'email' => 'first@example.com', 'primary' => false },
84
- { 'email' => 'second@example.com', 'primary' => false }
85
- ]
86
- allow(subject).to receive(:raw_info).and_return({})
87
- subject.options['scope'] = 'user'
88
- allow(subject).to receive(:emails).and_return(emails)
89
- expect(subject.email).to be_nil
90
- end
91
- end
92
-
93
- context '#raw_info' do
94
- it 'should use relative paths' do
95
- expect(access_token).to receive(:get).with('user').and_return(response)
96
- expect(subject.raw_info).to eq(parsed_response)
97
- end
98
62
  end
99
63
 
100
64
  context '#info.email' do
@@ -113,4 +77,4 @@ describe OmniAuth::Strategies::Scientist do
113
77
  expect(subject.callback_url).to eq('https://example.com/sub_uri/auth/scientist/callback')
114
78
  end
115
79
  end
116
- end
80
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-scientist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Petersen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-23 00:00:00.000000000 Z
11
+ date: 2024-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -16,48 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.9'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.9'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: omniauth-oauth2
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.6.0
34
- - - "<"
31
+ - - "~>"
35
32
  - !ruby/object:Gem::Version
36
- version: '2.0'
33
+ version: '1.8'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 1.6.0
44
- - - "<"
38
+ - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: '2.0'
40
+ version: '1.8'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: rspec
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
- - - ">="
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: '3.5'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
- - - ">="
52
+ - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: '0'
54
+ version: '3.5'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: rack-test
63
57
  requirement: !ruby/object:Gem::Requirement
@@ -107,6 +101,7 @@ executables: []
107
101
  extensions: []
108
102
  extra_rdoc_files: []
109
103
  files:
104
+ - ".github/workflows/ruby.yml"
110
105
  - ".gitignore"
111
106
  - ".rspec"
112
107
  - Gemfile
@@ -123,7 +118,7 @@ homepage: https://github.com/assaydepot/omniauth-scientist
123
118
  licenses:
124
119
  - MIT
125
120
  metadata: {}
126
- post_install_message:
121
+ post_install_message:
127
122
  rdoc_options: []
128
123
  require_paths:
129
124
  - lib
@@ -138,9 +133,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
133
  - !ruby/object:Gem::Version
139
134
  version: '0'
140
135
  requirements: []
141
- rubyforge_project:
142
- rubygems_version: 2.7.6
143
- signing_key:
136
+ rubygems_version: 3.5.3
137
+ signing_key:
144
138
  specification_version: 4
145
139
  summary: Official OmniAuth strategy for Scientist.
146
140
  test_files: