diff --git a/src/Token.php b/src/Token.php index cede70ae..de125e9e 100644 --- a/src/Token.php +++ b/src/Token.php @@ -254,6 +254,7 @@ public function validate( ?int $tokenLeeway = null, ?int $tokenNow = null, ): self { + $tenantDomain = $this->configuration->formatDomain(true) . "/"; $tokenIssuer ??= $this->configuration->formatDomain() . '/'; $tokenAudience ??= $this->configuration->getAudience() ?? []; $tokenOrganization ??= $this->configuration->getOrganization() ?? null; @@ -275,8 +276,16 @@ public function validate( } } + try { + $validator->issuer($tokenIssuer); + } catch (InvalidTokenException $invalidTokenException) { + if($tenantDomain !== $tokenIssuer) { + $validator->issuer($tenantDomain); + } + throw $invalidTokenException; + } + $validator - ->issuer($tokenIssuer) ->audience($tokenAudience) ->expiration($tokenLeeway, $tokenNow);