auth0 5.1.2 → 5.5.0
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.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/CHANGELOG.md +44 -0
- data/README.md +1 -0
- data/auth0.gemspec +7 -6
- data/lib/auth0/api/v2/branding.rb +0 -1
- data/lib/auth0/api/v2/connections.rb +5 -2
- data/lib/auth0/api/v2/device_credentials.rb +3 -3
- data/lib/auth0/api/v2/logs.rb +2 -2
- data/lib/auth0/api/v2/organizations.rb +19 -3
- data/lib/auth0/api/v2/roles.rb +7 -3
- data/lib/auth0/mixins/httpproxy.rb +71 -33
- data/lib/auth0/mixins/initializer.rb +1 -0
- data/lib/auth0/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/_filters/should_exclude_the_fields_indicated.yml +38 -26
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/_filters/should_include_the_fields_indicated.yml +38 -24
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/should_find_the_correct_connection.yml +38 -26
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_include_previously-created_connection_when_filtered.yml +41 -21
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_should_exclude_the_fields_indicated_from_filtered_results.yml +41 -21
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_should_include_the_fields_indicated_from_filtered_results.yml +41 -21
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/should_include_the_previously_created_connection.yml +41 -21
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/should_not_be_empty.yml +41 -21
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_delete_connection/should_delete_the_connection.yml +45 -24
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_delete_connection_user/should_delete_the_user_created.yml +75 -39
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_update_connection/should_update_the_connection.yml +39 -28
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/create_test_connection.yml +37 -25
- data/spec/lib/auth0/api/v2/connections_spec.rb +1 -1
- data/spec/lib/auth0/api/v2/device_credentials_spec.rb +2 -2
- data/spec/lib/auth0/api/v2/organizations_spec.rb +31 -6
- data/spec/lib/auth0/api/v2/roles_spec.rb +5 -1
- data/spec/lib/auth0/mixins/httpproxy_spec.rb +216 -25
- data/spec/lib/auth0/mixins/initializer_spec.rb +7 -0
- data/spec/support/dummy_class_for_proxy.rb +1 -2
- metadata +32 -23
- data/.yardoc/checksums +0 -22
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a3d59041ebfdd2dfcbc326ea1ea9e416796afd2818607014757d90266ed16c07
|
|
4
|
+
data.tar.gz: e9e950591d2027fc475fa437f144dea929a724eeea94bd9491b0a0af5095b271
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f6733b62fa9839d0c03f4a9b641c5f86ffd3a47b7961d76156881f95f34a5ca0cf63c765fccc124418affaca78f34d72e899d5592eddf690f18d4d939b3f9fe
|
|
7
|
+
data.tar.gz: b9bf5d5f1e570a595388fbd3555ca23d6964c6a445d150b233f51dd2a19da30ef4a906825567da350a6411adbdee0a2af562953a3034e41f0c714a0ad0a4d04a
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## [v5.5.0](https://github.com/auth0/ruby-auth0/tree/v5.5.0) (2021-08-06)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://github.com/auth0/ruby-auth0/compare/v5.4.0..v5.5.0)
|
|
6
|
+
|
|
7
|
+
**Added**
|
|
8
|
+
|
|
9
|
+
- Automatically retry requests when API returns a 429 rate-limit status header. [\#290](https://github.com/auth0/ruby-auth0/pull/290) ([davidpatrick](https://github.com/davidpatrick))
|
|
10
|
+
|
|
11
|
+
## [v5.4.0](https://github.com/auth0/ruby-auth0/tree/v5.4.0) (2021-07-23)
|
|
12
|
+
|
|
13
|
+
[Full Changelog](https://github.com/auth0/ruby-auth0/compare/v5.3.0..v5.4.0)
|
|
14
|
+
|
|
15
|
+
**Fixed**
|
|
16
|
+
|
|
17
|
+
- Fixing yard issues with documentation [\#288](https://github.com/auth0/ruby-auth0/pull/288) ([davidpatrick](https://github.com/davidpatrick))
|
|
18
|
+
|
|
19
|
+
**Changed**
|
|
20
|
+
|
|
21
|
+
- Change strategy when normalizing path [\#287](https://github.com/auth0/ruby-auth0/pull/287) ([davidpatrick](https://github.com/davidpatrick))
|
|
22
|
+
|
|
23
|
+
## [v5.3.0](https://github.com/auth0/ruby-auth0/tree/v5.3.0) (2021-07-23)
|
|
24
|
+
|
|
25
|
+
[Full Changelog](https://github.com/auth0/ruby-auth0/compare/v5.2.0..v5.3.0)
|
|
26
|
+
|
|
27
|
+
**Added**
|
|
28
|
+
|
|
29
|
+
- Checkpoint Pagination [\#284](https://github.com/auth0/ruby-auth0/pull/284) ([davidpatrick](https://github.com/davidpatrick))
|
|
30
|
+
|
|
31
|
+
## [v5.2.0](https://github.com/auth0/ruby-auth0/tree/v5.2.0) (2021-07-20)
|
|
32
|
+
|
|
33
|
+
[Full Changelog](https://github.com/auth0/ruby-auth0/compare/v5.1.2..v5.2.0)
|
|
34
|
+
|
|
35
|
+
**Fixed**
|
|
36
|
+
|
|
37
|
+
- Ensure email param is properly encoded in delete_connection_user [\#280](https://github.com/auth0/ruby-auth0/pull/280) ([widcket](https://github.com/widcket))
|
|
38
|
+
|
|
39
|
+
**Added**
|
|
40
|
+
|
|
41
|
+
- Adds Rotating Refresh Token type to Device Credentials [\#275](https://github.com/auth0/ruby-auth0/pull/275) ([epintos](https://github.com/epintos))
|
|
42
|
+
|
|
43
|
+
**Changed**
|
|
44
|
+
|
|
45
|
+
- Do not lock dependencies to minor version [\#279](https://github.com/auth0/ruby-auth0/pull/279) ([athix](https://github.com/athix))
|
|
46
|
+
|
|
3
47
|
## [v5.1.2](https://github.com/auth0/ruby-auth0/tree/v5.1.2) (2021-07-15)
|
|
4
48
|
|
|
5
49
|
[Full Changelog](https://github.com/auth0/ruby-auth0/compare/v5.1.1..v5.1.2)
|
data/README.md
CHANGED
|
@@ -234,6 +234,7 @@ begin
|
|
|
234
234
|
rescue Auth0::InvalidIdToken => e
|
|
235
235
|
# In this case the ID Token contents should not be trusted
|
|
236
236
|
end
|
|
237
|
+
```
|
|
237
238
|
|
|
238
239
|
For more information, please read [Work with Tokens and Organizations](https://auth0.com/docs/organizations/using-tokens) on Auth0 Docs.
|
|
239
240
|
|
data/auth0.gemspec
CHANGED
|
@@ -16,10 +16,11 @@ Gem::Specification.new do |s|
|
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
17
17
|
s.require_paths = ['lib']
|
|
18
18
|
|
|
19
|
-
s.add_runtime_dependency 'rest-client', '~> 2.0.0
|
|
20
|
-
s.add_runtime_dependency 'jwt', '~> 2.2
|
|
21
|
-
s.add_runtime_dependency 'zache', '~> 0.12
|
|
22
|
-
s.add_runtime_dependency 'addressable', '~> 2.8
|
|
19
|
+
s.add_runtime_dependency 'rest-client', '~> 2.0.2' #2.1.0 has breaking changes
|
|
20
|
+
s.add_runtime_dependency 'jwt', '~> 2.2'
|
|
21
|
+
s.add_runtime_dependency 'zache', '~> 0.12'
|
|
22
|
+
s.add_runtime_dependency 'addressable', '~> 2.8'
|
|
23
|
+
s.add_runtime_dependency 'retryable', '~> 3.0'
|
|
23
24
|
|
|
24
25
|
s.add_development_dependency 'bundler'
|
|
25
26
|
s.add_development_dependency 'rake', '~> 13.0'
|
|
@@ -27,10 +28,10 @@ Gem::Specification.new do |s|
|
|
|
27
28
|
s.add_development_dependency 'guard-rspec', '~> 4.5' unless ENV['CIRCLECI']
|
|
28
29
|
s.add_development_dependency 'dotenv-rails', '~> 2.0'
|
|
29
30
|
s.add_development_dependency 'pry', '~> 0.10'
|
|
30
|
-
s.add_development_dependency 'pry-nav', '~> 0.2
|
|
31
|
+
s.add_development_dependency 'pry-nav', '~> 0.2'
|
|
31
32
|
s.add_development_dependency 'rspec', '~> 3.5'
|
|
32
33
|
s.add_development_dependency 'rack-test', '~> 0.6'
|
|
33
|
-
s.add_development_dependency 'rack', '~> 2.1
|
|
34
|
+
s.add_development_dependency 'rack', '~> 2.1'
|
|
34
35
|
s.add_development_dependency 'simplecov', '~> 0.9'
|
|
35
36
|
s.add_development_dependency 'faker', '~> 2.0'
|
|
36
37
|
s.add_development_dependency 'gem-release', '~> 0.7'
|
|
@@ -35,7 +35,6 @@ module Auth0
|
|
|
35
35
|
|
|
36
36
|
# Delete template for New Universal Login Experience
|
|
37
37
|
# @see https://auth0.com/docs/api/management/v2/#!/Branding/delete_universal_login
|
|
38
|
-
# @param rule_id [string] The id of the rule to delete.
|
|
39
38
|
def delete_branding_templates_for_universal_login
|
|
40
39
|
delete(templates_path)
|
|
41
40
|
end
|
|
@@ -81,8 +81,11 @@ module Auth0
|
|
|
81
81
|
def delete_connection_user(connection_id, user_email)
|
|
82
82
|
raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
|
|
83
83
|
raise Auth0::InvalidParameter, 'Must supply a valid user email' if user_email.to_s.empty?
|
|
84
|
-
path = "#{connections_path}/#{connection_id}/users
|
|
85
|
-
|
|
84
|
+
path = "#{connections_path}/#{connection_id}/users"
|
|
85
|
+
request_params = {
|
|
86
|
+
email: user_email
|
|
87
|
+
}
|
|
88
|
+
delete(path, request_params)
|
|
86
89
|
end
|
|
87
90
|
|
|
88
91
|
# Updates a connection. Updates the fields specified in the body parameter.
|
|
@@ -12,7 +12,7 @@ module Auth0
|
|
|
12
12
|
# * :fields [string] A comma separated list of fields to include or exclude from the result.
|
|
13
13
|
# * :include_fields [boolean] True if the fields specified are to be included in the result, false otherwise.
|
|
14
14
|
# * :user_id [string] The user_id of the devices to retrieve.
|
|
15
|
-
# * :type [string]
|
|
15
|
+
# * :type [string] Type of credentials to retrieve. Must be 'public_key', 'refresh_token' or 'rotating_refresh_token'
|
|
16
16
|
#
|
|
17
17
|
# @return [json] Returns the list of existing devices for the specified client_id.
|
|
18
18
|
# rubocop:disable Metrics/AbcSize
|
|
@@ -25,8 +25,8 @@ module Auth0
|
|
|
25
25
|
type: options.fetch(:type, nil)
|
|
26
26
|
}
|
|
27
27
|
raise Auth0::InvalidParameter, 'Must supply a valid client_id' if client_id.to_s.empty?
|
|
28
|
-
if !request_params[:type].nil? && !%w(public_key refresh_token).include?(request_params[:type])
|
|
29
|
-
raise Auth0::InvalidParameter, 'Type must be one of \'public_key\', \'refresh_token\''
|
|
28
|
+
if !request_params[:type].nil? && !%w(public_key refresh_token rotating_refresh_token).include?(request_params[:type])
|
|
29
|
+
raise Auth0::InvalidParameter, 'Type must be one of \'public_key\', \'refresh_token\', \'rotating_refresh_token\''
|
|
30
30
|
end
|
|
31
31
|
get(device_credentials_path, request_params)
|
|
32
32
|
end
|
data/lib/auth0/api/v2/logs.rb
CHANGED
|
@@ -16,8 +16,8 @@ module Auth0
|
|
|
16
16
|
# * :fields [string] A comma separated list of fields to include or exclude from the result.
|
|
17
17
|
# * :include_fields [boolean] True if the fields specified are to be included in the result, false otherwise.
|
|
18
18
|
# * :include_totals [string] True if a query summary must be included in the result, false otherwise.
|
|
19
|
-
# * :from [string]
|
|
20
|
-
# * :take [integer]
|
|
19
|
+
# * :from [string] For checkpoint pagination, the ID from which to start selection from.
|
|
20
|
+
# * :take [integer] For checkpoint pagination, the number of entries to retrieve. Default is 50.
|
|
21
21
|
# Default: 50. Max value: 100.
|
|
22
22
|
#
|
|
23
23
|
# @return [json] Returns the list of existing log entries.
|
|
@@ -12,12 +12,16 @@ module Auth0
|
|
|
12
12
|
# @param options [hash] The Hash options used to define the paging of rersults
|
|
13
13
|
# * :per_page [integer] The amount of entries per page. Default: 50. Max value: 100.
|
|
14
14
|
# * :page [integer] The page number. Zero based.
|
|
15
|
+
# * :from [string] For checkpoint pagination, the ID from which to start selection from.
|
|
16
|
+
# * :take [integer] For checkpoint pagination, the number of entries to retrieve. Default is 50.
|
|
15
17
|
# * :include_totals [boolean] True to include query summary in the result, false or nil otherwise.
|
|
16
18
|
# @return [json] All Organizations
|
|
17
19
|
def organizations(options = {})
|
|
18
20
|
request_params = {
|
|
19
21
|
per_page: options.fetch(:per_page, nil),
|
|
20
22
|
page: options.fetch(:page, nil),
|
|
23
|
+
from: options.fetch(:from, nil),
|
|
24
|
+
take: options.fetch(:take, nil),
|
|
21
25
|
include_totals: options.fetch(:include_totals, nil)
|
|
22
26
|
}
|
|
23
27
|
get(organizations_path, request_params)
|
|
@@ -212,13 +216,25 @@ module Auth0
|
|
|
212
216
|
# Get Members in a Organization
|
|
213
217
|
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_members
|
|
214
218
|
# @param organization_id [string] The Organization ID
|
|
215
|
-
# @param
|
|
219
|
+
# @param options [hash] The Hash options used to define the paging of rersults
|
|
220
|
+
# * :per_page [integer] The amount of entries per page. Default: 50. Max value: 100.
|
|
221
|
+
# * :page [integer] The page number. Zero based.
|
|
222
|
+
# * :from [string] For checkpoint pagination, the ID from which to start selection from.
|
|
223
|
+
# * :take [integer] For checkpoint pagination, the number of entries to retrieve. Default is 50.
|
|
224
|
+
# * :include_totals [boolean] True to include query summary in the result, false or nil otherwise.
|
|
216
225
|
#
|
|
217
226
|
# @return [json] Returns the members for the given organization
|
|
218
|
-
def get_organizations_members(organization_id)
|
|
227
|
+
def get_organizations_members(organization_id, options = {})
|
|
219
228
|
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
|
229
|
+
request_params = {
|
|
230
|
+
per_page: options.fetch(:per_page, nil),
|
|
231
|
+
page: options.fetch(:page, nil),
|
|
232
|
+
from: options.fetch(:from, nil),
|
|
233
|
+
take: options.fetch(:take, nil),
|
|
234
|
+
include_totals: options.fetch(:include_totals, nil)
|
|
235
|
+
}
|
|
220
236
|
path = "#{organizations_members_path(organization_id)}"
|
|
221
|
-
get(path)
|
|
237
|
+
get(path, request_params)
|
|
222
238
|
end
|
|
223
239
|
|
|
224
240
|
# Add members in an organization
|
data/lib/auth0/api/v2/roles.rb
CHANGED
|
@@ -87,13 +87,17 @@ module Auth0
|
|
|
87
87
|
# @param options [hash] A hash of options for getting Roles
|
|
88
88
|
# - per_page: Number of Roles to return.
|
|
89
89
|
# - page: Page number to return, zero-based.
|
|
90
|
-
#
|
|
90
|
+
# * :from [string] For checkpoint pagination, the ID from which to start selection from.
|
|
91
|
+
# * :take [integer] For checkpoint pagination, the number of entries to retrieve. Default is 50.
|
|
92
|
+
# * :include_totals [boolean] True to include query summary in the result, false or nil otherwise.
|
|
91
93
|
def get_role_users(role_id, options = {})
|
|
92
94
|
raise Auth0::MissingParameter, 'Must supply a valid role_id' if role_id.to_s.empty?
|
|
93
95
|
|
|
94
96
|
request_params = {
|
|
95
|
-
per_page:
|
|
96
|
-
page:
|
|
97
|
+
per_page: options.fetch(:per_page, nil),
|
|
98
|
+
page: options.fetch(:page, nil),
|
|
99
|
+
from: options.fetch(:from, nil),
|
|
100
|
+
take: options.fetch(:take, nil),
|
|
97
101
|
include_totals: options.fetch(:include_totals, nil)
|
|
98
102
|
}
|
|
99
103
|
get "#{roles_path}/#{role_id}/users", request_params
|
|
@@ -1,51 +1,54 @@
|
|
|
1
1
|
require "addressable/uri"
|
|
2
|
+
require "retryable"
|
|
3
|
+
require_relative "../exception.rb"
|
|
2
4
|
|
|
3
5
|
module Auth0
|
|
4
6
|
module Mixins
|
|
5
7
|
# here's the proxy for Rest calls based on rest-client, we're building all request on that gem
|
|
6
8
|
# for now, if you want to feel free to use your own http client
|
|
7
9
|
module HTTPProxy
|
|
8
|
-
attr_accessor :headers, :base_uri, :timeout
|
|
10
|
+
attr_accessor :headers, :base_uri, :timeout, :retry_count
|
|
11
|
+
DEAFULT_RETRIES = 3
|
|
12
|
+
MAX_ALLOWED_RETRIES = 10
|
|
13
|
+
MAX_REQUEST_RETRY_JITTER = 250
|
|
14
|
+
MAX_REQUEST_RETRY_DELAY = 1000
|
|
15
|
+
MIN_REQUEST_RETRY_DELAY = 100
|
|
9
16
|
|
|
10
17
|
# proxying requests from instance methods to HTTP class methods
|
|
11
18
|
%i(get post post_file put patch delete delete_with_body).each do |method|
|
|
12
|
-
define_method(method) do |
|
|
13
|
-
safe_path = Addressable::URI.escape(path)
|
|
19
|
+
define_method(method) do |uri, body = {}, extra_headers = {}|
|
|
14
20
|
body = body.delete_if { |_, v| v.nil? }
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# Merge custom headers into existing ones for this req.
|
|
19
|
-
# This prevents future calls from using them.
|
|
20
|
-
get_headers = headers.merge extra_headers
|
|
21
|
-
# Make the call with extra_headers, if provided.
|
|
22
|
-
call(:get, url(safe_path), timeout, get_headers)
|
|
23
|
-
elsif method == :delete
|
|
24
|
-
call(:delete, url(safe_path), timeout, add_headers({params: body}))
|
|
25
|
-
elsif method == :delete_with_body
|
|
26
|
-
call(:delete, url(safe_path), timeout, headers, body.to_json)
|
|
27
|
-
elsif method == :post_file
|
|
28
|
-
body.merge!(multipart: true)
|
|
29
|
-
# Ignore the default Content-Type headers and let the HTTP client define them
|
|
30
|
-
post_file_headers = headers.slice(*headers.keys - ['Content-Type'])
|
|
31
|
-
# Actual call with the altered headers
|
|
32
|
-
call(:post, url(safe_path), timeout, post_file_headers, body)
|
|
33
|
-
else
|
|
34
|
-
call(method, url(safe_path), timeout, headers, body.to_json)
|
|
35
|
-
end
|
|
36
|
-
case result.code
|
|
37
|
-
when 200...226 then safe_parse_json(result.body)
|
|
38
|
-
when 400 then raise Auth0::BadRequest.new(result.body, code: result.code, headers: result.headers)
|
|
39
|
-
when 401 then raise Auth0::Unauthorized.new(result.body, code: result.code, headers: result.headers)
|
|
40
|
-
when 403 then raise Auth0::AccessDenied.new(result.body, code: result.code, headers: result.headers)
|
|
41
|
-
when 404 then raise Auth0::NotFound.new(result.body, code: result.code, headers: result.headers)
|
|
42
|
-
when 429 then raise Auth0::RateLimitEncountered.new(result.body, code: result.code, headers: result.headers)
|
|
43
|
-
when 500 then raise Auth0::ServerError.new(result.body, code: result.code, headers: result.headers)
|
|
44
|
-
else raise Auth0::Unsupported.new(result.body, code: result.code, headers: result.headers)
|
|
21
|
+
|
|
22
|
+
Retryable.retryable(retry_options) do
|
|
23
|
+
request(method, uri, body, extra_headers)
|
|
45
24
|
end
|
|
46
25
|
end
|
|
47
26
|
end
|
|
48
27
|
|
|
28
|
+
def retry_options
|
|
29
|
+
sleep_timer = lambda do |attempt|
|
|
30
|
+
wait = 1000 * 2**attempt # Exponential delay with each subsequent request attempt.
|
|
31
|
+
wait += rand(wait..wait+MAX_REQUEST_RETRY_JITTER) # Add jitter to the delay window.
|
|
32
|
+
wait = [MAX_REQUEST_RETRY_DELAY, wait].min # Cap delay at MAX_REQUEST_RETRY_DELAY.
|
|
33
|
+
wait = [MIN_REQUEST_RETRY_DELAY, wait].max # Ensure delay is no less than MIN_REQUEST_RETRY_DELAY.
|
|
34
|
+
wait / 1000.to_f.round(2) # convert ms to seconds
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
tries = 1 + [Integer(retry_count || DEAFULT_RETRIES), MAX_ALLOWED_RETRIES].min # Cap retries at MAX_ALLOWED_RETRIES
|
|
38
|
+
|
|
39
|
+
{
|
|
40
|
+
tries: tries,
|
|
41
|
+
sleep: sleep_timer,
|
|
42
|
+
on: Auth0::RateLimitEncountered
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def encode_uri(uri)
|
|
47
|
+
# if a base_uri is set then the uri can be encoded as a path
|
|
48
|
+
path = base_uri ? Addressable::URI.new(path: uri).normalized_path : Addressable::URI.escape(uri)
|
|
49
|
+
url(path)
|
|
50
|
+
end
|
|
51
|
+
|
|
49
52
|
def url(path)
|
|
50
53
|
"#{base_uri}#{path}"
|
|
51
54
|
end
|
|
@@ -62,6 +65,41 @@ module Auth0
|
|
|
62
65
|
body
|
|
63
66
|
end
|
|
64
67
|
|
|
68
|
+
def request(method, uri, body, extra_headers)
|
|
69
|
+
result = if method == :get
|
|
70
|
+
# Mutate the headers property to add parameters.
|
|
71
|
+
add_headers({params: body})
|
|
72
|
+
# Merge custom headers into existing ones for this req.
|
|
73
|
+
# This prevents future calls from using them.
|
|
74
|
+
get_headers = headers.merge extra_headers
|
|
75
|
+
# Make the call with extra_headers, if provided.
|
|
76
|
+
call(:get, encode_uri(uri), timeout, get_headers)
|
|
77
|
+
elsif method == :delete
|
|
78
|
+
call(:delete, encode_uri(uri), timeout, add_headers({params: body}))
|
|
79
|
+
elsif method == :delete_with_body
|
|
80
|
+
call(:delete, encode_uri(uri), timeout, headers, body.to_json)
|
|
81
|
+
elsif method == :post_file
|
|
82
|
+
body.merge!(multipart: true)
|
|
83
|
+
# Ignore the default Content-Type headers and let the HTTP client define them
|
|
84
|
+
post_file_headers = headers.slice(*headers.keys - ['Content-Type'])
|
|
85
|
+
# Actual call with the altered headers
|
|
86
|
+
call(:post, encode_uri(uri), timeout, post_file_headers, body)
|
|
87
|
+
else
|
|
88
|
+
call(method, encode_uri(uri), timeout, headers, body.to_json)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
case result.code
|
|
92
|
+
when 200...226 then safe_parse_json(result.body)
|
|
93
|
+
when 400 then raise Auth0::BadRequest.new(result.body, code: result.code, headers: result.headers)
|
|
94
|
+
when 401 then raise Auth0::Unauthorized.new(result.body, code: result.code, headers: result.headers)
|
|
95
|
+
when 403 then raise Auth0::AccessDenied.new(result.body, code: result.code, headers: result.headers)
|
|
96
|
+
when 404 then raise Auth0::NotFound.new(result.body, code: result.code, headers: result.headers)
|
|
97
|
+
when 429 then raise Auth0::RateLimitEncountered.new(result.body, code: result.code, headers: result.headers)
|
|
98
|
+
when 500 then raise Auth0::ServerError.new(result.body, code: result.code, headers: result.headers)
|
|
99
|
+
else raise Auth0::Unsupported.new(result.body, code: result.code, headers: result.headers)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
65
103
|
def call(method, url, timeout, headers, body = nil)
|
|
66
104
|
RestClient::Request.execute(
|
|
67
105
|
method: method,
|
|
@@ -15,6 +15,7 @@ module Auth0
|
|
|
15
15
|
@base_uri = base_url(options)
|
|
16
16
|
@headers = client_headers
|
|
17
17
|
@timeout = options[:timeout] || 10
|
|
18
|
+
@retry_count = options[:retry_count]
|
|
18
19
|
extend Auth0::Api::AuthenticationEndpoints
|
|
19
20
|
@client_id = options[:client_id]
|
|
20
21
|
@client_secret = options[:client_secret]
|
data/lib/auth0/version.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: get
|
|
5
|
-
uri: https://auth0-sdk-tests.auth0.com/api/v2/connections/
|
|
5
|
+
uri: https://auth0-sdk-tests.auth0.com/api/v2/connections/con_n8MJ02x2Zs0JBUWN?fields=name,id&include_fields=false
|
|
6
6
|
body:
|
|
7
7
|
encoding: US-ASCII
|
|
8
8
|
string: ''
|
|
@@ -12,52 +12,64 @@ http_interactions:
|
|
|
12
12
|
Accept-Encoding:
|
|
13
13
|
- gzip, deflate
|
|
14
14
|
User-Agent:
|
|
15
|
-
-
|
|
15
|
+
- rest-client/2.0.2 (darwin20.2.0 x86_64) ruby/2.7.2p137
|
|
16
16
|
Content-Type:
|
|
17
17
|
- application/json
|
|
18
18
|
Auth0-Client:
|
|
19
|
-
-
|
|
19
|
+
- eyJuYW1lIjoicnVieS1hdXRoMCIsInZlcnNpb24iOiI1LjEuMiIsImVudiI6eyJydWJ5IjoiMi43LjIifX0=
|
|
20
20
|
Authorization:
|
|
21
21
|
- Bearer API_TOKEN
|
|
22
|
-
Host:
|
|
23
|
-
- auth0-sdk-tests.auth0.com
|
|
24
22
|
response:
|
|
25
23
|
status:
|
|
26
24
|
code: 200
|
|
27
25
|
message: OK
|
|
28
26
|
headers:
|
|
29
27
|
Date:
|
|
30
|
-
-
|
|
28
|
+
- Tue, 20 Jul 2021 02:14:49 GMT
|
|
31
29
|
Content-Type:
|
|
32
30
|
- application/json; charset=utf-8
|
|
33
31
|
Transfer-Encoding:
|
|
34
32
|
- chunked
|
|
35
33
|
Connection:
|
|
36
34
|
- keep-alive
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
X-Ratelimit-Remaining:
|
|
40
|
-
- '7'
|
|
41
|
-
X-Ratelimit-Reset:
|
|
42
|
-
- '1538770639'
|
|
43
|
-
Vary:
|
|
44
|
-
- origin,accept-encoding
|
|
35
|
+
Cf-Ray:
|
|
36
|
+
- 6718ada05caf0d20-LAX
|
|
45
37
|
Cache-Control:
|
|
46
|
-
-
|
|
38
|
+
- no-cache
|
|
47
39
|
Content-Encoding:
|
|
48
40
|
- gzip
|
|
49
41
|
Strict-Transport-Security:
|
|
50
|
-
- max-age=
|
|
51
|
-
|
|
52
|
-
-
|
|
42
|
+
- max-age=31536000
|
|
43
|
+
Vary:
|
|
44
|
+
- origin,accept-encoding
|
|
45
|
+
Cf-Cache-Status:
|
|
46
|
+
- DYNAMIC
|
|
47
|
+
Expect-Ct:
|
|
48
|
+
- max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
|
|
49
|
+
Ot-Baggage-Auth0-Request-Id:
|
|
50
|
+
- 6718ada05caf0d20
|
|
51
|
+
Ot-Tracer-Sampled:
|
|
52
|
+
- 'true'
|
|
53
|
+
Ot-Tracer-Spanid:
|
|
54
|
+
- 25f1c5cc01ec17ff
|
|
55
|
+
Ot-Tracer-Traceid:
|
|
56
|
+
- 1a4dd66f250d867d
|
|
57
|
+
X-Content-Type-Options:
|
|
58
|
+
- nosniff
|
|
59
|
+
X-Ratelimit-Limit:
|
|
60
|
+
- '50'
|
|
61
|
+
X-Ratelimit-Remaining:
|
|
62
|
+
- '49'
|
|
63
|
+
X-Ratelimit-Reset:
|
|
64
|
+
- '1626747290'
|
|
65
|
+
Server:
|
|
66
|
+
- cloudflare
|
|
67
|
+
Alt-Svc:
|
|
68
|
+
- h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400, h3=":443";
|
|
69
|
+
ma=86400
|
|
53
70
|
body:
|
|
54
71
|
encoding: ASCII-8BIT
|
|
55
72
|
string: !binary |-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
mTBxiML8lQyYrVqIscvUh5gTsddOl+vWF/O07XAm8+PvaqelW7wiuK4ve7Zv
|
|
60
|
-
I/YAAAA=
|
|
61
|
-
http_version:
|
|
62
|
-
recorded_at: Fri, 05 Oct 2018 20:17:17 GMT
|
|
63
|
-
recorded_with: VCR 4.0.0
|
|
73
|
+
H4sIAAAAAAAAAz2PwWrDQAxE/0VnF5xQCvGtFAK9BdqSQAjLei27G9aSkbQpbsi/d5M2PQk0o6eZM/BkkUmhOcPY++vwweIJoTHJWIGgZSGHJJySUzSLNOiveqlg8qpfLN2GUwwzNDAwd1CBmnjDYXYnFC0PoFlW0Eo2dD1LQDcJGwa7SX+s+02h+GyfdcFEdR2PPpILTHT39z5piYbk24SdCykiWcm0h2Wgbc7D07df7xbHesDFZrU6Pn9QvX7cveVXOFwb+TTe3O+o9vLPfZDczlZWcLj8ALzgJBkYAQAA
|
|
74
|
+
recorded_at: Tue, 20 Jul 2021 02:14:49 GMT
|
|
75
|
+
recorded_with: VCR 6.0.0
|