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

@@ -40,6 +40,7 @@ class StoreUsersController extends AdminController
'name' => $request->get('name'),
'auth_token' => (string) Str::uuid(),
'can_specify_subdomains' => (int) $request->get('can_specify_subdomains'),
'can_share_tcp_ports' => (int) $request->get('can_share_tcp_ports'),
];
$this->userRepository

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;
}
}