auth0 4.17.1 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.yardoc/checksums +22 -0
  4. data/.yardoc/complete +0 -0
  5. data/.yardoc/object_types +0 -0
  6. data/.yardoc/objects/root.dat +0 -0
  7. data/.yardoc/proxy_types +0 -0
  8. data/CHANGELOG.md +33 -0
  9. data/Gemfile +0 -1
  10. data/Gemfile.lock +19 -21
  11. data/README.md +1 -7
  12. data/Rakefile +0 -22
  13. data/auth0.gemspec +0 -1
  14. data/examples/ruby-api/.gitignore +0 -6
  15. data/lib/auth0/api/authentication_endpoints.rb +6 -220
  16. data/lib/auth0/api/v2/users.rb +7 -5
  17. data/lib/auth0/exception.rb +2 -7
  18. data/lib/auth0/mixins.rb +0 -1
  19. data/lib/auth0/mixins/access_token_struct.rb +2 -2
  20. data/lib/auth0/mixins/api_token_struct.rb +2 -2
  21. data/lib/auth0/mixins/initializer.rb +1 -7
  22. data/lib/auth0/mixins/permission_struct.rb +2 -2
  23. data/lib/auth0/mixins/validation.rb +1 -1
  24. data/lib/auth0/version.rb +1 -1
  25. data/spec/integration/lib/auth0/api/api_authentication_spec.rb +1 -1
  26. data/spec/integration/lib/auth0/api/v2/api_roles_spec.rb +1 -1
  27. data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +1 -1
  28. data/spec/lib/auth0/api/v2/roles_spec.rb +4 -4
  29. data/spec/lib/auth0/api/v2/users_spec.rb +19 -9
  30. data/spec/support/credentials.rb +0 -19
  31. metadata +7 -31
  32. data/deploy_documentation.sh +0 -29
  33. data/doc_config/templates/default/fulldoc/html/css/full_list.css +0 -79
  34. data/doc_config/templates/default/fulldoc/html/css/style.css +0 -546
  35. data/doc_config/templates/default/layout/html/breadcrumb.erb +0 -11
  36. data/doc_config/templates/default/layout/html/footer.erb +0 -115
  37. data/doc_config/templates/default/layout/html/headers.erb +0 -17
  38. data/doc_config/templates/default/layout/html/layout.erb +0 -27
  39. data/lib/auth0/api/v1.rb +0 -19
  40. data/lib/auth0/api/v1/clients.rb +0 -58
  41. data/lib/auth0/api/v1/connections.rb +0 -68
  42. data/lib/auth0/api/v1/logs.rb +0 -43
  43. data/lib/auth0/api/v1/rules.rb +0 -57
  44. data/lib/auth0/api/v1/users.rb +0 -227
  45. data/spec/lib/auth0/api/authentication_endpoints_spec.rb +0 -703
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48e61f0781f7f7414219fe6f2aa406fa5f11df18707e04ef242a062c4775f6f0
4
- data.tar.gz: 5d0f5d8fd83e4f77624394c8fd968a2b167f3f2bdeef3f7b60012df3ec28e8e4
3
+ metadata.gz: 82dfc2ea2a26c6a1aa75bcbfeb013ba0ae6f88f160c855863e858b56dadc40a4
4
+ data.tar.gz: 9c882d7199b9084703b573ab3621b202858fc1d4f6ffd20c588de54e4b7ac2e5
5
5
  SHA512:
6
- metadata.gz: '055290cd6f89e5da0e8316bb805268d84d29108abff3c0afe133a286de5718cf9d1d394873a64a08b456b6fa8c24246347010eaf0e7d1ec6d1f7856165255b58'
7
- data.tar.gz: ab47cf7f1728afcd517d8d59b01e06b8857c8a7f5b2e4028bb931d4939548ec565b0385894eb05320e0419955dc43b2203024e3ba090a8459cc1d5b7eca978a9
6
+ metadata.gz: 8005cde8f1c028b5d87c8058c3b711cd0f8d85e4dd34db1d2b79e45581935a26401dfc5da5d0e08745ccb3b061ebd1ab767d9255043e827e55468f7603ea290c
7
+ data.tar.gz: cb6ac580e79b850b7785f1e13594e06b4055fb124906910590519b9cd6e6f6df984c218b21cf07cf2c0738212a0d444c2e07dcbf3e7c58bb5298a38fbea3c347
data/.gitignore CHANGED
@@ -10,5 +10,4 @@ coverage
10
10
  *.swp
