diff --git a/src/Token.php b/src/Token.php index cede70ae..23c7e761 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,17 @@ 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);