omniauth-auth0 2.4.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,6 +3,8 @@
3
3
  require 'spec_helper'
4
4
  require 'jwt'
5
5
 
6
+ OmniAuth.config.allowed_request_methods = [:get, :post]
7
+
6
8
  RSpec.shared_examples 'site has valid domain url' do |url|
7
9
  it { expect(subject.site).to eq(url) }
8
10
  end
@@ -26,7 +28,12 @@ describe OmniAuth::Strategies::Auth0 do
26
28
  end
27
29
 
28
30
  describe 'client_options' do
29
- let(:subject) { auth0.client }
31
+ let(:subject) { OmniAuth::Strategies::Auth0.new(
32
+ application,
33
+ client_id,
34
+ client_secret,
35
+ domain_url
36
+ ).client }
30
37
 
31
38
  context 'domain with https' do
32
39
  let(:domain_url) { 'https://samples.auth0.com' }
@@ -86,6 +93,9 @@ describe OmniAuth::Strategies::Auth0 do
86
93
  expect(redirect_url).not_to have_query('connection_scope')
87
94
  expect(redirect_url).not_to have_query('prompt')
88
95
  expect(redirect_url).not_to have_query('screen_hint')
96
+ expect(redirect_url).not_to have_query('login_hint')
97
+ expect(redirect_url).not_to have_query('organization')
98
+ expect(redirect_url).not_to have_query('invitation')
89
99
  end
90
100
 
91
101
  it 'redirects to hosted login page' do
@@ -102,6 +112,9 @@ describe OmniAuth::Strategies::Auth0 do
102
112
  expect(redirect_url).not_to have_query('connection_scope')
103
113
  expect(redirect_url).not_to have_query('prompt')
104
114
  expect(redirect_url).not_to have_query('screen_hint')
115
+ expect(redirect_url).not_to have_query('login_hint')
116
+ expect(redirect_url).not_to have_query('organization')
117
+ expect(redirect_url).not_to have_query('invitation')
105
118
  end
106
119
 
107
120
  it 'redirects to the hosted login page with connection_scope' do
@@ -125,6 +138,9 @@ describe OmniAuth::Strategies::Auth0 do
125
138
  expect(redirect_url).to have_query('prompt', 'login')
126
139
  expect(redirect_url).not_to have_query('auth0Client')
127
140
  expect(redirect_url).not_to have_query('connection')
141
+ expect(redirect_url).not_to have_query('login_hint')
142
+ expect(redirect_url).not_to have_query('organization')
143
+ expect(redirect_url).not_to have_query('invitation')
128
144
  end
129
145
 
130
146
  it 'redirects to hosted login page with screen_hint=signup' do
@@ -139,6 +155,47 @@ describe OmniAuth::Strategies::Auth0 do
139
155
  expect(redirect_url).to have_query('screen_hint', 'signup')
140
156
  expect(redirect_url).not_to have_query('auth0Client')
141
157
  expect(redirect_url).not_to have_query('connection')
158
+ expect(redirect_url).not_to have_query('login_hint')
159
+ expect(redirect_url).not_to have_query('organization')
160
+ expect(redirect_url).not_to have_query('invitation')
161
+ end
162
+
163
+ it 'redirects to hosted login page with organization=TestOrg and invitation=TestInvite' do
164
+ get 'auth/auth0?organization=TestOrg&invitation=TestInvite'
165
+ expect(last_response.status).to eq(302)
166
+ redirect_url = last_response.headers['Location']
167
+ expect(redirect_url).to start_with('https://samples.auth0.com/authorize')
168
+ expect(redirect_url).to have_query('response_type', 'code')
169
+ expect(redirect_url).to have_query('state')
170
+ expect(redirect_url).to have_query('client_id')
171
+ expect(redirect_url).to have_query('redirect_uri')
172
+ expect(redirect_url).to have_query('organization', 'TestOrg')
173
+ expect(redirect_url).to have_query('invitation', 'TestInvite')
174
+ expect(redirect_url).not_to have_query('auth0Client')
175
+ expect(redirect_url).not_to have_query('connection')
176
+ expect(redirect_url).not_to have_query('connection_scope')
177
+ expect(redirect_url).not_to have_query('prompt')
178
+ expect(redirect_url).not_to have_query('screen_hint')
179
+ expect(redirect_url).not_to have_query('login_hint')
180
+ end
181
+
182
+ it 'redirects to hosted login page with login_hint=example@mail.com' do
183
+ get 'auth/auth0?login_hint=example@mail.com'
184
+ expect(last_response.status).to eq(302)
185
+ redirect_url = last_response.headers['Location']
186
+ expect(redirect_url).to start_with('https://samples.auth0.com/authorize')
187
+ expect(redirect_url).to have_query('response_type', 'code')
188
+ expect(redirect_url).to have_query('state')
189
+ expect(redirect_url).to have_query('client_id')
190
+ expect(redirect_url).to have_query('redirect_uri')
191
+ expect(redirect_url).to have_query('login_hint', 'example@mail.com')
192
+ expect(redirect_url).not_to have_query('auth0Client')
193
+ expect(redirect_url).not_to have_query('connection')
194
+ expect(redirect_url).not_to have_query('connection_scope')
195
+ expect(redirect_url).not_to have_query('prompt')
196
+ expect(redirect_url).not_to have_query('screen_hint')
197
+ expect(redirect_url).not_to have_query('organization')
198
+ expect(redirect_url).not_to have_query('invitation')
142
199
  end
