auth0 5.11.0 → 5.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +4 -3
- data/.semgrepignore +6 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile.lock +35 -35
- data/README.md +0 -1
- data/examples/ruby-api/Gemfile.lock +1 -1
- data/lib/auth0/api/authentication_endpoints.rb +37 -0
- data/lib/auth0/api/v2/users.rb +116 -0
- data/lib/auth0/mixins/httpproxy.rb +5 -2
- data/lib/auth0/version.rb +1 -1
- data/spec/lib/auth0/api/authentication_endpoints_spec.rb +92 -2
- data/spec/lib/auth0/api/v2/users_spec.rb +218 -0
- data/spec/lib/auth0/mixins/httpproxy_spec.rb +38 -77
- data/spec/support/dummy_class_for_tokens.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb764cc8daf156b3d3736bff8c65c69c32db6d15757f2e450ea85eb0dca300c0
|
4
|
+
data.tar.gz: b0cfc02df42818062bc5cb609daaffd04806f9ea92f771caf58575b9faa781c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68c6502714f8c631aa92a0b29d387e662cf06b9ec4e18f4d12e3260a7068a5e754b1f29bc60a76b2defa54763919ee9b6e31ffb5181d1c0d38c584bf4d0186a3
|
7
|
+
data.tar.gz: 26a2e83b7aa49807d45cda688d857d8dc93177bdd4a47b92b0e952561a2dbda2a056a15c537b71a787d22ddebb5ebb4fddb9f7e83fb26ce7e769b1c23a49c221
|
data/.circleci/config.yml
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
version: 2.1
|
2
2
|
orbs:
|
3
|
-
ship: auth0/ship@
|
3
|
+
ship: auth0/ship@0
|
4
4
|
codecov: codecov/codecov@3
|
5
5
|
|
6
6
|
matrix_ruby_versions: &matrix_ruby_versions
|
7
7
|
matrix:
|
8
8
|
parameters:
|
9
|
-
ruby_version: ["
|
9
|
+
ruby_version: ["3.0", "3.1", "3.2"]
|
10
10
|
# Default version of ruby to use for lint and publishing
|
11
11
|
default_ruby_version: &default_ruby_version "3.2"
|
12
12
|
|
@@ -41,7 +41,8 @@ jobs:
|
|
41
41
|
- vendor/bundle
|
42
42
|
# Must define DOMAIN, CLIENT_ID, CLIENT_SECRET and MASTER_JWT env
|
43
43
|
- run: bundle exec rake test
|
44
|
-
- codecov/upload
|
44
|
+
- codecov/upload:
|
45
|
+
file: /home/circleci/project/coverage/coverage.xml
|
45
46
|
|
46
47
|
workflows:
|
47
48
|
tests:
|
data/.semgrepignore
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v5.13.0](https://github.com/auth0/ruby-auth0/tree/v5.13.0) (2023-04-24)
|
4
|
+
[Full Changelog](https://github.com/auth0/ruby-auth0/compare/v5.12.0...v5.13.0)
|
5
|
+
|
6
|
+
**Added**
|
7
|
+
- [SDK-4142] Add support for /oauth/par [\#470](https://github.com/auth0/ruby-auth0/pull/470) ([stevehobbsdev](https://github.com/stevehobbsdev))
|
8
|
+
|
9
|
+
**Deprecated**
|
10
|
+
- Drop support for 2.7 in CI build [\#467](https://github.com/auth0/ruby-auth0/pull/467) ([stevehobbsdev](https://github.com/stevehobbsdev))
|
11
|
+
|
12
|
+
## [v5.12.0](https://github.com/auth0/ruby-auth0/tree/v5.12.0) (2023-03-13)
|
13
|
+
[Full Changelog](https://github.com/auth0/ruby-auth0/compare/v5.11.0...v5.12.0)
|
14
|
+
|
15
|
+
**Added**
|
16
|
+
- [SDK-4014] User Authentication Method management API support [\#450](https://github.com/auth0/ruby-auth0/pull/450) ([stevehobbsdev](https://github.com/stevehobbsdev))
|
17
|
+
|
18
|
+
**Fixed**
|
19
|
+
- Remove broken FAQ link from README [\#441](https://github.com/auth0/ruby-auth0/pull/441) ([joxxoxo](https://github.com/joxxoxo))
|
20
|
+
|
3
21
|
## [v5.11.0](https://github.com/auth0/ruby-auth0/tree/v5.11.0) (2023-01-27)
|
4
22
|
[Full Changelog](https://github.com/auth0/ruby-auth0/compare/v5.10.0...v5.11.0)
|
5
23
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
auth0 (5.
|
4
|
+
auth0 (5.13.0)
|
5
5
|
addressable (~> 2.8)
|
6
6
|
jwt (~> 2.5)
|
7
7
|
rest-client (~> 2.1)
|
@@ -11,29 +11,29 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
actionpack (7.0.4.
|
15
|
-
actionview (= 7.0.4.
|
16
|
-
activesupport (= 7.0.4.
|
14
|
+
actionpack (7.0.4.3)
|
15
|
+
actionview (= 7.0.4.3)
|
16
|
+
activesupport (= 7.0.4.3)
|
17
17
|
rack (~> 2.0, >= 2.2.0)
|
18
18
|
rack-test (>= 0.6.3)
|
19
19
|
rails-dom-testing (~> 2.0)
|
20
20
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
21
|
-
actionview (7.0.4.
|
22
|
-
activesupport (= 7.0.4.
|
21
|
+
actionview (7.0.4.3)
|
22
|
+
activesupport (= 7.0.4.3)
|
23
23
|
builder (~> 3.1)
|
24
24
|
erubi (~> 1.4)
|
25
25
|
rails-dom-testing (~> 2.0)
|
26
26
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
27
|
-
activesupport (7.0.4.
|
27
|
+
activesupport (7.0.4.3)
|
28
28
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
29
29
|
i18n (>= 1.6, < 2)
|
30
30
|
minitest (>= 5.1)
|
31
31
|
tzinfo (~> 2.0)
|
32
|
-
addressable (2.8.
|
32
|
+
addressable (2.8.4)
|
33
33
|
public_suffix (>= 2.0.2, < 6.0)
|
34
34
|
ast (2.4.2)
|
35
35
|
builder (3.2.4)
|
36
|
-
concurrent-ruby (1.2.
|
36
|
+
concurrent-ruby (1.2.2)
|
37
37
|
coveralls (0.7.1)
|
38
38
|
multi_json (~> 1.3)
|
39
39
|
rest-client
|
@@ -65,31 +65,31 @@ GEM
|
|
65
65
|
i18n (1.12.0)
|
66
66
|
concurrent-ruby (~> 1.0)
|
67
67
|
io-console (0.6.0)
|
68
|
-
irb (1.6.
|
68
|
+
irb (1.6.4)
|
69
69
|
reline (>= 0.3.0)
|
70
70
|
json (2.6.3)
|
71
|
-
jwt (2.
|
72
|
-
loofah (2.
|
71
|
+
jwt (2.7.0)
|
72
|
+
loofah (2.20.0)
|
73
73
|
crass (~> 1.0.2)
|
74
74
|
nokogiri (>= 1.5.9)
|
75
75
|
method_source (1.0.0)
|
76
76
|
mime-types (3.4.1)
|
77
77
|
mime-types-data (~> 3.2015)
|
78
|
-
mime-types-data (3.
|
79
|
-
minitest (5.
|
78
|
+
mime-types-data (3.2023.0218.1)
|
79
|
+
minitest (5.18.0)
|
80
80
|
multi_json (1.15.0)
|
81
81
|
netrc (0.11.0)
|
82
|
-
nokogiri (1.14.
|
82
|
+
nokogiri (1.14.3-x86_64-linux)
|
83
83
|
racc (~> 1.4)
|
84
|
-
parallel (1.
|
85
|
-
parser (3.2.
|
84
|
+
parallel (1.23.0)
|
85
|
+
parser (3.2.2.1)
|
86
86
|
ast (~> 2.4.1)
|
87
87
|
pp (0.4.0)
|
88
88
|
prettyprint
|
89
89
|
prettyprint (0.1.1)
|
90
90
|
public_suffix (5.0.1)
|
91
91
|
racc (1.6.2)
|
92
|
-
rack (2.2.6.
|
92
|
+
rack (2.2.6.4)
|
93
93
|
rack-test (0.8.3)
|
94
94
|
rack (>= 1.0, < 3)
|
95
95
|
rails-dom-testing (2.0.3)
|
@@ -97,17 +97,17 @@ GEM
|
|
97
97
|
nokogiri (>= 1.6)
|
98
98
|
rails-html-sanitizer (1.5.0)
|
99
99
|
loofah (~> 2.19, >= 2.19.1)
|
100
|
-
railties (7.0.4.
|
101
|
-
actionpack (= 7.0.4.
|
102
|
-
activesupport (= 7.0.4.
|
100
|
+
railties (7.0.4.3)
|
101
|
+
actionpack (= 7.0.4.3)
|
102
|
+
activesupport (= 7.0.4.3)
|
103
103
|
method_source
|
104
104
|
rake (>= 12.2)
|
105
105
|
thor (~> 1.0)
|
106
106
|
zeitwerk (~> 2.5)
|
107
107
|
rainbow (3.1.1)
|
108
108
|
rake (13.0.6)
|
109
|
-
regexp_parser (2.
|
110
|
-
reline (0.3.
|
109
|
+
regexp_parser (2.8.0)
|
110
|
+
reline (0.3.3)
|
111
111
|
io-console (~> 0.5)
|
112
112
|
rest-client (2.1.0)
|
113
113
|
http-accept (>= 1.7.0, < 2.0)
|
@@ -120,32 +120,32 @@ GEM
|
|
120
120
|
rspec-core (~> 3.12.0)
|
121
121
|
rspec-expectations (~> 3.12.0)
|
122
122
|
rspec-mocks (~> 3.12.0)
|
123
|
-
rspec-core (3.12.
|
123
|
+
rspec-core (3.12.2)
|
124
124
|
rspec-support (~> 3.12.0)
|
125
|
-
rspec-expectations (3.12.
|
125
|
+
rspec-expectations (3.12.3)
|
126
126
|
diff-lcs (>= 1.2.0, < 2.0)
|
127
127
|
rspec-support (~> 3.12.0)
|
128
|
-
rspec-mocks (3.12.
|
128
|
+
rspec-mocks (3.12.5)
|
129
129
|
diff-lcs (>= 1.2.0, < 2.0)
|
130
130
|
rspec-support (~> 3.12.0)
|
131
131
|
rspec-support (3.12.0)
|
132
|
-
rubocop (1.
|
132
|
+
rubocop (1.50.2)
|
133
133
|
json (~> 2.3)
|
134
134
|
parallel (~> 1.10)
|
135
135
|
parser (>= 3.2.0.0)
|
136
136
|
rainbow (>= 2.2.2, < 4.0)
|
137
137
|
regexp_parser (>= 1.8, < 3.0)
|
138
138
|
rexml (>= 3.2.5, < 4.0)
|
139
|
-
rubocop-ast (>= 1.
|
139
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
140
140
|
ruby-progressbar (~> 1.7)
|
141
141
|
unicode-display_width (>= 2.4.0, < 3.0)
|
142
|
-
rubocop-ast (1.
|
143
|
-
parser (>= 3.
|
144
|
-
rubocop-rails (2.
|
142
|
+
rubocop-ast (1.28.0)
|
143
|
+
parser (>= 3.2.1.0)
|
144
|
+
rubocop-rails (2.19.1)
|
145
145
|
activesupport (>= 4.2.0)
|
146
146
|
rack (>= 1.1)
|
147
147
|
rubocop (>= 1.33.0, < 2.0)
|
148
|
-
ruby-progressbar (1.
|
148
|
+
ruby-progressbar (1.13.0)
|
149
149
|
simplecov (0.22.0)
|
150
150
|
docile (~> 1.1)
|
151
151
|
simplecov-html (~> 0.11)
|
@@ -162,7 +162,7 @@ GEM
|
|
162
162
|
timecop (0.9.6)
|
163
163
|
tins (1.32.1)
|
164
164
|
sync
|
165
|
-
tzinfo (2.0.
|
165
|
+
tzinfo (2.0.6)
|
166
166
|
concurrent-ruby (~> 1.0)
|
167
167
|
unf (0.1.4)
|
168
168
|
unf_ext
|
@@ -174,7 +174,7 @@ GEM
|
|
174
174
|
crack (>= 0.3.2)
|
175
175
|
hashdiff (>= 0.4.0, < 2.0.0)
|
176
176
|
zache (0.12.0)
|
177
|
-
zeitwerk (2.6.
|
177
|
+
zeitwerk (2.6.7)
|
178
178
|
|
179
179
|
PLATFORMS
|
180
180
|
x86_64-linux
|
@@ -202,4 +202,4 @@ DEPENDENCIES
|
|
202
202
|
webmock
|
203
203
|
|
204
204
|
BUNDLED WITH
|
205
|
-
2.
|
205
|
+
2.4.10
|
data/README.md
CHANGED
@@ -16,7 +16,6 @@ Ruby API client for the [Auth0](https://auth0.com) platform.
|
|
16
16
|
|
17
17
|
- [API documentation](https://www.rubydoc.info/gems/auth0) - documentation auto-generated from the code comments that explains all the available features
|
18
18
|
- [Examples](https://github.com/auth0/ruby-auth0/blob/master/EXAMPLES.md) - examples that demonstrate the different ways in which this SDK can be used
|
19
|
-
[FAQ](https://github.com/auth0/ruby-auth0/blob/master/FAQ.md) - frequently asked questions about the SDK
|
20
19
|
- [Docs Site](https://auth0.com/docs) - explore our Docs site and learn more about Auth0
|
21
20
|
|
22
21
|
## Getting Started
|
@@ -323,6 +323,21 @@ module Auth0
|
|
323
323
|
URI::HTTPS.build(host: @domain, path: '/authorize', query: to_query(request_params))
|
324
324
|
end
|
325
325
|
|
326
|
+
# Return an authorization URL for PAR requests
|
327
|
+
# @see https://www.rfc-editor.org/rfc/rfc9126.html
|
328
|
+
# @param request_uri [string] The request_uri as obtained by calling `pushed_authorization_request`
|
329
|
+
# @param additional_parameters Any additional parameters to send
|
330
|
+
def par_authorization_url(request_uri)
|
331
|
+
raise Auth0::InvalidParameter, 'Must supply a valid request_uri' if request_uri.to_s.empty?
|
332
|
+
|
333
|
+
request_params = {
|
334
|
+
client_id: @client_id,
|
335
|
+
request_uri: request_uri,
|
336
|
+
}
|
337
|
+
|
338
|
+
URI::HTTPS.build(host: @domain, path: '/authorize', query: to_query(request_params))
|
339
|
+
end
|
340
|
+
|
326
341
|
# Returns an Auth0 logout URL with a return URL.
|
327
342
|
# @see https://auth0.com/docs/api/authentication#logout
|
328
343
|
# @see https://auth0.com/docs/logout
|
@@ -344,6 +359,28 @@ module Auth0
|
|
344
359
|
)
|
345
360
|
end
|
346
361
|
|
362
|
+
# Make a request to the PAR endpoint and receive a `request_uri` to send to the '/authorize' endpoint.
|
363
|
+
# @see https://auth0.com/docs/api/authentication#authorization-code-grant
|
364
|
+
# @param redirect_uri [string] URL to redirect after authorization
|
365
|
+
# @param options [hash] Can contain response_type, connection, state, organization, invitation, and additional_parameters.
|
366
|
+
# @return [url] Authorization URL.
|
367
|
+
def pushed_authorization_request(parameters = {})
|
368
|
+
request_params = {
|
369
|
+
client_id: @client_id,
|
370
|
+
response_type: parameters.fetch(:response_type, 'code'),
|
371
|
+
connection: parameters.fetch(:connection, nil),
|
372
|
+
redirect_uri: parameters.fetch(:redirect_uri, nil),
|
373
|
+
state: parameters.fetch(:state, nil),
|
374
|
+
scope: parameters.fetch(:scope, nil),
|
375
|
+
organization: parameters.fetch(:organization, nil),
|
376
|
+
invitation: parameters.fetch(:invitation, nil)
|
377
|
+
}.merge(parameters.fetch(:additional_parameters, {}))
|
378
|
+
|
379
|
+
populate_client_assertion_or_secret(request_params)
|
380
|
+
|
381
|
+
request_with_retry(:post_form, '/oauth/par', request_params, {})
|
382
|
+
end
|
383
|
+
|
347
384
|
# Return a SAMLP URL.
|
348
385
|
# The SAML Request AssertionConsumerServiceURL will be used to POST back
|
349
386
|
# the assertion and it must match with the application callback URL.
|
data/lib/auth0/api/v2/users.rb
CHANGED
@@ -329,6 +329,122 @@ module Auth0
|
|
329
329
|
get "#{users_path}/#{user_id}/organizations"
|
330
330
|
end
|
331
331
|
|
332
|
+
# Get the available authentication methods for a user.
|
333
|
+
#
|
334
|
+
# @param user_id [string] The user ID of the authentication methods to get
|
335
|
+
# @param options [hash] A hash of options for getting permissions
|
336
|
+
# * :per_page [integer] The amount of permissions per page. (optional)
|
337
|
+
# * :page [integer] The page number. Zero based. (optional)
|
338
|
+
# * :include_totals [boolean] True if a query summary must be included in the result. (optional)
|
339
|
+
# @return [json] The user's authentication methods
|
340
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/get_authentication_methods
|
341
|
+
def user_authentication_methods(user_id, options = {})
|
342
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
343
|
+
|
344
|
+
request_params = {
|
345
|
+
per_page: options.fetch(:per_page, nil),
|
346
|
+
page: options.fetch(:page, nil),
|
347
|
+
include_totals: options.fetch(:include_totals, nil)
|
348
|
+
}
|
349
|
+
|
350
|
+
get "#{users_path}/#{user_id}/authentication-methods", request_params
|
351
|
+
end
|
352
|
+
alias get_user_authentication_methods user_authentication_methods
|
353
|
+
|
354
|
+
# Get a specific authentication method for a user.
|
355
|
+
#
|
356
|
+
# @param user_id [string] The user ID of the authentication methods to get
|
357
|
+
# @param authentication_method_id [string] The ID of the authentication method
|
358
|
+
# @return [json] The user authentication method
|
359
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/get_authentication_methods_by_authentication_method_id
|
360
|
+
def user_authentication_method(user_id, authentication_method_id)
|
361
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
362
|
+
raise Auth0::MissingParameter, 'Must supply a valid authentication_method_id' if authentication_method_id.to_s.empty?
|
363
|
+
|
364
|
+
get "#{users_path}/#{user_id}/authentication-methods/#{authentication_method_id}"
|
365
|
+
end
|
366
|
+
alias get_user_authentication_method user_authentication_method
|
367
|
+
|
368
|
+
# Create an authentication method for a user
|
369
|
+
#
|
370
|
+
# @param user_id [string] The user ID of the authentication methods to get
|
371
|
+
# @param body [hash] The post body content
|
372
|
+
# * :type [string] "phone" or "email" or "totp" or "webauthn-roaming"
|
373
|
+
# * :name [string] A human-readable label to identify the authentication method (optional)
|
374
|
+
# * :totp_secret [string] Base32 encoded secret for TOTP generation (optional)
|
375
|
+
# * :phone_number [string] Applies to phone authentication methods only. The destination phone number used to send verification codes via text and voice (optional)
|
376
|
+
# * :email [string] Applies to email authentication methods only. The email address used to send verification messages (optional)
|
377
|
+
# * :preferred_authentication_method [string] Preferred phone authentication method (optional)
|
378
|
+
# * :key_id [string] Applies to email webauthn authenticators only. The id of the credential (optional)
|
379
|
+
# * :public_key [string] Applies to email webauthn authenticators only. The public key (optional)
|
380
|
+
# * :relying_party_identifier [string] Applies to email webauthn authenticators only. The relying party identifier (optional)
|
381
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/post_authentication_methods
|
382
|
+
def post_user_authentication_method(user_id, body)
|
383
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
384
|
+
raise Auth0::MissingParameter, 'Must supply a body' if body.to_s.empty?
|
385
|
+
|
386
|
+
post "#{users_path}/#{user_id}/authentication-methods", body
|
387
|
+
end
|
388
|
+
alias create_user_authentication_method post_user_authentication_method
|
389
|
+
|
390
|
+
# Updates all authentication methods by replacing them with the given ones
|
391
|
+
#
|
392
|
+
# @param user_id [string] The user ID of the authentication methods to get
|
393
|
+
# @param body [hash array] The mehods to update
|
394
|
+
# * :type [string] "phone" or "email" or "totp" or "webauthn-roaming"
|
395
|
+
# * :name [string] A human-readable label to identify the authentication method (optional)
|
396
|
+
# * :totp_secret [string] Base32 encoded secret for TOTP generation (optional)
|
397
|
+
# * :phone_number [string] Applies to phone authentication methods only. The destination phone number used to send verification codes via text and voice (optional)
|
398
|
+
# * :email [string] Applies to email authentication methods only. The email address used to send verification messages (optional)
|
399
|
+
# * :preferred_authentication_method [string] Preferred phone authentication method (optional)
|
400
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/put_authentication_methods
|
401
|
+
def put_all_user_authentication_methods(user_id, body)
|
402
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
403
|
+
raise Auth0::MissingParameter, 'Must supply a body' if body.to_s.empty?
|
404
|
+
|
405
|
+
put "#{users_path}/#{user_id}/authentication-methods", body
|
406
|
+
end
|
407
|
+
alias update_all_user_authentication_methods put_all_user_authentication_methods
|
408
|
+
|
409
|
+
# Updates a user authentication method
|
410
|
+
#
|
411
|
+
# @param user_id [string] The user ID of the authentication methods to get
|
412
|
+
# @param body [hash array] The mehods to update
|
413
|
+
# * :name [string] A human-readable label to identify the authentication method (optional)
|
414
|
+
# * :preferred_authentication_method [string] Preferred phone authentication method (optional)
|
415
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/put_authentication_methods
|
416
|
+
def patch_user_authentication_method(user_id, authentication_method_id, body)
|
417
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
418
|
+
raise Auth0::MissingParameter, 'Must supply an authentication_method_id' if authentication_method_id.to_s.empty?
|
419
|
+
raise Auth0::MissingParameter, 'Must supply a body' if body.to_s.empty?
|
420
|
+
|
421
|
+
patch "#{users_path}/#{user_id}/authentication-methods/#{authentication_method_id}", body
|
422
|
+
end
|
423
|
+
alias update_user_authentication_method patch_user_authentication_method
|
424
|
+
|
425
|
+
# Deletes all of the user's authentication methods
|
426
|
+
#
|
427
|
+
# @param user_id [string] The user ID
|
428
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/delete_authentication_methods
|
429
|
+
def delete_user_authentication_methods(user_id)
|
430
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
431
|
+
|
432
|
+
delete "#{users_path}/#{user_id}/authentication-methods"
|
433
|
+
end
|
434
|
+
|
435
|
+
|
436
|
+
# Deletes the user's authentication method specified by authentication_method_id
|
437
|
+
#
|
438
|
+
# @param user_id [string] The user ID
|
439
|
+
# @param authentication_method_id [string] The ID of the authentication method
|
440
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/delete_authentication_methods_by_authentication_method_id
|
441
|
+
def delete_user_authentication_method(user_id, authentication_method_id)
|
442
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
443
|
+
raise Auth0::MissingParameter, 'Must supply an authentication_method_id' if authentication_method_id.to_s.empty?
|
444
|
+
|
445
|
+
delete "#{users_path}/#{user_id}/authentication-methods/#{authentication_method_id}"
|
446
|
+
end
|
447
|
+
|
332
448
|
private
|
333
449
|
|
334
450
|
# Users API path
|
@@ -16,7 +16,7 @@ module Auth0
|
|
16
16
|
BASE_DELAY = 100
|
17
17
|
|
18
18
|
# proxying requests from instance methods to HTTP class methods
|
19
|
-
%i(get post post_file put patch delete delete_with_body).each do |method|
|
19
|
+
%i(get post post_file post_form put patch delete delete_with_body).each do |method|
|
20
20
|
define_method(method) do |uri, body = {}, extra_headers = {}|
|
21
21
|
body = body.delete_if { |_, v| v.nil? }
|
22
22
|
token = get_token()
|
@@ -85,9 +85,12 @@ module Auth0
|
|
85
85
|
elsif method == :post_file
|
86
86
|
body.merge!(multipart: true)
|
87
87
|
# Ignore the default Content-Type headers and let the HTTP client define them
|
88
|
-
post_file_headers = headers.
|
88
|
+
post_file_headers = headers.except('Content-Type') if headers != nil
|
89
89
|
# Actual call with the altered headers
|
90
90
|
call(:post, encode_uri(uri), timeout, post_file_headers, body)
|
91
|
+
elsif method == :post_form
|
92
|
+
form_post_headers = headers.except('Content-Type') if headers != nil
|
93
|
+
call(:post, encode_uri(uri), timeout, form_post_headers, body.compact)
|
91
94
|
else
|
92
95
|
call(method, encode_uri(uri), timeout, headers, body.to_json)
|
93
96
|
end
|
data/lib/auth0/version.rb
CHANGED
@@ -6,6 +6,7 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
6
6
|
let(:client_secret) { 'test-client-secret' }
|
7
7
|
let(:api_identifier) { 'test-audience' }
|
8
8
|
let(:domain) { 'samples.auth0.com' }
|
9
|
+
let(:request_uri) { 'urn:ietf:params:oauth:request_uri:the.request.uri' }
|
9
10
|
|
10
11
|
let(:client_secret_config) { {
|
11
12
|
domain: domain,
|
@@ -237,7 +238,7 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
237
238
|
end
|
238
239
|
end
|
239
240
|
|
240
|
-
context 'exchange_sms_otp_for_tokens'
|
241
|
+
context 'exchange_sms_otp_for_tokens' do
|
241
242
|
it 'requests the tokens using an OTP from SMS' do
|
242
243
|
expect(RestClient::Request).to receive(:execute) do |arg|
|
243
244
|
expect(arg).to match(
|
@@ -335,7 +336,7 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
335
336
|
end
|
336
337
|
end
|
337
338
|
|
338
|
-
context 'exchange_email_otp_for_tokens'
|
339
|
+
context 'exchange_email_otp_for_tokens' do
|
339
340
|
it 'requests the tokens using email OTP' do
|
340
341
|
expect(RestClient::Request).to receive(:execute) do |arg|
|
341
342
|
expect(arg).to match(
|
@@ -628,5 +629,94 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
628
629
|
client_assertion_instance.send :start_passwordless_sms_flow, '123456789'
|
629
630
|
end
|
630
631
|
end
|
632
|
+
|
633
|
+
context 'par_authorization_url' do
|
634
|
+
it 'throws an exception if request_uri is nil' do
|
635
|
+
expect { client_secret_instance.send :par_authorization_url, nil}.to raise_error Auth0::InvalidParameter
|
636
|
+
end
|
637
|
+
|
638
|
+
it 'throws an exception if request_uri is empty' do
|
639
|
+
expect { client_secret_instance.send :par_authorization_url, ''}.to raise_error Auth0::InvalidParameter
|
640
|
+
end
|
641
|
+
|
642
|
+
it 'builds a URL containing the request_uri' do
|
643
|
+
url = client_secret_instance.send :par_authorization_url, request_uri
|
644
|
+
expect(CGI.unescape(url.to_s)).to eq("https://samples.auth0.com/authorize?client_id=#{client_id}&request_uri=#{request_uri}")
|
645
|
+
end
|
646
|
+
end
|
647
|
+
|
648
|
+
context 'pushed_authorization_request' do
|
649
|
+
it 'sends the request as a form post' do
|
650
|
+
expect(RestClient::Request).to receive(:execute) do |arg|
|
651
|
+
expect(arg[:url]).to eq('https://samples.auth0.com/oauth/par')
|
652
|
+
expect(arg[:method]).to eq(:post)
|
653
|
+
|
654
|
+
expect(arg[:payload]).to eq({
|
655
|
+
client_id: client_id,
|
656
|
+
client_secret: client_secret,
|
657
|
+
response_type: 'code',
|
658
|
+
})
|
659
|
+
|
660
|
+
StubResponse.new({}, true, 200)
|
661
|
+
end
|
662
|
+
|
663
|
+
client_secret_instance.send :pushed_authorization_request
|
664
|
+
end
|
665
|
+
|
666
|
+
it 'allows the RestClient to handle the correct header defaults' do
|
667
|
+
expect(RestClient::Request).to receive(:execute) do |arg|
|
668
|
+
expect(arg[:headers]).not_to have_key('Content-Type')
|
669
|
+
|
670
|
+
StubResponse.new({}, true, 200)
|
671
|
+
end
|
672
|
+
|
673
|
+
client_secret_instance.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
674
|
+
client_secret_instance.send :pushed_authorization_request
|
675
|
+
end
|
676
|
+
|
677
|
+
it 'sends the request as a form post with all known overrides' do
|
678
|
+
expect(RestClient::Request).to receive(:execute) do |arg|
|
679
|
+
expect(arg[:url]).to eq('https://samples.auth0.com/oauth/par')
|
680
|
+
expect(arg[:method]).to eq(:post)
|
681
|
+
|
682
|
+
expect(arg[:payload]).to eq({
|
683
|
+
client_id: client_id,
|
684
|
+
client_secret: client_secret,
|
685
|
+
connection: 'google-oauth2',
|
686
|
+
organization: 'org_id',
|
687
|
+
invitation: 'http://invite.url',
|
688
|
+
redirect_uri: 'http://localhost:3000',
|
689
|
+
response_type: 'id_token',
|
690
|
+
scope: 'openid',
|
691
|
+
state: 'random_value'
|
692
|
+
})
|
693
|
+
|
694
|
+
StubResponse.new({}, true, 200)
|
695
|
+
end
|
696
|
+
|
697
|
+
client_secret_instance.send(:pushed_authorization_request,
|
698
|
+
response_type: 'id_token',
|
699
|
+
redirect_uri: 'http://localhost:3000',
|
700
|
+
organization: 'org_id',
|
701
|
+
invitation: 'http://invite.url',
|
702
|
+
scope: 'openid',
|
703
|
+
state: 'random_value',
|
704
|
+
connection: 'google-oauth2')
|
705
|
+
end
|
706
|
+
|
707
|
+
it 'sends the request as a form post using client assertion' do
|
708
|
+
expect(RestClient::Request).to receive(:execute) do |arg|
|
709
|
+
expect(arg[:url]).to eq('https://samples.auth0.com/oauth/par')
|
710
|
+
expect(arg[:method]).to eq(:post)
|
711
|
+
expect(arg[:payload][:client_secret]).to be_nil
|
712
|
+
expect(arg[:payload][:client_assertion]).not_to be_nil
|
713
|
+
expect(arg[:payload][:client_assertion_type]).to eq Auth0::ClientAssertion::CLIENT_ASSERTION_TYPE
|
714
|
+
|
715
|
+
StubResponse.new({}, true, 200)
|
716
|
+
end
|
717
|
+
|
718
|
+
client_assertion_instance.send :pushed_authorization_request
|
719
|
+
end
|
720
|
+
end
|
631
721
|
end
|
632
722
|
end
|
@@ -583,4 +583,222 @@ describe Auth0::Api::V2::Users do
|
|
583
583
|
end.not_to raise_error
|
584
584
|
end
|
585
585
|
end
|
586
|
+
|
587
|
+
context '.get_user_authentication_methods' do
|
588
|
+
it 'is expected to respond to user_authentication_methods method' do
|
589
|
+
expect(@instance).to respond_to(:user_authentication_methods)
|
590
|
+
end
|
591
|
+
|
592
|
+
it 'is expected to respond to get_user_authentication_methods method' do
|
593
|
+
expect(@instance).to respond_to(:get_user_authentication_methods)
|
594
|
+
end
|
595
|
+
|
596
|
+
it 'is expected to raise an exception when the user ID is empty' do
|
597
|
+
expect { @instance.user_authentication_methods(nil) }.to raise_exception(Auth0::MissingUserId)
|
598
|
+
end
|
599
|
+
|
600
|
+
it 'is expected to get user authentication methods' do
|
601
|
+
expect(@instance).to receive(:get).with(
|
602
|
+
'/api/v2/users/USER_ID/authentication-methods', {
|
603
|
+
per_page: nil,
|
604
|
+
page: nil,
|
605
|
+
include_totals: nil
|
606
|
+
}
|
607
|
+
)
|
608
|
+
|
609
|
+
expect do
|
610
|
+
@instance.user_authentication_methods('USER_ID')
|
611
|
+
end.not_to raise_error
|
612
|
+
end
|
613
|
+
|
614
|
+
it 'is expected to get user authentication methods with paging' do
|
615
|
+
expect(@instance).to receive(:get).with(
|
616
|
+
'/api/v2/users/USER_ID/authentication-methods', {
|
617
|
+
per_page: 1,
|
618
|
+
page: 2,
|
619
|
+
include_totals: true
|
620
|
+
}
|
621
|
+
)
|
622
|
+
|
623
|
+
expect do
|
624
|
+
@instance.user_authentication_methods('USER_ID', per_page: 1, page: 2, include_totals: true)
|
625
|
+
end.not_to raise_error
|
626
|
+
end
|
627
|
+
end
|
628
|
+
|
629
|
+
context '.get_user_authentication_method' do
|
630
|
+
it 'is expected to respond to get_user_authentication_method' do
|
631
|
+
expect(@instance).to respond_to :user_authentication_method
|
632
|
+
end
|
633
|
+
|
634
|
+
it 'is expected to respond to get_user_authentication_method' do
|
635
|
+
expect(@instance).to respond_to :get_user_authentication_method
|
636
|
+
end
|
637
|
+
|
638
|
+
it 'is expected to raise an exception for a missing user ID' do
|
639
|
+
expect { @instance.user_authentication_method(nil, nil) }.to raise_exception(Auth0::MissingUserId)
|
640
|
+
end
|
641
|
+
|
642
|
+
it 'is expected to raise an exception for a missing authentication method ID' do
|
643
|
+
expect { @instance.user_authentication_method('USER_ID', nil) }.to raise_exception(Auth0::MissingParameter)
|
644
|
+
end
|
645
|
+
|
646
|
+
it 'is expected to GET a user authentication method' do
|
647
|
+
expect(@instance).to receive(:get).with(
|
648
|
+
'/api/v2/users/USER_ID/authentication-methods/AUTH_METHOD_ID'
|
649
|
+
)
|
650
|
+
|
651
|
+
expect do
|
652
|
+
@instance.user_authentication_method('USER_ID', 'AUTH_METHOD_ID')
|
653
|
+
end.not_to raise_error
|
654
|
+
|
655
|
+
end
|
656
|
+
end
|
657
|
+
|
658
|
+
context '.create_user_authentication_method' do
|
659
|
+
it 'is expected to respond to create_user_authentication_method' do
|
660
|
+
expect(@instance).to respond_to :create_user_authentication_method
|
661
|
+
end
|
662
|
+
|
663
|
+
it 'is expected to respond to post_user_authentication_method' do
|
664
|
+
expect(@instance).to respond_to :post_user_authentication_method
|
665
|
+
end
|
666
|
+
|
667
|
+
it 'is expected to raise an exception for a missing user ID' do
|
668
|
+
expect { @instance.create_user_authentication_method(nil, nil) }.to raise_exception(Auth0::MissingUserId)
|
669
|
+
end
|
670
|
+
|
671
|
+
it 'is expected to raise an exception for a missing body' do
|
672
|
+
expect { @instance.create_user_authentication_method('USER_ID', nil) }.to raise_exception(Auth0::MissingParameter)
|
673
|
+
end
|
674
|
+
|
675
|
+
it 'is expected to send the body to the endpoint' do
|
676
|
+
body = {
|
677
|
+
type: 'phone'
|
678
|
+
}
|
679
|
+
|
680
|
+
expect(@instance).to receive(:post).with(
|
681
|
+
'/api/v2/users/USER_ID/authentication-methods',
|
682
|
+
body
|
683
|
+
)
|
684
|
+
|
685
|
+
expect do
|
686
|
+
@instance.create_user_authentication_method 'USER_ID', body
|
687
|
+
end.not_to raise_error
|
688
|
+
end
|
689
|
+
end
|
690
|
+
|
691
|
+
context '.put_all_user_authentication_methods' do
|
692
|
+
it 'is expected to respond to put_all_user_authentication_methods' do
|
693
|
+
expect(@instance).to respond_to(:put_all_user_authentication_methods)
|
694
|
+
end
|
695
|
+
|
696
|
+
it 'is expected to respond to update_all_user_authentication_methods' do
|
697
|
+
expect(@instance).to respond_to(:update_all_user_authentication_methods)
|
698
|
+
end
|
699
|
+
|
700
|
+
it 'is expected to raise an exception for a missing user ID' do
|
701
|
+
expect { @instance.put_all_user_authentication_methods(nil, nil) }.to raise_exception(Auth0::MissingUserId)
|
702
|
+
end
|
703
|
+
|
704
|
+
it 'is expected to raise an exception for a missing body' do
|
705
|
+
expect { @instance.put_all_user_authentication_methods('USER_ID', nil) }.to raise_exception(Auth0::MissingParameter)
|
706
|
+
end
|
707
|
+
|
708
|
+
it 'is expected to send the body to the endpoint' do
|
709
|
+
body = {
|
710
|
+
type: 'phone'
|
711
|
+
}
|
712
|
+
|
713
|
+
expect(@instance).to receive(:put).with(
|
714
|
+
'/api/v2/users/USER_ID/authentication-methods',
|
715
|
+
[body]
|
716
|
+
)
|
717
|
+
|
718
|
+
expect do
|
719
|
+
@instance.put_all_user_authentication_methods 'USER_ID', [body]
|
720
|
+
end.to_not raise_error
|
721
|
+
end
|
722
|
+
end
|
723
|
+
|
724
|
+
context '.patch_user_authentication_method' do
|
725
|
+
it 'is expected to respond to patch_user_authentication_method' do
|
726
|
+
expect(@instance).to respond_to(:patch_user_authentication_method)
|
727
|
+
end
|
728
|
+
|
729
|
+
it 'is expected to respond to update_user_authentication_method' do
|
730
|
+
expect(@instance).to respond_to(:update_user_authentication_method)
|
731
|
+
end
|
732
|
+
|
733
|
+
it 'is expected to raise an exception for a missing user ID' do
|
734
|
+
expect { @instance.patch_user_authentication_method(nil, nil, nil) }.to raise_exception(Auth0::MissingUserId)
|
735
|
+
end
|
736
|
+
|
737
|
+
it 'is expected to raise an exception for a missing authentication_method_id' do
|
738
|
+
expect { @instance.patch_user_authentication_method('USER_ID', nil, nil) }.to raise_exception(Auth0::MissingParameter)
|
739
|
+
end
|
740
|
+
|
741
|
+
it 'is expected to raise an exception for a missing body' do
|
742
|
+
expect { @instance.patch_user_authentication_method('USER_ID', 'AUTH_METHOD_ID', nil) }.to raise_exception(Auth0::MissingParameter)
|
743
|
+
end
|
744
|
+
|
745
|
+
it 'is expected to send the body to the endpoint' do
|
746
|
+
body = {
|
747
|
+
name: 'auth method name'
|
748
|
+
}
|
749
|
+
|
750
|
+
expect(@instance).to receive(:patch).with(
|
751
|
+
'/api/v2/users/USER_ID/authentication-methods/AUTH_METHOD_ID',
|
752
|
+
body
|
753
|
+
)
|
754
|
+
|
755
|
+
expect do
|
756
|
+
@instance.patch_user_authentication_method 'USER_ID', 'AUTH_METHOD_ID', body
|
757
|
+
end.to_not raise_error
|
758
|
+
end
|
759
|
+
end
|
760
|
+
|
761
|
+
context '.delete_user_authentication_methods' do
|
762
|
+
it 'is expected to respond to delete_user_authentication_methods' do
|
763
|
+
expect(@instance).to respond_to(:delete_user_authentication_methods)
|
764
|
+
end
|
765
|
+
|
766
|
+
it 'is expected to raise an exception for a missing user ID' do
|
767
|
+
expect { @instance.delete_user_authentication_methods(nil) }.to raise_exception(Auth0::MissingUserId)
|
768
|
+
end
|
769
|
+
|
770
|
+
it 'is expected to call the endpoint' do
|
771
|
+
expect(@instance).to receive(:delete).with(
|
772
|
+
'/api/v2/users/USER_ID/authentication-methods'
|
773
|
+
)
|
774
|
+
|
775
|
+
expect do
|
776
|
+
@instance.delete_user_authentication_methods 'USER_ID'
|
777
|
+
end.to_not raise_error
|
778
|
+
end
|
779
|
+
end
|
780
|
+
|
781
|
+
context '.delete_user_authentication_method' do
|
782
|
+
it 'is expected to respond to delete_user_authentication_method' do
|
783
|
+
expect(@instance).to respond_to(:delete_user_authentication_method)
|
784
|
+
end
|
785
|
+
|
786
|
+
it 'is expected to raise an exception for a missing user ID' do
|
787
|
+
expect { @instance.delete_user_authentication_method(nil, nil) }.to raise_exception(Auth0::MissingUserId)
|
788
|
+
end
|
789
|
+
|
790
|
+
it 'is expected to raise an exception for a missing authentication_method_id' do
|
791
|
+
expect { @instance.delete_user_authentication_method('USER_ID', nil) }.to raise_exception(Auth0::MissingParameter)
|
792
|
+
end
|
793
|
+
|
794
|
+
it 'is expected to call the endpoint' do
|
795
|
+
expect(@instance).to receive(:delete).with(
|
796
|
+
'/api/v2/users/USER_ID/authentication-methods/AUTH_METHOD_ID'
|
797
|
+
)
|
798
|
+
|
799
|
+
expect do
|
800
|
+
@instance.delete_user_authentication_method 'USER_ID', 'AUTH_METHOD_ID'
|
801
|
+
end.to_not raise_error
|
802
|
+
end
|
803
|
+
end
|
586
804
|
end
|
@@ -250,25 +250,37 @@ describe Auth0::Mixins::HTTPProxy do
|
|
250
250
|
end
|
251
251
|
end
|
252
252
|
|
253
|
-
|
253
|
+
def expected_payload(method, overrides = {})
|
254
|
+
if method == :post_form
|
255
|
+
{
|
256
|
+
method: :post,
|
257
|
+
url: 'https://auth0.com/test',
|
258
|
+
timeout: nil,
|
259
|
+
headers: nil,
|
260
|
+
payload: {}
|
261
|
+
}.merge(overrides)
|
262
|
+
else
|
263
|
+
{
|
264
|
+
method: method,
|
265
|
+
url: 'https://auth0.com/test',
|
266
|
+
timeout: nil,
|
267
|
+
headers: nil,
|
268
|
+
payload: '{}'
|
269
|
+
}.merge(overrides)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
%i(post post_form put patch).each do |http_method|
|
254
274
|
context ".#{http_method}" do
|
255
275
|
it { expect(@instance).to respond_to(http_method.to_sym) }
|
256
|
-
it "should call send http #{http_method} method to path defined through HTTP"
|
257
|
-
expect(RestClient::Request).to receive(:execute).with(
|
258
|
-
url: 'https://auth0.com/test',
|
259
|
-
timeout: nil,
|
260
|
-
headers: nil,
|
261
|
-
payload: '{}')
|
276
|
+
it "should call send http #{http_method} method to path defined through HTTP"do
|
277
|
+
expect(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
|
262
278
|
.and_return(StubResponse.new({}, true, 200))
|
263
279
|
expect { @instance.send(http_method, '/test') }.not_to raise_error
|
264
280
|
end
|
265
281
|
|
266
282
|
it 'should not raise exception if data returned not in json format (should be fixed in v2)' do
|
267
|
-
allow(RestClient::Request).to receive(:execute).with(
|
268
|
-
url: 'https://auth0.com/test',
|
269
|
-
timeout: nil,
|
270
|
-
headers: nil,
|
271
|
-
payload: '{}')
|
283
|
+
allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
|
272
284
|
.and_return(StubResponse.new('Some random text here', true, 200))
|
273
285
|
expect { @instance.send(http_method, '/test') }.not_to raise_error
|
274
286
|
expect(@instance.send(http_method, '/test')).to eql('Some random text here')
|
@@ -277,11 +289,7 @@ describe Auth0::Mixins::HTTPProxy do
|
|
277
289
|
it "should raise Auth0::Unauthorized on send http #{http_method} method
|
278
290
|
to path defined through HTTP when 401 status received" do
|
279
291
|
@exception.response = StubResponse.new({}, false, 401)
|
280
|
-
allow(RestClient::Request).to receive(:execute).with(
|
281
|
-
url: 'https://auth0.com/test',
|
282
|
-
timeout: nil,
|
283
|
-
headers: nil,
|
284
|
-
payload: '{}')
|
292
|
+
allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
|
285
293
|
.and_raise(@exception)
|
286
294
|
expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::Unauthorized)
|
287
295
|
end
|
@@ -294,11 +302,7 @@ describe Auth0::Mixins::HTTPProxy do
|
|
294
302
|
:x_ratelimit_reset => 1560564149
|
295
303
|
}
|
296
304
|
@exception.response = StubResponse.new({}, false, 429,headers)
|
297
|
-
allow(RestClient::Request).to receive(:execute).with(
|
298
|
-
url: 'https://auth0.com/test',
|
299
|
-
timeout: nil,
|
300
|
-
headers: nil,
|
301
|
-
payload: '{}')
|
305
|
+
allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
|
302
306
|
.and_raise(@exception)
|
303
307
|
expect { @instance.send(http_method, '/test') }.to raise_error { |error|
|
304
308
|
expect(error).to be_a(Auth0::RateLimitEncountered)
|
@@ -317,11 +321,7 @@ describe Auth0::Mixins::HTTPProxy do
|
|
317
321
|
it "should raise Auth0::NotFound on send http #{http_method} method
|
318
322
|
to path defined through HTTP when 404 status received" do
|
319
323
|
@exception.response = StubResponse.new({}, false, 404)
|
320
|
-
allow(RestClient::Request).to receive(:execute).with(
|
321
|
-
url: 'https://auth0.com/test',
|
322
|
-
timeout: nil,
|
323
|
-
headers: nil,
|
324
|
-
payload: '{}')
|
324
|
+
allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
|
325
325
|
.and_raise(@exception)
|
326
326
|
expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::NotFound)
|
327
327
|
end
|
@@ -329,22 +329,14 @@ describe Auth0::Mixins::HTTPProxy do
|
|
329
329
|
it "should raise Auth0::Unsupported on send http #{http_method} method
|
330
330
|
to path defined through HTTP when 418 or other unknown status received" do
|
331
331
|
@exception.response = StubResponse.new({}, false, 418)
|
332
|
-
allow(RestClient::Request).to receive(:execute).with(
|
333
|
-
url: 'https://auth0.com/test',
|
334
|
-
timeout: nil,
|
335
|
-
headers: nil,
|
336
|
-
payload: '{}')
|
332
|
+
allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
|
337
333
|
.and_raise(@exception)
|
338
334
|
expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::Unsupported)
|
339
335
|
end
|
340
336
|
|
341
337
|
it "should raise Auth0::RequestTimeout on send http #{http_method} method
|
342
338
|
to path defined through HTTP when RestClient::RequestTimeout received" do
|
343
|
-
allow(RestClient::Request).to receive(:execute).with(
|
344
|
-
url: 'https://auth0.com/test',
|
345
|
-
timeout: nil,
|
346
|
-
headers: nil,
|
347
|
-
payload: '{}')
|
339
|
+
allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
|
348
340
|
.and_raise(RestClient::Exceptions::OpenTimeout.new)
|
349
341
|
expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::RequestTimeout)
|
350
342
|
end
|
@@ -352,11 +344,7 @@ describe Auth0::Mixins::HTTPProxy do
|
|
352
344
|
it "should raise Auth0::BadRequest on send http #{http_method} method
|
353
345
|
to path defined through HTTP when 400 status received" do
|
354
346
|
@exception.response = StubResponse.new({}, false, 400)
|
355
|
-
allow(RestClient::Request).to receive(:execute).with(
|
356
|
-
url: 'https://auth0.com/test',
|
357
|
-
timeout: nil,
|
358
|
-
headers: nil,
|
359
|
-
payload: '{}')
|
347
|
+
allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
|
360
348
|
.and_raise(@exception)
|
361
349
|
expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::BadRequest)
|
362
350
|
end
|
@@ -364,20 +352,13 @@ describe Auth0::Mixins::HTTPProxy do
|
|
364
352
|
it "should raise Auth0::ServerError on send http #{http_method} method
|
365
353
|
to path defined through HTTP when 500 received" do
|
366
354
|
@exception.response = StubResponse.new({}, false, 500)
|
367
|
-
allow(RestClient::Request).to receive(:execute).with(
|
368
|
-
timeout: nil,
|
369
|
-
headers: nil,
|
370
|
-
payload: '{}')
|
355
|
+
allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
|
371
356
|
.and_raise(@exception)
|
372
357
|
expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::ServerError)
|
373
358
|
end
|
374
359
|
|
375
360
|
it 'should normalize path with Addressable::URI' do
|
376
|
-
expect(RestClient::Request).to receive(:execute).with(
|
377
|
-
url: 'https://auth0.com/te%20st',
|
378
|
-
timeout: nil,
|
379
|
-
headers: nil,
|
380
|
-
payload: '{}')
|
361
|
+
expect(RestClient::Request).to receive(:execute).with(expected_payload(http_method, url: 'https://auth0.com/te%20st'))
|
381
362
|
.and_return(StubResponse.new({}, true, 200))
|
382
363
|
expect { @instance.send(http_method, '/te st') }.not_to raise_error
|
383
364
|
end
|
@@ -388,11 +369,7 @@ describe Auth0::Mixins::HTTPProxy do
|
|
388
369
|
'message' => "Path validation error: 'String does not match pattern ^.+\\|.+$:
|
389
370
|
3241312' on property id (The user_id of the user to retrieve).",
|
390
371
|
'errorCode' => 'invalid_uri')
|
391
|
-
expect(RestClient::Request).to receive(:execute).with(
|
392
|
-
url: 'https://auth0.com/test',
|
393
|
-
timeout: nil,
|
394
|
-
headers: nil,
|
395
|
-
payload: '{}')
|
372
|
+
expect(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
|
396
373
|
.and_return(StubResponse.new(res, true, 404))
|
397
374
|
expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::NotFound, res)
|
398
375
|
end
|
@@ -404,11 +381,7 @@ describe Auth0::Mixins::HTTPProxy do
|
|
404
381
|
retry_instance.base_uri = "https://auth0.com"
|
405
382
|
|
406
383
|
@exception.response = StubResponse.new({}, false, 429)
|
407
|
-
allow(RestClient::Request).to receive(:execute).with(
|
408
|
-
url: 'https://auth0.com/test',
|
409
|
-
timeout: nil,
|
410
|
-
headers: nil,
|
411
|
-
payload: '{}')
|
384
|
+
allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
|
412
385
|
.and_raise(@exception)
|
413
386
|
expect(RestClient::Request).to receive(:execute).exactly(4).times
|
414
387
|
|
@@ -424,11 +397,7 @@ describe Auth0::Mixins::HTTPProxy do
|
|
424
397
|
retry_instance.retry_count = 2
|
425
398
|
|
426
399
|
@exception.response = StubResponse.new({}, false, 429)
|
427
|
-
allow(RestClient::Request).to receive(:execute).with(
|
428
|
-
url: 'https://auth0.com/test',
|
429
|
-
timeout: nil,
|
430
|
-
headers: nil,
|
431
|
-
payload: '{}')
|
400
|
+
allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
|
432
401
|
.and_raise(@exception)
|
433
402
|
expect(RestClient::Request).to receive(:execute).exactly(3).times
|
434
403
|
|
@@ -445,11 +414,7 @@ describe Auth0::Mixins::HTTPProxy do
|
|
445
414
|
|
446
415
|
@exception.response = StubResponse.new({}, false, 429)
|
447
416
|
|
448
|
-
allow(RestClient::Request).to receive(:execute).with(
|
449
|
-
url: 'https://auth0.com/test',
|
450
|
-
timeout: nil,
|
451
|
-
headers: nil,
|
452
|
-
payload: '{}')
|
417
|
+
allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
|
453
418
|
.and_raise(@exception)
|
454
419
|
|
455
420
|
expect(RestClient::Request).to receive(:execute).exactly(1).times
|
@@ -467,11 +432,7 @@ describe Auth0::Mixins::HTTPProxy do
|
|
467
432
|
@time_start
|
468
433
|
|
469
434
|
@exception.response = StubResponse.new({}, false, 429)
|
470
|
-
allow(RestClient::Request).to receive(:execute).with(
|
471
|
-
url: 'https://auth0.com/test',
|
472
|
-
timeout: nil,
|
473
|
-
headers: nil,
|
474
|
-
payload: '{}') do
|
435
|
+
allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method)) do
|
475
436
|
|
476
437
|
time_entries.push(Time.now.to_f - @time_start.to_f)
|
477
438
|
@time_start = Time.now.to_f # restart the clock
|
@@ -492,6 +453,7 @@ describe Auth0::Mixins::HTTPProxy do
|
|
492
453
|
end
|
493
454
|
end
|
494
455
|
end
|
456
|
+
end
|
495
457
|
|
496
458
|
context "Renewing tokens" do
|
497
459
|
let(:httpproxy_instance) {
|
@@ -546,7 +508,6 @@ describe Auth0::Mixins::HTTPProxy do
|
|
546
508
|
end
|
547
509
|
end
|
548
510
|
end
|
549
|
-
end
|
550
511
|
|
551
512
|
context "Using cached tokens" do
|
552
513
|
let(:httpproxy_instance) {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auth0
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Auth0
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2023-
|
14
|
+
date: 2023-04-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rest-client
|
@@ -248,6 +248,7 @@ files:
|
|
248
248
|
- ".rspec"
|
249
249
|
- ".rubocop.yml"
|
250
250
|
- ".rubocop_todo.yml"
|
251
|
+
- ".semgrepignore"
|
251
252
|
- ".shiprc"
|
252
253
|
- CHANGELOG.md
|
253
254
|
- CODE_OF_CONDUCT.md
|
@@ -614,7 +615,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
614
615
|
- !ruby/object:Gem::Version
|
615
616
|
version: '0'
|
616
617
|
requirements: []
|
617
|
-
rubygems_version: 3.
|
618
|
+
rubygems_version: 3.4.10
|
618
619
|
signing_key:
|
619
620
|
specification_version: 4
|
620
621
|
summary: Auth0 API Client
|