This commit is contained in:
Marcel Pociot
2020-05-03 21:38:33 +02:00
parent 141412762a
commit 7d0a570d85
7 changed files with 83 additions and 13 deletions

View File

@@ -65,13 +65,13 @@ class Client
}); });
$connection->on('authenticationFailed', function ($data) use ($deferred) { $connection->on('authenticationFailed', function ($data) use ($deferred) {
$this->logger->error($data->data->message); $this->logger->error($data->message);
$this->exit($deferred); $this->exit($deferred);
}); });
$connection->on('subdomainTaken', function ($data) use ($deferred) { $connection->on('subdomainTaken', function ($data) use ($deferred) {
$this->logger->error($data->data->message); $this->logger->error($data->message);
$this->exit($deferred); $this->exit($deferred);
}); });
@@ -94,6 +94,7 @@ class Client
$host .= ":{$this->configuration->port()}"; $host .= ":{$this->configuration->port()}";
} }
$this->logger->info($data->message);
$this->logger->info("Connected to {$httpProtocol}://{$data->subdomain}.{$host}"); $this->logger->info("Connected to {$httpProtocol}://{$data->subdomain}.{$host}");
static::$subdomains[] = "$data->subdomain.{$this->configuration->host()}:{$this->configuration->port()}"; static::$subdomains[] = "$data->subdomain.{$this->configuration->host()}:{$this->configuration->port()}";

View File

@@ -34,10 +34,10 @@ class ControlConnection
$this->socket->on('message', function (Message $message) { $this->socket->on('message', function (Message $message) {
$decodedEntry = json_decode($message); $decodedEntry = json_decode($message);
$this->emit($decodedEntry->event ?? '', [$decodedEntry]); $this->emit($decodedEntry->event ?? '', [$decodedEntry->data]);
if (method_exists($this, $decodedEntry->event ?? '')) { if (method_exists($this, $decodedEntry->event ?? '')) {
call_user_func([$this, $decodedEntry->event], $decodedEntry); call_user_func([$this, $decodedEntry->event], $decodedEntry->data);
} }
}); });
} }

View File

@@ -45,8 +45,10 @@ class ControlConnection
{ {
$this->socket->send(json_encode([ $this->socket->send(json_encode([
'event' => 'createProxy', 'event' => 'createProxy',
'request_id' => $requestId, 'data' => [
'client_id' => $this->client_id, 'request_id' => $requestId,
'client_id' => $this->client_id,
],
])); ]));
} }
} }

View File

