Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/PublicKey/PublicKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,20 @@ public static function verify(Token $token): bool
throw new TokenVerificationException("Issuer scheme is not '{$scheme}'", 200);
}

$hostname = $_ENV['LV_PLUGIN_COMPONENT_REGISTRATION_HOSTNAME'] ?? 'backend.leadvertex.com';
if (!preg_match('~(^|\.)' . preg_quote($hostname) . '$~ui', $endpoint['host'])) {
throw new TokenVerificationException("Issuer hostname is not '{$hostname}'", 300);
$hostnames = explode(',', $_ENV['LV_PLUGIN_COMPONENT_REGISTRATION_HOSTNAME']) ??
['backend.leadvertex.com', 'backend.salesrender.com'];
$hostnames = array_map('trim', $hostnames);

$invalidHostname = true;
foreach ($hostnames as $hostname) {
if (preg_match('~(^|\.)' . preg_quote($hostname) . '$~ui', $endpoint['host'])) {
$invalidHostname = false;
break;
}
}
if ($invalidHostname) {
throw new TokenVerificationException(sprintf("Issuer hostname is not in '{%s}'",
implode(',', $hostnames)), 300);
}

$hash = $token->getHeader('pkey');
Expand Down