Skip to content

Commit

Permalink
[MultiTenancy] ensure hostname ends with correct hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
that-guy-iain committed May 22, 2024
1 parent f67e60a commit bcab4d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function __construct(
private TenantRepositoryInterface $tenantRepository,
private RequestStack $requestStack,
private string $defaultDatabase,
private string $domain,
) {
}

Expand All @@ -62,6 +63,10 @@ public function getCurrentTenant(bool $refresh = false): TenantInterface
}

$host = $request->getHost();
if (str_ends_with($host, $this->domain)) {
return Tenant::createWithSubdomainAndDatabase($this->defaultDatabase, 'dummy.subdomain');
}

$subdomain = preg_replace('~^([a-z0-9-]+)(\..*)$~', '$1', $host);

try {
Expand Down
1 change: 1 addition & 0 deletions src/Parthenon/Resources/config/services/multi_tenancy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<argument type="service" id="Parthenon\MultiTenancy\Repository\TenantRepositoryInterface" />
<argument type="service" id="request_stack" />
<argument>%parthenon_multi_tenancy_default_database%</argument>
<argument>%parthenon_multi_tenancy_domain%</argument>
</service>
<service id="Parthenon\MultiTenancy\TenantProvider\TenantProviderInterface" alias="Parthenon\MultiTenancy\TenantProvider\CurrentTenantProvider">
</service>
Expand Down

0 comments on commit bcab4d5

Please sign in to comment.