Skip to content

Commit 57d9eda

Browse files
authored
Require domain configuration with management strategy (#589)
1 parent effb723 commit 57d9eda

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Configuration/SdkConfiguration.php

+4
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,10 @@ private function validateStateApi(): void
527527
*/
528528
private function validateStateManagement(): void
529529
{
530+
if (! $this->hasDomain()) {
531+
throw \Auth0\SDK\Exception\ConfigurationException::requiresDomain();
532+
}
533+
530534
if (! $this->hasManagementToken()) {
531535
if (! $this->hasClientId()) {
532536
throw \Auth0\SDK\Exception\ConfigurationException::requiresClientId();

tests/Unit/Configuration/SdkConfigurationTest.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,26 @@
232232
]);
233233
})->throws(\Auth0\SDK\Exception\ConfigurationException::class, \Auth0\SDK\Exception\ConfigurationException::MSG_REQUIRES_AUDIENCE);
234234

235-
test('a `management` strategy requires a client id if a management token is not provided', function(): void
235+
test('a `management` strategy requires a domain', function(): void
236236
{
237237
$sdk = new SdkConfiguration([
238238
'strategy' => 'management'
239239
]);
240+
})->throws(\Auth0\SDK\Exception\ConfigurationException::class, \Auth0\SDK\Exception\ConfigurationException::MSG_REQUIRES_DOMAIN);
241+
242+
test('a `management` strategy requires a client id if a management token is not provided', function(): void
243+
{
244+
$sdk = new SdkConfiguration([
245+
'strategy' => 'management',
246+
'domain' => uniqid()
247+
]);
240248
})->throws(\Auth0\SDK\Exception\ConfigurationException::class, \Auth0\SDK\Exception\ConfigurationException::MSG_REQUIRES_CLIENT_ID);
241249

242250
test('a `management` strategy requires a client secret if a management token is not provided', function(): void
243251
{
244252
$sdk = new SdkConfiguration([
245253
'strategy' => 'management',
254+
'domain' => uniqid(),
246255
'clientId' => uniqid()
247256
]);
248257
})->throws(\Auth0\SDK\Exception\ConfigurationException::class, \Auth0\SDK\Exception\ConfigurationException::MSG_REQUIRES_CLIENT_SECRET);
@@ -251,6 +260,7 @@
251260
{
252261
$sdk = new SdkConfiguration([
253262
'strategy' => 'management',
263+
'domain' => uniqid(),
254264
'managementToken' => uniqid()
255265
]);
256266

0 commit comments

Comments
 (0)