This commit is contained in:
Marcel Pociot
2020-09-08 10:10:46 +02:00
parent 790d33d548
commit 1fc277fd5e
10 changed files with 183 additions and 3 deletions

View File

@@ -120,6 +120,10 @@ class ControlMessageController implements MessageComponentInterface
protected function handleTcpConnection(ConnectionInterface $connection, $data, $user = null)
{
if (! $this->canShareTcpPorts($connection, $data, $user)) {
return;
}
try {
$connectionInfo = $this->connectionManager->storeTcpConnection($data->port, $connection);
} catch (NoFreePortAvailable $exception) {
@@ -233,4 +237,21 @@ class ControlMessageController implements MessageComponentInterface
return true;
}
protected function canShareTcpPorts(ConnectionInterface $connection, $data, $user)
{
if (! is_null($user) && $user['can_share_tcp_ports'] === 0) {
$connection->send(json_encode([
'event' => 'authenticationFailed',
'data' => [
'message' => config('expose.admin.messages.custom_subdomain_unauthorized'),
],
]));
$connection->close();
return false;
}
return true;
}
}