|
32 | 32 | * @method SdkConfiguration setClientId(?string $clientId = null)
|
33 | 33 | * @method SdkConfiguration setClientSecret(?string $clientSecret = null)
|
34 | 34 | * @method SdkConfiguration setDomain(?string $domain = null)
|
| 35 | + * @method SdkConfiguration setCustomDomain(?string $customDomain = null) |
35 | 36 | * @method SdkConfiguration setEventListenerProvider(?ListenerProviderInterface $eventListenerProvider = null)
|
36 | 37 | * @method SdkConfiguration setHttpClient(?ClientInterface $httpClient = null)
|
37 | 38 | * @method SdkConfiguration setHttpMaxRetries(int $httpMaxRetires = 3)
|
|
73 | 74 | * @method string|null getClientId(?\Throwable $exceptionIfNull = null)
|
74 | 75 | * @method string|null getClientSecret(?\Throwable $exceptionIfNull = null)
|
75 | 76 | * @method string|string getDomain(?\Throwable $exceptionIfNull = null)
|
| 77 | + * @method string|string getCustomDomain(?\Throwable $exceptionIfNull = null) |
76 | 78 | * @method ListenerProviderInterface|null getEventListenerProvider(?\Throwable $exceptionIfNull = null)
|
77 | 79 | * @method ClientInterface|null getHttpClient(?\Throwable $exceptionIfNull = null)
|
78 | 80 | * @method int getHttpMaxRetries()
|
|
114 | 116 | * @method bool hasClientId()
|
115 | 117 | * @method bool hasClientSecret()
|
116 | 118 | * @method bool hasDomain()
|
| 119 | + * @method bool hasCustomDomain() |
117 | 120 | * @method bool hasEventListenerProvider()
|
118 | 121 | * @method bool hasHttpClient()
|
119 | 122 | * @method bool hasHttpMaxRetries()
|
@@ -163,7 +166,8 @@ final class SdkConfiguration implements ConfigurableContract
|
163 | 166 | *
|
164 | 167 | * @param array<mixed>|null $configuration An key-value array matching this constructor's arguments. Overrides any other passed arguments with the same key name.
|
165 | 168 | * @param string|null $strategy Defaults to 'webapp'. Should be assigned either 'api', 'management', or 'webapp' to specify the type of application the SDK is being applied to. Determines what configuration options will be required at initialization.
|
166 |
| - * @param string|null $domain Auth0 domain for your tenant. |
| 169 | + * @param string|null $domain Auth0 domain for your tenant, found in your Auth0 Application settings. |
| 170 | + * @param string|null $customDomain If you have configured Auth0 to use a custom domain, configure it here. |
167 | 171 | * @param string|null $clientId Client ID, found in the Auth0 Application settings.
|
168 | 172 | * @param string|null $redirectUri Authentication callback URI, as defined in your Auth0 Application settings.
|
169 | 173 | * @param string|null $clientSecret Client Secret, found in the Auth0 Application settings.
|
@@ -209,6 +213,7 @@ public function __construct(
|
209 | 213 | ?array $configuration = null,
|
210 | 214 | ?string $strategy = 'webapp',
|
211 | 215 | ?string $domain = null,
|
| 216 | + ?string $customDomain = null, |
212 | 217 | ?string $clientId = null,
|
213 | 218 | ?string $redirectUri = null,
|
214 | 219 | ?string $clientSecret = null,
|
@@ -257,12 +262,31 @@ public function __construct(
|
257 | 262 | $this->validateState();
|
258 | 263 | }
|
259 | 264 |
|
| 265 | + /** |
| 266 | + * Return the configured custom or tenant domain, formatted with protocol. |
| 267 | + * |
| 268 | + * @param bool $forceTenantDomain Force the return of the tenant domain even if a custom domain is configured. |
| 269 | + */ |
| 270 | + public function formatDomain( |
| 271 | + bool $forceTenantDomain = false |
| 272 | + ): string { |
| 273 | + if ($this->hasCustomDomain() && ! $forceTenantDomain) { |
| 274 | + return 'https://' . $this->getCustomDomain(); |
| 275 | + } |
| 276 | + |
| 277 | + return 'https://' . $this->getDomain(); |
| 278 | + } |
| 279 | + |
260 | 280 | /**
|
261 | 281 | * Return the configured domain with protocol.
|
262 | 282 | */
|
263 |
| - public function formatDomain(): string |
| 283 | + public function formatCustomDomain(): ?string |
264 | 284 | {
|
265 |
| - return 'https://' . $this->getDomain(); |
| 285 | + if ($this->hasCustomDomain()) { |
| 286 | + return 'https://' . $this->getCustomDomain(); |
| 287 | + } |
| 288 | + |
| 289 | + return null; |
266 | 290 | }
|
267 | 291 |
|
268 | 292 | /**
|
|
0 commit comments