11
11
  *.swo
12
12
  spec/auth0.yml
13
- .yardoc
14
13
  .env
@@ -0,0 +1,22 @@
1
+ lib/auth0/api/v2/jobs.rb 53fe5a814c9da1bb89d7cb885fe7f1151d6ca44a
2
+ lib/auth0/api/v2/logs.rb f4b9b93248d85d29d58ac12b6b5ebabd72f98adb
3
+ lib/auth0/api/v2/roles.rb 99e9d0222f0d59f21cb061d13b434bf1a903660a
4
+ lib/auth0/api/v2/rules.rb 2fbbf4258ba7e6fe67d1ab197ca3503d4e5daf84
5
+ lib/auth0/api/v2/stats.rb 035b172ad69efb2b040ffcd29319f23017352b4c
6
+ lib/auth0/api/v2/users.rb 6a648030a6851db60ab13dc3a8a7d46bd51ce977
7
+ lib/auth0/api/v2/emails.rb 83aaf5ed8082cb2787a0f9c47c463d218a3aee77
8
+ lib/auth0/api/v2/anomaly.rb c0e38b3cbb4cca65fbe51e6ed69d56cfa5ea8d0e
9
+ lib/auth0/api/v2/clients.rb 23c2b6f307f6a20537720ad24de30b62de51b9f2
10
+ lib/auth0/api/v2/prompts.rb 688c71d37885b64ed8c174d54c9403fe21dc0735
11
+ lib/auth0/api/v2/tenants.rb d20a9c46b6754d504667b6d5187b525274d5ffe8
12
+ lib/auth0/api/v2/tickets.rb fd192d8b281ca54d318cac0a6b5cff3cad555076
13
+ lib/auth0/api/v2/guardian.rb 367ea7046c90fdb2065bc66eddb64e47b2d3370d
14
+ lib/auth0/api/v2/blacklists.rb c3405a13b9c6481a43136b3f4c755602e24a9511
15
+ lib/auth0/api/v2/connections.rb 3a2ac77a7f9ba97df3fd2e7b958192e06db2e0a7
16
+ lib/auth0/api/v2/log_streams.rb 1624abe964bd0e9bcfa1107a970f8fa823ec5955
17
+ lib/auth0/api/v2/user_blocks.rb ce0f80dc00eb32dc1b825c0bbafb89e94d30a28c
18
+ lib/auth0/api/v2/client_grants.rb ac7489b697d58e7514014e5ae125ffa88015306d
19
+ lib/auth0/api/v2/users_by_email.rb 95bb92421fb03ec8feee8ef0b5f2ab64c8e51403
20
+ lib/auth0/api/v2/resource_servers.rb f9c6e7c8fc0bd497e34b0a9e3ac1a81d7fbbe88b
21
+ lib/auth0/api/v2/device_credentials.rb 94b92db7091ebc7af97fe0fb10a3ad64fa36cdc8
22
+ lib/auth0/api/authentication_endpoints.rb d6e5c2fabbd79b4f17864b6ec026488d65c5090d
File without changes
Binary file
Binary file
Binary file
@@ -1,5 +1,38 @@
1
1
  # Change Log
2
2
 