@@ -32,6 +32,12 @@ class SaveSettingsController extends AdminController
{ {
config()->set('expose.admin.validate_auth_tokens', $request->has('validate_auth_tokens')); config()->set('expose.admin.validate_auth_tokens', $request->has('validate_auth_tokens'));
config()->set('expose.admin.messages.invalid_auth_token', $request->get('invalid_auth_token'));
config()->set('expose.admin.messages.subdomain_taken', $request->get('subdomain_taken'));
config()->set('expose.admin.messages.message_of_the_day', $request->get('motd'));
$httpConnection->send(str(new Response(301, [ $httpConnection->send(str(new Response(301, [
'Location' => '/settings' 'Location' => '/settings'
]))); ])));

View File

@@ -89,8 +89,11 @@ class ControlMessageController implements MessageComponentInterface
$connection->send(json_encode([ $connection->send(json_encode([
'event' => 'authenticated', 'event' => 'authenticated',
'subdomain' => $connectionInfo->subdomain, 'data' => [
'client_id' => $connectionInfo->client_id 'message' => config('expose.admin.messages.message_of_the_day'),
'subdomain' => $connectionInfo->subdomain,
'client_id' => $connectionInfo->client_id
],
])); ]));
}, function () use ($connection) { }, function () use ($connection) {
$connection->send(json_encode([ $connection->send(json_encode([

View File

@@ -1,5 +1,7 @@
<html> <html>
<head> <head>
<title>Expose</title>
<meta charset="UTF-8">
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script> <script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tailwindcss/ui@latest/dist/tailwind-ui.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tailwindcss/ui@latest/dist/tailwind-ui.min.css">
</head> </head>

View File

@@ -11,7 +11,9 @@
<div role="group" aria-labelledby="label-email"> <div role="group" aria-labelledby="label-email">
<div class="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-baseline"> <div class="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-baseline">
<div> <div>
<div class="text-base leading-6 font-medium text-gray-900 sm:text-sm sm:leading-5 sm:text-gray-700" id="label-email"> <div
class="text-base leading-6 font-medium text-gray-900 sm:text-sm sm:leading-5 sm:text-gray-700"
id="label-email">
Authentication Authentication
</div> </div>
</div> </div>
@@ -23,17 +25,71 @@
type="checkbox" type="checkbox"
name="validate_auth_tokens" name="validate_auth_tokens"
value="1" value="1"
{% if configuration.validate_auth_tokens %} checked="checked" {% endif %} {% if configuration.validate_auth_tokens %} checked="checked" {% endif %}
class="form-checkbox h-4 w-4 text-indigo-600 transition duration-150 ease-in-out" /> class="form-checkbox h-4 w-4 text-indigo-600 transition duration-150 ease-in-out"/>
</div> </div>
<div class="pl-7 text-sm leading-5"> <div class="pl-7 text-sm leading-5">
<label for="authentication" class="font-medium text-gray-700">Require authentication tokens</label> <label for="authentication" class="font-medium text-gray-700">Require
<p class="text-gray-500">Only allow connection from clients with valid authentication tokens</p> authentication tokens</label>
<p class="text-gray-500">Only allow connection from clients with
valid authentication tokens</p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div
class="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5">
<label for="motd"
class="block text-sm font-medium leading-5 text-gray-700 sm:mt-px sm:pt-2">
Message of the day
</label>
<div class="mt-1 sm:mt-0 sm:col-span-2">
<div class="max-w-lg flex rounded-md shadow-sm">
<textarea id="motd" name="motd" rows="3"
class="form-textarea block w-full transition duration-150 ease-in-out sm:text-sm sm:leading-5">{{ attribute(configuration, 'messages.message_of_the_day') }}</textarea>
</div>
<p class="mt-2 text-sm text-gray-500">This message will be shown, when a
successful connection can be established.</p>
</div>
</div>
<div
class="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5">
<label for="invalid_auth_token"
class="block text-sm font-medium leading-5 text-gray-700 sm:mt-px sm:pt-2">
Authentication Failed
</label>
<div class="mt-1 sm:mt-0 sm:col-span-2">
<div class="max-w-lg flex rounded-md shadow-sm">
<textarea id="invalid_auth_token"
name="invalid_auth_token"
rows="3"
class="form-textarea block w-full transition duration-150 ease-in-out sm:text-sm sm:leading-5">{{ attribute(configuration, 'messages.invalid_auth_token') }}</textarea>
</div>
<p class="mt-2 text-sm text-gray-500">This message will be shown, when a
user tries to connect with an invalid authentication token.</p>
</div>
</div>
<div
class="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5">
<label for="subdomain_taken"
class="block text-sm font-medium leading-5 text-gray-700 sm:mt-px sm:pt-2">
Subdomain taken
</label>
<div class="mt-1 sm:mt-0 sm:col-span-2">
<div class="max-w-lg flex rounded-md shadow-sm">
<textarea id="subdomain_taken" name="subdomain_taken" rows="3"
class="form-textarea block w-full transition duration-150 ease-in-out sm:text-sm sm:leading-5">{{ attribute(configuration, 'messages.subdomain_taken') }}</textarea>
</div>
<p class="mt-2 text-sm text-gray-500">This message will be shown, when a
user tries to connect with an already registered subdomain. You can use
<code class="font-mono bg-gray-500 text-white p-1">:subdomain</code> as
a placeholder.</p>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>