143
200
 
144
201
  describe 'callback' do
@@ -161,12 +218,17 @@ describe OmniAuth::Strategies::Auth0 do
161
218
  payload['sub'] = user_id
162
219
  payload['iss'] = "#{domain_url}/"
163
220
  payload['aud'] = client_id
221
+ payload['name'] = name
222
+ payload['nickname'] = nickname
223
+ payload['picture'] = picture
224
+ payload['email'] = email
225
+ payload['email_verified'] = email_verified
226
+
164
227
  JWT.encode payload, client_secret, 'HS256'
165
228
  end
166
229
 
167
230
  let(:oauth_response) do
168
231
  {
169
- id_token: id_token,
170
232
  access_token: access_token,
171
233
  expires_in: expires_in,
172
234
  token_type: token_type
@@ -182,17 +244,7 @@ describe OmniAuth::Strategies::Auth0 do
182
244
  }
183
245
  end
184
246
 
185
- let(:basic_user_info) { { sub: user_id } }
186
- let(:oidc_user_info) do
187
- {
188
- sub: user_id,
189
- name: name,
190
- nickname: nickname,
191
- email: email,
192
- picture: picture,
193
- email_verified: email_verified
194
- }
195
- end
247
+ let(:basic_user_info) { { "sub" => user_id, "name" => name } }
196
248
 
197
249
  def stub_auth(body)
198
250
  stub_request(:post, 'https://samples.auth0.com/oauth/token')
@@ -220,7 +272,9 @@ describe OmniAuth::Strategies::Auth0 do
220
272
  WebMock.reset!
221
273
  end
222
274
 
223
- let(:subject) { MultiJson.decode(last_response.body) }
275
+ let(:subject) do
276
+ MultiJson.decode(last_response.body)
277
+ end
224
278
 
225
279
  context 'basic oauth' do
226
280
  before do
@@ -239,10 +293,14 @@ describe OmniAuth::Strategies::Auth0 do
239
293
  expect(subject['credentials']['expires_at']).to_not be_nil
240
294
  end
241
295
 
242
- it 'has basic values' do
296
+ it 'has basic values' do
243
297
  expect(subject['provider']).to eq('auth0')
244
298
  expect(subject['uid']).to eq(user_id)
245
- expect(subject['info']['name']).to eq(user_id)
299
+ expect(subject['info']['name']).to eq(name)
300
+ end
301
+
302
+ it 'should use the user info endpoint' do
303
+ expect(subject['extra']['raw_info']).to eq(basic_user_info)
246
304
  end
247
305
  end
248
306
 
@@ -268,7 +326,6 @@ describe OmniAuth::Strategies::Auth0 do
268
326
  context 'oidc' do
269
327
  before do
270
328
  stub_auth(oidc_response)
271
- stub_userinfo(oidc_user_info)
272
329
  trigger_callback
273
330
  end
274
331
 
metadata CHANGED
@@ -1,43 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-auth0
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Auth0
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-23 00:00:00.000000000 Z
11
+ date: 2021-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: omniauth-oauth2
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '1.5'
33
+ version: '1.7'
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '1.5'
40
+ version: '1.7'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: '1.9'
47
+ version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: '1.9'
54
+ version: '0'
41
55
  description: |
42
56
  Auth0 is an authentication broker that supports social identity providers as well as enterprise identity providers such as Active Directory, LDAP, Google Apps, Salesforce.
43
57
 
@@ -53,7 +67,9 @@ files:
53
67
  - ".circleci/config.yml"
54
68
  - ".gemrelease"
55
69
  - ".github/CODEOWNERS"
