auth0 5.10.0 → 5.11.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 +2 -2
- data/.devcontainer/devcontainer.json +1 -1
- data/CHANGELOG.md +11 -0
- data/DEVELOPMENT.md +35 -0
- data/EXAMPLES.md +220 -0
- data/Gemfile.lock +52 -60
- data/README.md +68 -253
- data/auth0.gemspec +0 -2
- data/examples/ruby-api/Gemfile.lock +5 -4
- data/examples/ruby-on-rails-api/README.md +0 -2
- data/lib/auth0/api/authentication_endpoints.rb +70 -13
- data/lib/auth0/api/v2/clients.rb +42 -0
- data/lib/auth0/client_assertion.rb +45 -0
- data/lib/auth0/mixins/initializer.rb +2 -0
- data/lib/auth0/mixins/token_management.rb +1 -1
- data/lib/auth0/version.rb +1 -1
- data/opslevel.yml +5 -0
- data/spec/lib/auth0/api/authentication_endpoints_spec.rb +632 -0
- data/spec/lib/auth0/api/v2/clients_spec.rb +51 -0
- data/spec/lib/auth0/mixins/initializer_spec.rb +79 -25
- data/spec/lib/auth0/mixins/token_management_spec.rb +45 -30
- data/spec/spec_helper.rb +0 -1
- data/spec/support/dummy_class_for_tokens.rb +2 -0
- metadata +8 -31
@@ -13,6 +13,15 @@ describe Auth0::Mixins::Initializer do
|
|
13
13
|
let(:params) { { namespace: 'samples.auth0.com' } }
|
14
14
|
let(:instance) { DummyClassForProxy.send(:include, described_class).new(params) }
|
15
15
|
let(:time_now) { Time.now }
|
16
|
+
|
17
|
+
let(:client_assertion_signing_key_pair) do
|
18
|
+
rsa_private = OpenSSL::PKey::RSA.generate 2048
|
19
|
+
|
20
|
+
{
|
21
|
+
public_key: rsa_private.public_key,
|
22
|
+
private_key: rsa_private
|
23
|
+
}
|
24
|
+
end
|
16
25
|
|
17
26
|
context 'api v2' do
|
18
27
|
it 'sets retry_count when passed' do
|
@@ -45,31 +54,76 @@ describe Auth0::Mixins::Initializer do
|
|
45
54
|
expect(instance.instance_variable_get('@token')).to eq('123')
|
46
55
|
end
|
47
56
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
57
|
+
context 'with a client secret' do
|
58
|
+
it 'fetches a token if none was given' do
|
59
|
+
params[:client_id] = client_id = 'test_client_id'
|
60
|
+
params[:client_secret] = client_secret = 'test_client_secret'
|
61
|
+
params[:api_identifier] = api_identifier = 'test'
|
62
|
+
|
63
|
+
payload = {
|
64
|
+
grant_type: 'client_credentials',
|
65
|
+
client_id: client_id,
|
66
|
+
client_secret: client_secret,
|
67
|
+
audience: api_identifier
|
68
|
+
}
|
69
|
+
|
70
|
+
expect(RestClient::Request).to receive(:execute) do |arg|
|
71
|
+
expect(arg).to(match(
|
72
|
+
include(
|
73
|
+
method: :post,
|
74
|
+
url: 'https://samples.auth0.com/oauth/token'
|
75
|
+
)
|
76
|
+
))
|
77
|
+
|
78
|
+
expect(JSON.parse(arg[:payload], { symbolize_names: true })).to eq(payload)
|
79
|
+
|
80
|
+
StubResponse.new({
|
81
|
+
"access_token" => "test",
|
82
|
+
"expires_in" => 86400},
|
83
|
+
true,
|
84
|
+
200)
|
85
|
+
end
|
86
|
+
|
87
|
+
expect(instance.instance_variable_get('@token')).to eq('test')
|
88
|
+
expect(instance.instance_variable_get('@token_expires_at')).to eq(time_now.to_i + 86400)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'with a client assertion signing key' do
|
93
|
+
it 'fetches a token if none was given' do
|
94
|
+
private_key = client_assertion_signing_key_pair[:private_key]
|
95
|
+
|
96
|
+
params[:client_id] = client_id = 'test_client_id'
|
97
|
+
params[:api_identifier] = api_identifier = 'test'
|
98
|
+
params[:client_assertion_signing_key] = private_key
|
99
|
+
|
100
|
+
expect(RestClient::Request).to receive(:execute) do |arg|
|
101
|
+
expect(arg).to(match(
|
102
|
+
include(
|
103
|
+
method: :post,
|
104
|
+
url: 'https://samples.auth0.com/oauth/token'
|
105
|
+
)
|
106
|
+
))
|
107
|
+
|
108
|
+
payload = JSON.parse(arg[:payload], { symbolize_names: true })
|
109
|
+
|
110
|
+
expect(payload[:grant_type]).to eq 'client_credentials'
|
111
|
+
expect(payload[:client_id]).to eq client_id
|
112
|
+
expect(payload[:audience]).to eq api_identifier
|
113
|
+
expect(payload[:client_secret]).to be_nil
|
114
|
+
expect(payload[:client_assertion]).not_to be_nil
|
115
|
+
expect(payload[:client_assertion_type]).to eq Auth0::ClientAssertion::CLIENT_ASSERTION_TYPE
|
116
|
+
|
117
|
+
StubResponse.new({
|
118
|
+
"access_token" => "test",
|
119
|
+
"expires_in" => 86400},
|
120
|
+
true,
|
121
|
+
200)
|
122
|
+
end
|
123
|
+
|
124
|
+
expect(instance.instance_variable_get('@token')).to eq('test')
|
125
|
+
expect(instance.instance_variable_get('@token_expires_at')).to eq(time_now.to_i + 86400)
|
126
|
+
end
|
73
127
|
end
|
74
128
|
|
75
129
|
it "doesn't get a new token if one was supplied using 'token'" do
|
@@ -34,16 +34,21 @@ describe Auth0::Mixins::TokenManagement do
|
|
34
34
|
|
35
35
|
context 'get_token' do
|
36
36
|
it 'renews the token if there is no token set' do
|
37
|
-
expect(RestClient::Request).to receive(:execute)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
37
|
+
expect(RestClient::Request).to receive(:execute) do |arg|
|
38
|
+
expect(arg).to(match(
|
39
|
+
include(
|
40
|
+
method: :post,
|
41
|
+
url: 'https://samples.auth0.com/oauth/token'
|
42
|
+
)))
|
43
|
+
|
44
|
+
expect(JSON.parse(arg[:payload], { symbolize_names: true })).to eq(payload)
|
45
|
+
|
46
|
+
StubResponse.new({
|
47
|
+
"access_token" => "test",
|
48
|
+
"expires_in" => 86400},
|
49
|
+
true,
|
50
|
+
200)
|
51
|
+
end
|
47
52
|
|
48
53
|
instance.send(:get_token)
|
49
54
|
|
@@ -70,16 +75,21 @@ describe Auth0::Mixins::TokenManagement do
|
|
70
75
|
params[:token] = 'test-token'
|
71
76
|
params[:token_expires_at] = time_now.to_i + 5
|
72
77
|
|
73
|
-
expect(RestClient::Request).to receive(:execute)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
expect(RestClient::Request).to receive(:execute) do |arg|
|
79
|
+
expect(arg).to(match(
|
80
|
+
include(
|
81
|
+
method: :post,
|
82
|
+
url: 'https://samples.auth0.com/oauth/token'
|
83
|
+
)))
|
84
|
+
|
85
|
+
expect(JSON.parse(arg[:payload], { symbolize_names: true })).to eq(payload)
|
86
|
+
|
87
|
+
StubResponse.new({
|
88
|
+
"access_token" => "renewed_token",
|
89
|
+
"expires_in" => 86400},
|
90
|
+
true,
|
91
|
+
200)
|
92
|
+
end
|
83
93
|
|
84
94
|
instance.send(:get_token)
|
85
95
|
|
@@ -91,16 +101,21 @@ describe Auth0::Mixins::TokenManagement do
|
|
91
101
|
params[:token] = 'test-token'
|
92
102
|
params[:token_expires_at] = time_now.to_i - 10
|
93
103
|
|
94
|
-
expect(RestClient::Request).to receive(:execute)
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
+
expect(RestClient::Request).to receive(:execute) do |arg|
|
105
|
+
expect(arg).to(match(
|
106
|
+
include(
|
107
|
+
method: :post,
|
108
|
+
url: 'https://samples.auth0.com/oauth/token'
|
109
|
+
)))
|
110
|
+
|
111
|
+
expect(JSON.parse(arg[:payload], { symbolize_names: true })).to eq(payload)
|
112
|
+
|
113
|
+
StubResponse.new({
|
114
|
+
"access_token" => "renewed_token",
|
115
|
+
"expires_in" => 86400},
|
116
|
+
true,
|
117
|
+
200)
|
118
|
+
end
|
104
119
|
|
105
120
|
instance.send(:get_token)
|
106
121
|
|
data/spec/spec_helper.rb
CHANGED
@@ -13,5 +13,7 @@ class DummyClassForTokens
|
|
13
13
|
@base_uri = "https://#{@domain}"
|
14
14
|
@token = config[:token]
|
15
15
|
@token_expires_at = config[:token_expires_at]
|
16
|
+
@client_assertion_signing_key = config[:client_assertion_signing_key]
|
17
|
+
@client_assertion_signing_alg = config[:client_assertion_signing_alg] || 'RS256'
|
16
18
|
end
|
17
19
|
end
|
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.11.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:
|
14
|
+
date: 2023-01-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rest-client
|
@@ -139,34 +139,6 @@ dependencies:
|
|
139
139
|
- - "~>"
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '2.0'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: pry
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
requirements:
|
146
|
-
- - "~>"
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
version: '0.10'
|
149
|
-
type: :development
|
150
|
-
prerelease: false
|
151
|
-
version_requirements: !ruby/object:Gem::Requirement
|
152
|
-
requirements:
|
153
|
-
- - "~>"
|
154
|
-
- !ruby/object:Gem::Version
|
155
|
-
version: '0.10'
|
156
|
-
- !ruby/object:Gem::Dependency
|
157
|
-
name: pry-nav
|
158
|
-
requirement: !ruby/object:Gem::Requirement
|
159
|
-
requirements:
|
160
|
-
- - "~>"
|
161
|
-
- !ruby/object:Gem::Version
|
162
|
-
version: '0.2'
|
163
|
-
type: :development
|
164
|
-
prerelease: false
|
165
|
-
version_requirements: !ruby/object:Gem::Requirement
|
166
|
-
requirements:
|
167
|
-
- - "~>"
|
168
|
-
- !ruby/object:Gem::Version
|
169
|
-
version: '0.2'
|
170
142
|
- !ruby/object:Gem::Dependency
|
171
143
|
name: rspec
|
172
144
|
requirement: !ruby/object:Gem::Requirement
|
@@ -280,7 +252,9 @@ files:
|
|
280
252
|
- CHANGELOG.md
|
281
253
|
- CODE_OF_CONDUCT.md
|
282
254
|
- DEPLOYMENT.md
|
255
|
+
- DEVELOPMENT.md
|
283
256
|
- Dockerfile
|
257
|
+
- EXAMPLES.md
|
284
258
|
- Gemfile
|
285
259
|
- Gemfile.lock
|
286
260
|
- Guardfile
|
@@ -389,6 +363,7 @@ files:
|
|
389
363
|
- lib/auth0/api/v2/users.rb
|
390
364
|
- lib/auth0/api/v2/users_by_email.rb
|
391
365
|
- lib/auth0/client.rb
|
366
|
+
- lib/auth0/client_assertion.rb
|
392
367
|
- lib/auth0/exception.rb
|
393
368
|
- lib/auth0/mixins.rb
|
394
369
|
- lib/auth0/mixins/access_token_struct.rb
|
@@ -401,6 +376,7 @@ files:
|
|
401
376
|
- lib/auth0/mixins/validation.rb
|
402
377
|
- lib/auth0/version.rb
|
403
378
|
- lib/auth0_client.rb
|
379
|
+
- opslevel.yml
|
404
380
|
- publish_rubygem.sh
|
405
381
|
- spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_change_password/should_trigger_a_password_reset.yml
|
406
382
|
- spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_fail_with_an_incorrect_email.yml
|
@@ -579,6 +555,7 @@ files:
|
|
579
555
|
- spec/integration/lib/auth0/api/v2/api_user_blocks_spec.rb
|
580
556
|
- spec/integration/lib/auth0/api/v2/api_users_spec.rb
|
581
557
|
- spec/integration/lib/auth0/auth0_client_spec.rb
|
558
|
+
- spec/lib/auth0/api/authentication_endpoints_spec.rb
|
582
559
|
- spec/lib/auth0/api/v2/actions_spec.rb
|
583
560
|
- spec/lib/auth0/api/v2/anomaly_spec.rb
|
584
561
|
- spec/lib/auth0/api/v2/attack_protection_spec.rb
|
@@ -637,7 +614,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
637
614
|
- !ruby/object:Gem::Version
|
638
615
|
version: '0'
|
639
616
|
requirements: []
|
640
|
-
rubygems_version: 3.3.
|
617
|
+
rubygems_version: 3.3.26
|
641
618
|
signing_key:
|
642
619
|
specification_version: 4
|
643
620
|
summary: Auth0 API Client
|