3
+ ## [v5.0.0](https://github.com/auth0/ruby-auth0/tree/v5.0.0) (2020-10-22)
4
+
5
+ This release addresses some long standing issues with the library that could only be addressed in a major. We have also removed Api/v1 endpoints and other deprecated methods.
6
+
7
+ ### Migration from v4 to v5
8
+
9
+ #### Top Level Structs
10
+ The following top level structs were colliding with other libraries, this was addressed in [\#183](183) and have been namespaced with `::Auth0::`
11
+ - `ApiToken` changed to `::Auth0::ApiToken`
12
+ - `Permission` changed to `::Auth0::Permission`
13
+ - `AccessToken` changed to `::AccessToken::AccessToken`
14
+
15
+ #### Api2 Users create_user method
16
+ This method was requiring you send in a `name`, which was optional, but didn't require `connection_name` which isn't optional. This was fixed in [\#244](244).
17
+
18
+ `Auth0::Api::V2::Users.create_user(name, options = {})` has changed to `Auth0::Api::V2::Users.create_user(connection_name, options = {})`
19
+
20
+ #### APIv1 End of Life
21
+ APIv1 endpoints were deprecated in 4.x and now have been removed in v5. They reached end-of-life in the Public Cloud on 13 July 2020. Migration from v1 to v2 has been documented here https://auth0.com/docs/product-lifecycle/deprecations-and-migrations/migrate-to-management-api-v2
22
+
23
+ #### Catching 429 Errors
24
+ In 4.x `RateLimitEncountered` was inheriting from `Auth0::Unsupported` in order for backwards compatibility. This class is now inheriting `Auth0::HTTPError`. If you are catching 429 errors with `Auth0::Unsupported` then you will need to migrate to catching with `Auth0::HTTPError`.
25
+
26
+ ### Changes
27
+ [Full Changelog](https://github.com/auth0/ruby-auth0/compare/v4.17.1...v5.0.0)
28
+
29
+ **Fixed**
30
+ - Don't define structs as top-level constants (breaking changes) [\#183](https://github.com/auth0/ruby-auth0/pull/183) ([makimoto](https://github.com/makimoto))
31
+ - Fix create_user implementation (breaking changes) [\#244](https://github.com/auth0/ruby-auth0/pull/244) ([davidpatrick](https://github.com/davidpatrick))
32
+
33
+ **Removed**
34
+ - Removed Deprecations (breaking changes) [\#245](https://github.com/auth0/ruby-auth0/pull/245) ([davidpatrick](https://github.com/davidpatrick))
35
+
3
36
  ## [v4.17.1](https://github.com/auth0/ruby-auth0/tree/v4.17.1) (2020-10-21)
4
37
 
5
38
  [Full Changelog](https://github.com/auth0/ruby-auth0/compare/v4.17.0...v4.17.1)
data/Gemfile CHANGED
@@ -8,7 +8,6 @@ group :development do
8
8
  gem 'coveralls', require: false
9
9
  gem 'rubocop', require: false
10
10
  gem 'rubocop-rails', require: false
11
- gem 'yard', require: false
12
11
  end
13
12
 
14
13
  group :test do
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- auth0 (4.17.1)
4
+ auth0 (5.0.0)
5
5
  addressable (~> 2.7.0)
6
6
  jwt (~> 2.2.0)
7
7
  rest-client (~> 2.0.0)
@@ -10,20 +10,20 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- actionpack (6.0.3.3)
14
- actionview (= 6.0.3.3)
15
- activesupport (= 6.0.3.3)
13
+ actionpack (6.0.3.4)
14
+ actionview (= 6.0.3.4)
15
+ activesupport (= 6.0.3.4)
16
16
  rack (~> 2.0, >= 2.0.8)
17
17
  rack-test (>= 0.6.3)
18
18
  rails-dom-testing (~> 2.0)
19
19
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
20
- actionview (6.0.3.3)
21
- activesupport (= 6.0.3.3)
20
+ actionview (6.0.3.4)
21
+ activesupport (= 6.0.3.4)
22
22
  builder (~> 3.1)
23
23
  erubi (~> 1.4)
24
24
  rails-dom-testing (~> 2.0)
25
25
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
26
- activesupport (6.0.3.3)
26
+ activesupport (6.0.3.4)
27
27
  concurrent-ruby (~> 1.0, >= 1.0.2)
28
28
  i18n (>= 0.7, < 2)
29
29
  minitest (~> 5.1)
@@ -33,7 +33,7 @@ GEM
33
33
  public_suffix (>= 2.0.2, < 5.0)
34
34
  ast (2.4.1)
35
35
  builder (3.2.4)
36
- codecov (0.2.11)
36
+ codecov (0.2.12)
37
37
  json
38
38
  simplecov
39
39
  coderay (1.1.3)
@@ -106,7 +106,7 @@ GEM
106
106
  nenv (~> 0.1)
107
107
  shellany (~> 0.0)
108
108
  parallel (1.19.2)
109
- parser (2.7.1.5)
109
+ parser (2.7.2.0)
110
110
  ast (~> 2.4.1)
111
111
  pry (0.10.4)
112
112
  coderay (~> 1.1.0)
@@ -123,9 +123,9 @@ GEM
123
123
  nokogiri (>= 1.6)
124
124
  rails-html-sanitizer (1.3.0)
125
125
  loofah (~> 2.3)
126
- railties (6.0.3.3)
127
- actionpack (= 6.0.3.3)
128
- activesupport (= 6.0.3.3)
126
+ railties (6.0.3.4)
127
+ actionpack (= 6.0.3.4)
128
+ activesupport (= 6.0.3.4)
129
129
  method_source
130
130
  rake (>= 0.8.7)
131
131
  thor (>= 0.20.3, < 2.0)
@@ -134,7 +134,7 @@ GEM
134
134
  rb-fsevent (0.10.4)
135
135
  rb-inotify (0.10.1)
136
136
  ffi (~> 1.0)
137
- regexp_parser (1.8.1)
137
+ regexp_parser (1.8.2)
138
138
  rest-client (2.0.2)
139
139
  http-cookie (>= 1.0.2, < 2.0)
140
140
  mime-types (>= 1.16, < 4.0)
@@ -153,16 +153,16 @@ GEM
153
153
  diff-lcs (>= 1.2.0, < 2.0)
154
154
  rspec-support (~> 3.9.0)
155
155
  rspec-support (3.9.3)
156
- rubocop (0.92.0)
156
+ rubocop (1.0.0)
157
157
  parallel (~> 1.10)
158
158
  parser (>= 2.7.1.5)
159
159
  rainbow (>= 2.2.2, < 4.0)
160
- regexp_parser (>= 1.7)
160
+ regexp_parser (>= 1.8)
161
161
  rexml
162
- rubocop-ast (>= 0.5.0)
162
+ rubocop-ast (>= 0.6.0)
163
163
  ruby-progressbar (~> 1.7)
164
164
  unicode-display_width (>= 1.4.0, < 2.0)
165
- rubocop-ast (0.7.1)
165
+ rubocop-ast (1.0.0)
166
166
  parser (>= 2.7.1.5)
167
167
  rubocop-rails (2.8.1)
168
168
  activesupport (>= 4.2.0)
@@ -181,7 +181,7 @@ GEM
181
181
  terminal-notifier-guard (1.7.0)
182
182
  thor (1.0.1)
183
183
  thread_safe (0.3.6)
184
- tins (1.25.0)
184
+ tins (1.26.0)
185
185
  sync
186
186
  tzinfo (1.2.7)
187
187
  thread_safe (~> 0.1)
@@ -190,11 +190,10 @@ GEM
190
190
  unf_ext (0.0.7.7)
191
191
  unicode-display_width (1.7.0)
192
192
  vcr (6.0.0)
193
- webmock (3.9.1)
193
+ webmock (3.9.3)
194
194
  addressable (>= 2.3.6)
195
195
  crack (>= 0.3.2)
196
196
  hashdiff (>= 0.4.0, < 2.0.0)
197
- yard (0.9.25)
198
197
  zache (0.12.0)
199
198
  zeitwerk (2.4.0)
200
199
 
@@ -222,7 +221,6 @@ DEPENDENCIES
222
221
  terminal-notifier-guard
223
222
  vcr
224
223
  webmock
225
- yard
226
224
 
227
225
  BUNDLED WITH
228
226
  1.17.3
data/README.md CHANGED
@@ -25,13 +25,7 @@ bundle add auth0
25
25
 
26
26
  ## API Documentation
27
27
 
28
- You can build the API documentation with the following:
29
-
30
- ```bash
31
- bundle exec rake documentation
32
- ```
33
-
34
- To view the generated documentation, open `doc/Auth0/Api.html` .
28
+ https://www.rubydoc.info/gems/auth0
35
29
 
36
30
  ## Management API v2
37
31
 
data/Rakefile CHANGED
@@ -9,28 +9,6 @@ begin
9
9
  desc 'Run Rubocop'
10
10
  RuboCop::RakeTask.new(:rubocop)
11
11
 
12
- require 'yard'
13
- DOC_FILES = ['lib/auth0/api/v2/*.rb', 'lib/auth0/api/authentication_endpoints.rb'].freeze
14
-
15
- desc 'Build Documentation'
16
- YARD::Rake::YardocTask.new(:documentation) do |t|
17
- t.files = DOC_FILES
18
- t.options = ['-p', 'doc_config/templates']
19
- end
20
-
21
- desc 'Publish SDK documentation'
22
- task :publish do
23
- sh 'rake documentation'
24
- sh 'cp -R doc /tmp/ruby-auth0-doc'
25
- sh 'git checkout gh-pages'
26
- sh 'cp -R /tmp/ruby-auth0-doc/* .'
27
- sh 'rm -rf /tmp/ruby-auth0-doc'
28
- sh 'git add .'
29
- sh 'git commit -am "Rebuild documentation"'
30
- sh 'git push origin gh-pages'
31
- sh 'git checkout master'
32
- end
33
-
34
12
  desc 'Run Integration Tests'
35
13
  RSpec::Core::RakeTask.new(:integration) do |t|
36
14
  t.pattern = FileList["spec/integration/**/*#{ENV['PATTERN']}*_spec.rb"]
@@ -32,7 +32,6 @@ Gem::Specification.new do |s|
32
32
  s.add_development_dependency 'rack', '~> 2.1.2'
33
33
  s.add_development_dependency 'simplecov', '~> 0.9'
34
34
  s.add_development_dependency 'faker', '~> 1.4'
35
- s.add_development_dependency 'yard', '~> 0.9.12'
36
35
  s.add_development_dependency 'gem-release', '~> 0.7'
37
36
  s.license = 'MIT'
38
37
  end
@@ -16,12 +16,6 @@
16
16
  .repl_history
17
17
  build/
18
18
 
19
- ## Documentation cache and generated files:
20
- /.yardoc/
21
- /_yardoc/
22
- /doc/
23
- /rdoc/
24
-
25
19
  ## Environment normalisation:
26
20
  /.bundle/
27
21
  /vendor/bundle
@@ -27,7 +27,7 @@ module Auth0
27
27
  audience: audience
28
28
  }
29
29
  response = post('/oauth/token', request_params)
30
- ApiToken.new(response['access_token'], response['scope'], response['expires_in'])
30
+ ::Auth0::ApiToken.new(response['access_token'], response['scope'], response['expires_in'])
31
31
  end
32
32
 
33
33
  # Get access and ID tokens using an Authorization Code.
@@ -37,7 +37,7 @@ module Auth0
37
37
  # Required only if it was set at the GET /authorize endpoint
38
38
  # @param client_id [string] Client ID for the Application
39
39
  # @param client_secret [string] Client Secret for the Application.
40
- # @return [AccessToken] Returns the access_token and id_token
40
+ # @return [Auth0::AccessToken] Returns the access_token and id_token
41
41
  def exchange_auth_code_for_tokens(
42
42
  code,
43
43
  redirect_uri: nil,
@@ -53,7 +53,7 @@ module Auth0
53
53
  code: code,
54
54
  redirect_uri: redirect_uri
55
55
  }
56
- AccessToken.from_response post('/oauth/token', request_params)
56
+ ::Auth0::AccessToken.from_response post('/oauth/token', request_params)
57
57
  end
58
58
 
59
59
  # Get access and ID tokens using a refresh token.
@@ -64,7 +64,7 @@ module Auth0
64
64
  # @param client_secret [string] Client Secret for the Application.
65
65
  # Required when the Application's Token Endpoint Authentication Method
66
66
  # is Post or Basic.
67
- # @return [AccessToken] Returns tokens allowed in the refresh_token
67
+ # @return [Auth0::AccessToken] Returns tokens allowed in the refresh_token
68
68
  def exchange_refresh_token(
69
69
  refresh_token,
70
70
  client_id: @client_id,
@@ -78,7 +78,7 @@ module Auth0
78
78
  client_secret: client_secret,
79
79
  refresh_token: refresh_token
80
80
  }
81
- AccessToken.from_response post('/oauth/token', request_params)
81
+ ::Auth0::AccessToken.from_response post('/oauth/token', request_params)
82
82
  end
83
83
 
84
84
  # rubocop:disable Metrics/ParameterLists
@@ -118,7 +118,7 @@ module Auth0
118
118
  audience: audience,
119
119
  grant_type: realm ? 'http://auth0.com/oauth/grant-type/password-realm' : 'password'
120
120
  }
121
- AccessToken.from_response post('/oauth/token', request_params)
121
+ ::Auth0::AccessToken.from_response post('/oauth/token', request_params)
122
122
  end
123
123
  # rubocop:enable Metrics/ParameterLists
124
124
 
@@ -292,220 +292,6 @@ module Auth0
292
292
  )
293
293
  end
294
294
 
295
- #
296
- # DEPRECATED
297
- #
298
-
299
- # Retrieve an access token.
300
- # @deprecated 4.6.0 - Use the api_token method instead.
301
- # @see https://auth0.com/docs/api/authentication#client-credentials
302
- # @param access_token [string] Social provider's access_token
303
- # @param connection [string] Currently, this endpoint only works for Facebook, Google, Twitter and Weibo
304
- # @return [json] Returns the access token
305
- def obtain_access_token(access_token = nil, connection = 'facebook', scope = 'openid')
306
- if access_token
307
- request_params = { client_id: @client_id, access_token: access_token, connection: connection, scope: scope }
308
- post('/oauth/access_token', request_params)['access_token']
309
- else
310
- request_params = { client_id: @client_id, client_secret: @client_secret, grant_type: 'client_credentials' }
311
- post('/oauth/token', request_params)['access_token']
312
- end
313
- end
314
-
315
- # Get access and ID tokens using an Authorization Code.
316
- # @deprecated 4.6.0 - Use the exchange_auth_code_for_tokens method instead.
317
- # @see https://auth0.com/docs/api/authentication#authorization-code
318
- # @param code [string] The access code obtained through passive authentication
319
- # @param redirect_uri [string] Url to redirect after authorization
320
- # @param connection [string] Currently, this endpoint only works for Facebook, Google, Twitter and Weibo
321
- # @param scope [string] Defaults to openid. Can be 'openid name email', 'openid offline_access'
322
- # @return [json] Returns the access_token and id_token
323
- def obtain_user_tokens(code, redirect_uri, connection = 'facebook', scope = 'openid')
324
- raise Auth0::InvalidParameter, 'Must supply a valid code' if code.to_s.empty?
325
- raise Auth0::InvalidParameter, 'Must supply a valid redirect_uri' if redirect_uri.to_s.empty?
326
-
327
- request_params = {
328
- client_id: @client_id,
329
- client_secret: @client_secret,
330
- connection: connection,
331
- grant_type: 'authorization_code',
332
- code: code,
333
- scope: scope,
334
- redirect_uri: redirect_uri
335
- }
336
- post('/oauth/token', request_params)
337
- end
338
-
339
- # Get access and ID tokens using Resource Owner Password.
340
- # @deprecated 4.6.0 - Use the login_with_resource_owner method instead.
341
- # @see https://auth0.com/docs/api/authentication#resource-owner-password
342
- # @param username [string] Username or email
343
- # @param password [string] Password
344
- # @param id_token [string] Token's id
345
- # @param connection_name [string] Connection name; use a database or
346
- # passwordless connection, Active Directory/LDAP, Windows Azure or ADF
347
- # @param options [hash] Additional options - :scope, :grant_type, :device
348
- # @return [json] Returns the access_token and id_token
349
- def login(username, password, id_token = nil, connection_name = UP_AUTH, options = {})
350
- raise Auth0::InvalidParameter, 'Must supply a valid username' if username.to_s.empty?
351
- raise Auth0::InvalidParameter, 'Must supply a valid password' if password.to_s.empty?
352
-
353
- request_params = {
354
- client_id: @client_id,
355
- client_secret: @client_secret,
356
- username: username,
357
- password: password,
358
- scope: options.fetch(:scope, 'openid'),
359
- connection: connection_name,
360
- grant_type: options.fetch(:grant_type, 'password'),
361
- id_token: id_token,
362
- device: options.fetch(:device, nil)
363
- }
364
- post('/oauth/token', request_params)
365
- end
366
-
367
- # Return the user information based on the Auth0 access token.
368
- # @deprecated 4.6.0 - Use the userinfo method instead.
369
- # @see https://auth0.com/docs/api/authentication#get-user-info
370
- # @return [json] User information based on the Auth0 access token
371
- def user_info
372
- get('/userinfo')
373
- end
374
-
375
- # Login using phone number + verification code.
376
- # @deprecated 4.5.0 - Legacy authentication pipeline; use a Password Grant
377
- # instead - https://auth0.com/docs/api-auth/tutorials/password-grant
378
- # @see https://auth0.com/docs/api/authentication#resource-owner
379
- # @param phone_number [string] User's phone number.
380
- # @param code [string] Verification code.
381
- # @return [json] Returns the access token and id token
382
- def phone_login(phone_number, code, scope = 'openid')
383
- raise Auth0::InvalidParameter, 'Must supply a valid phone number' if phone_number.to_s.empty?
384
- raise Auth0::InvalidParameter, 'Must supply a valid code' if code.to_s.empty?
385
-
386
- request_params = {
387
- client_id: @client_id,
388
- username: phone_number,
389
- password: code,
390
- scope: scope,
391
- connection: 'sms',
392
- grant_type: 'password'
393
- }
394
- post('/oauth/ro', request_params)
395
- end
396
-
397
- # Validate a JSON Web Token (signature and expiration).
398
- # @deprecated 4.5.0 - Legacy endpoint, use /userinfo instead.
399
- # @see https://auth0.com/docs/api/authentication#get-token-info
400
- # @param id_token [string] ID Token to use
401
- # @return User information associated with the user id (sub property) of the token.
402
- def token_info(id_token)
403
- raise Auth0::InvalidParameter, 'Must supply a valid id_token' if id_token.to_s.empty?
404
-
405
- request_params = { id_token: id_token }
406
- post('/tokeninfo', request_params)
407
- end
408
-
409
- # Refresh a delegation token.
410
- # @deprecated 4.5.0 - Feature is disabled, no replacement currently; see
411
- # https://auth0.com/docs/api-auth/tutorials/adoption/delegation
412
- # @see https://auth0.com/docs/api/authentication#delegation
413
- # @param refresh_token [string] Token to refresh
414
- # @param target [string] Target to sign the new token.
415
- # @param scope [string] Defaults to openid. Can be 'openid name email'.
416
- # @param api_type [string] Defaults to app. Can be aws, azure_sb, azure_blob, firebase, layer, salesforce_api,
417
- # salesforce_sandbox_api, sap_api or wams
418
- # @param extra_parameters [hash] Extra parameters.
419
- # @return [json] Returns the refreshed delegation token
420
- def refresh_delegation(refresh_token, target, scope = 'openid', api_type = 'app', extra_parameters = {})
421
- raise Auth0::InvalidParameter, 'Must supply a valid token to refresh' if refresh_token.to_s.empty?
422
-
423
- request_params = {
424
- client_id: @client_id,
425
- grant_type: JWT_BEARER,
426
- refresh_token: refresh_token,
427
- target: target,
428
- api_type: api_type,
429
- scope: scope
430
- }.merge(extra_parameters)
431
- post('/delegation', request_params)
432
- end
433
-
434
- # Retrieve a delegation token.
435
- # @deprecated 4.5.0 - Feature is disabled, no replacement currently; see
436
- # https://auth0.com/docs/api-auth/tutorials/adoption/delegation
437
- # @see https://auth0.com/docs/api/authentication#delegation
438
- # @param id_token [string] Token's id.
439
- # @param target [string] Target to sign the new token.
440
- # @param scope [string] Defaults to openid. Can be 'openid name email'.
441
- # @param api_type [string] Defaults to app. Can be aws, azure_sb, azure_blob, firebase, layer, salesforce_api,
442
- # salesforce_sandbox_api, sap_api or wams
443
- # @param extra_parameters [hash] Extra parameters.
444
- # @return [json] Returns the refreshed delegation token
445
- def delegation(id_token, target, scope = 'openid', api_type = 'app', extra_parameters = {})
446
- raise Auth0::InvalidParameter, 'Must supply a valid id_token' if id_token.to_s.empty?
447
-
448
- request_params = {
449
- client_id: @client_id,
450
- grant_type: JWT_BEARER,
451
- id_token: id_token,
452
- target: target,
453
- api_type: api_type,
454
- scope: scope
455
- }.merge(extra_parameters)
456
- post('/delegation', request_params)
457
- end
458
-
459
- # Retrieve an impersonation URL to login as another user.
460
- # @deprecated 4.5.0 - Feature is disabled.
461
- # @see https://auth0.com/docs/api/authentication#impersonation
462
- # @param user_id [string] Impersonate user id
463
- # @param app_client_id [string] Application client id
464
- # @param impersonator_id [string] Impersonator user id id.
465
- # @param options [string] Additional Parameters
466
- # @return [string] Impersonation URL
467
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
468
- def impersonate(user_id, app_client_id, impersonator_id, options)
469
- raise Auth0::InvalidParameter, 'Must supply a valid user_id' if user_id.to_s.empty?
470
- raise Auth0::InvalidParameter, 'Must supply a valid app_client_id' if app_client_id.to_s.empty?
471
- raise Auth0::InvalidParameter, 'Must supply a valid impersonator_id' if impersonator_id.to_s.empty?
472
- raise Auth0::MissingParameter, 'Must supply client_secret' if @client_secret.nil?
473
-
474
- authorization_header obtain_access_token
475
- request_params = {
476
- protocol: options.fetch(:protocol, 'oauth2'),
477
- impersonator_id: impersonator_id,
478
- client_id: app_client_id,
479
- additionalParameters: {
480
- response_type: options.fetch(:response_type, 'code'),
481
- state: options.fetch(:state, ''),
482
- scope: options.fetch(:scope, 'openid'),
483
- callback_url: options.fetch(:callback_url, '')
484
- }
485
- }
486
- result = post("/users/#{user_id}/impersonate", request_params)
487
- authorization_header @token
488
- result
489
- end
490
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
491
-
492
- # Unlink a user's account from the identity provider.
493
- # @deprecated 4.5.0 - Endpoint is disabled in favor of the Management API;
494
- # see https://auth0.com/docs/migrations/guides/account-linking
495
- # @see https://auth0.com/docs/api/authentication#unlink
496
- # @param access_token [string] Logged-in user access token
497
- # @param user_id [string] User Id
498
- def unlink_user(access_token, user_id)
499
- raise Auth0::InvalidParameter, 'Must supply a valid access_token' if access_token.to_s.empty?
500
- raise Auth0::InvalidParameter, 'Must supply a valid user_id' if user_id.to_s.empty?
501
-
502
- request_params = {
503
- access_token: access_token,
504
- user_id: user_id
505
- }
506
- post('/unlink', request_params)
507
- end
508
-
509
295
  # Validate an ID token (signature and expiration).
510
296
  # @see https://auth0.com/docs/tokens/guides/validate-id-tokens
511
297
  # @param id_token [string] The JWT to validate.