56
- - ".github/ISSUE_TEMPLATE.md"
70
+ - ".github/ISSUE_TEMPLATE/config.yml"
71
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
72
+ - ".github/ISSUE_TEMPLATE/report_a_bug.md"
57
73
  - ".github/PULL_REQUEST_TEMPLATE.md"
58
74
  - ".github/stale.yml"
59
75
  - ".gitignore"
@@ -64,7 +80,6 @@ files:
64
80
  - CODE_OF_CONDUCT.md
65
81
  - CONTRIBUTING.md
66
82
  - Gemfile
67
- - Gemfile.lock
68
83
  - Guardfile
69
84
  - LICENSE
70
85
  - README.md
@@ -103,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
118
  - !ruby/object:Gem::Version
104
119
  version: '0'
105
120
  requirements: []
106
- rubygems_version: 3.1.2
121
+ rubygems_version: 3.2.16
107
122
  signing_key:
108
123
  specification_version: 4
109
124
  summary: OmniAuth OAuth2 strategy for the Auth0 platform.
@@ -1,39 +0,0 @@
1
- In order to efficiently and accurately address your issue or feature request, please read through the template below and answer all relevant questions. Your additional work here is greatly appreciated and will help us respond as quickly as possible. Please delete any sections or questions below that do not pertain to this request.
2
-
3
- For general support or usage questions, please use the [Auth0 Community](https://community.auth0.com/) or [Auth0 Support](https://support.auth0.com.).
4
-
5
- ### Description
6
-
7
- Description of the bug or feature request and why it's a problem. Consider including:
8
-
9
- - The use case or overall problem you're trying to solve
10
- - Information about when the problem started
11
-
12
- ### Prerequisites
13
-
14
- * [ ] I have read the [Auth0 contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
15
- * [ ] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
16
- * [ ] Did you check the [documentation](https://auth0.com/docs/quickstart/webapp/rails)?
17
- * [ ] Did you check [Auth0 Community](https://community.auth0.com/tags/rails)?
18
- * [ ] Are you reporting this to the correct repository? This strategy relies on [OmniAuth](https://github.com/omniauth/omniauth) and the [OmniAuth OAuth2](https://github.com/omniauth/omniauth-oauth2) strategy.
19
- * [ ] Are there any related or duplicate [Issues](https://github.com/auth0/omniauth-auth0/issues) or [PRs](https://github.com/auth0/omniauth-auth0/pulls) for this issue?
20
-
21
- ### Environment
22
-
23
- Please provide the following:
24
-
25
- * OmniAuth-Auth0 version:
26
- * Ruby version:
27
- * Rails veresion:
28
- * Browser version, if applicable:
29
- * Additional gems that might be affecting your instance:
30
-
31
- ### Reproduction
32
-
33
- Detail the steps taken to reproduce this error and note if this issue can be reproduced consistently or if it is intermittent.
34
-
35
- Please include:
36
-
37
- - Log files (redact/remove sensitive information)
38
- - Application settings (redact/remove sensitive information)
39
- - Screenshots, if helpful
data/Gemfile.lock DELETED
@@ -1,167 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- omniauth-auth0 (2.4.0)
5
- omniauth-oauth2 (~> 1.5)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- addressable (2.7.0)
11
- public_suffix (>= 2.0.2, < 5.0)
12
- ast (2.4.1)
13
- codecov (0.2.11)
14
- json
15
- simplecov
16
- coderay (1.1.3)
17
- crack (0.4.4)
18
- daemons (1.3.1)
19
- diff-lcs (1.4.4)
20
- docile (1.3.2)
21
- dotenv (2.7.6)
22
- eventmachine (1.2.7)
23
- faraday (1.0.1)
24
- multipart-post (>= 1.2, < 3)
25
- ffi (1.13.1)
26
- formatador (0.2.5)
27
- gem-release (2.1.1)
28
- guard (2.16.2)
29
- formatador (>= 0.2.4)
30
- listen (>= 2.7, < 4.0)
31
- lumberjack (>= 1.0.12, < 2.0)
32
- nenv (~> 0.1)
33
- notiffany (~> 0.0)
34
- pry (>= 0.9.12)
35
- shellany (~> 0.0)
36
- thor (>= 0.18.1)
37
- guard-compat (1.2.1)
38
- guard-rspec (4.7.3)
39
- guard (~> 2.1)
40
- guard-compat (~> 1.1)
41
- rspec (>= 2.99.0, < 4.0)
42
- hashdiff (1.0.1)
43
- hashie (4.1.0)
44
- json (2.3.1)
45
- jwt (2.2.2)
46
- listen (3.1.5)
47
- rb-fsevent (~> 0.9, >= 0.9.4)
48
- rb-inotify (~> 0.9, >= 0.9.7)
49
- ruby_dep (~> 1.2)
50
- lumberjack (1.2.8)
51
- method_source (1.0.0)
52
- multi_json (1.15.0)
53
- multi_xml (0.6.0)
54
- multipart-post (2.1.1)
55
- mustermann (1.1.1)
56
- ruby2_keywords (~> 0.0.1)
57
- nenv (0.3.0)
58
- notiffany (0.1.3)
59
- nenv (~> 0.1)
60
- shellany (~> 0.0)
61
- oauth2 (1.4.4)
62
- faraday (>= 0.8, < 2.0)
63
- jwt (>= 1.0, < 3.0)
64
- multi_json (~> 1.3)
65
- multi_xml (~> 0.5)
66
- rack (>= 1.2, < 3)
67
- omniauth (1.9.1)
68
- hashie (>= 3.4.6)
69
- rack (>= 1.6.2, < 3)
70
- omniauth-oauth2 (1.7.0)
71
- oauth2 (~> 1.4)
72
- omniauth (~> 1.9)
73
- parallel (1.19.2)
74
- parser (2.7.1.4)
75
- ast (~> 2.4.1)
76
- pry (0.13.1)
77
- coderay (~> 1.1)
78
- method_source (~> 1.0)
79
- public_suffix (4.0.6)
80
- rack (2.2.3)
81
- rack-protection (2.1.0)
82
- rack
83
- rack-test (1.1.0)
84
- rack (>= 1.0, < 3)
85
- rainbow (3.0.0)
86
- rake (13.0.1)
87
- rb-fsevent (0.10.4)
88
- rb-inotify (0.10.1)
89
- ffi (~> 1.0)
90
- regexp_parser (1.8.0)
91
- rexml (3.2.4)
92
- rspec (3.9.0)
93
- rspec-core (~> 3.9.0)
94
- rspec-expectations (~> 3.9.0)
95
- rspec-mocks (~> 3.9.0)
96
- rspec-core (3.9.2)
97
- rspec-support (~> 3.9.3)
98
- rspec-expectations (3.9.2)
99
- diff-lcs (>= 1.2.0, < 2.0)
100
- rspec-support (~> 3.9.0)
101
- rspec-mocks (3.9.1)
102
- diff-lcs (>= 1.2.0, < 2.0)
103
- rspec-support (~> 3.9.0)
104
- rspec-support (3.9.3)
105
- rubocop (0.91.0)
106
- parallel (~> 1.10)
107
- parser (>= 2.7.1.1)
108
- rainbow (>= 2.2.2, < 4.0)
109
- regexp_parser (>= 1.7)
110
- rexml
111
- rubocop-ast (>= 0.4.0, < 1.0)
112
- ruby-progressbar (~> 1.7)
113
- unicode-display_width (>= 1.4.0, < 2.0)
114
- rubocop-ast (0.4.2)
115
- parser (>= 2.7.1.4)
116
- ruby-progressbar (1.10.1)
117
- ruby2_keywords (0.0.2)
118
- ruby_dep (1.5.0)
119
- shellany (0.0.1)
120
- shotgun (0.9.2)
121
- rack (>= 1.0)
122
- simplecov (0.19.0)
123
- docile (~> 1.1)
124
- simplecov-html (~> 0.11)
125
- simplecov-html (0.12.2)
126
- sinatra (2.1.0)
127
- mustermann (~> 1.0)
128
- rack (~> 2.2)
129
- rack-protection (= 2.1.0)
130
- tilt (~> 2.0)
131
- thin (1.7.2)
132
- daemons (~> 1.0, >= 1.0.9)
133
- eventmachine (~> 1.0, >= 1.0.4)
134
- rack (>= 1, < 3)
135
- thor (1.0.1)
136
- tilt (2.0.10)
137
- unicode-display_width (1.7.0)
138
- webmock (3.9.1)
139
- addressable (>= 2.3.6)
140
- crack (>= 0.3.2)
141
- hashdiff (>= 0.4.0, < 2.0.0)
142
-
143
- PLATFORMS
144
- ruby
145
-
146
- DEPENDENCIES
147
- bundler (~> 1.9)
148
- codecov
149
- dotenv
150
- gem-release
151
- guard-rspec
152
- jwt
153
- listen (~> 3.1.5)
154
- omniauth-auth0!
155
- pry
156
- rack-test
157
- rake
158
- rspec (~> 3.5)
159
- rubocop
160
- shotgun
161
- simplecov
162
- sinatra
163
- thin
164
- webmock
165
-
166
- BUNDLED WITH
167
- 1.17.3