mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
wip
This commit is contained in:
@@ -74,4 +74,9 @@ class ConnectionManager implements ConnectionManagerContract
|
||||
return $connection->client_id == $clientId;
|
||||
});
|
||||
}
|
||||
|
||||
public function getConnections(): array
|
||||
{
|
||||
return $this->connections;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ class ControlConnection
|
||||
$this->host = $host;
|
||||
$this->subdomain = $subdomain;
|
||||
$this->client_id = $clientId;
|
||||
$this->shared_at = now()->toDateTimeString();
|
||||
}
|
||||
|
||||
public function registerProxy($requestId)
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Contracts\SubdomainGenerator;
|
||||
use App\HttpServer\HttpServer;
|
||||
use App\Server\Connections\ConnectionManager;
|
||||
use App\Server\Http\Controllers\Admin\DeleteUsersController;
|
||||
use App\Server\Http\Controllers\Admin\ListSitesController;
|
||||
use App\Server\Http\Controllers\Admin\ListUsersController;
|
||||
use App\Server\Http\Controllers\Admin\StoreUsersController;
|
||||
use App\Server\Http\Controllers\ControlMessageController;
|
||||
@@ -113,6 +114,12 @@ class Factory
|
||||
'_controller' => app(DeleteUsersController::class),
|
||||
], [], [], null, [], ['DELETE'])
|
||||
);
|
||||
|
||||
$this->routes->add('admin.sites.index',
|
||||
new Route('/expose/sites', [
|
||||
'_controller' => app(ListSitesController::class),
|
||||
], [], [], null, [], ['GET'])
|
||||
);
|
||||
}
|
||||
|
||||
protected function bindConfiguration()
|
||||
@@ -190,7 +197,7 @@ class Factory
|
||||
|
||||
public function validateAuthTokens(bool $validate)
|
||||
{
|
||||
dump($validate);
|
||||
config()->set('expose.validate_auth_tokens', $validate);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
44
app/Server/Http/Controllers/Admin/ListSitesController.php
Normal file
44
app/Server/Http/Controllers/Admin/ListSitesController.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Server\Http\Controllers\Admin;
|
||||
|
||||
use App\Contracts\ConnectionManager;
|
||||
use App\HttpServer\Controllers\PostController;
|
||||
use Clue\React\SQLite\DatabaseInterface;
|
||||
use Clue\React\SQLite\Result;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Http\Request;
|
||||
use Ratchet\ConnectionInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\ArrayLoader;
|
||||
use function GuzzleHttp\Psr7\str;
|
||||
use function GuzzleHttp\Psr7\stream_for;
|
||||
|
||||
class ListSitesController extends PostController
|
||||
{
|
||||
/** @var ConnectionManager */
|
||||
protected $connectionManager;
|
||||
|
||||
public function __construct(ConnectionManager $connectionManager)
|
||||
{
|
||||
$this->connectionManager = $connectionManager;
|
||||
}
|
||||
|
||||
public function handle(Request $request, ConnectionInterface $httpConnection)
|
||||
{
|
||||
$httpConnection->send(
|
||||
respond_html($this->getView(['sites' => $this->connectionManager->getConnections()]))
|
||||
);
|
||||
}
|
||||
|
||||
protected function getView(array $data)
|
||||
{
|
||||
$twig = new Environment(
|
||||
new ArrayLoader([
|
||||
'template' => file_get_contents(base_path('resources/views/admin/sites/index.twig')),
|
||||
])
|
||||
);
|
||||
|
||||
return stream_for($twig->render('template', $data));
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,6 @@ class ControlMessageController implements MessageComponentInterface
|
||||
*/
|
||||
function onOpen(ConnectionInterface $connection)
|
||||
{
|
||||
$this->verifyAuthToken($connection);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,6 +74,10 @@ class ControlMessageController implements MessageComponentInterface
|
||||
|
||||
protected function authenticate(ConnectionInterface $connection, $data)
|
||||
{
|
||||
if (config('expose.validate_auth_tokens') === true) {
|
||||
$this->verifyAuthToken($connection);
|
||||
}
|
||||
|
||||
$connectionInfo = $this->connectionManager->storeConnection($data->host, $data->subdomain, $connection);
|
||||
|
||||
$connection->send(json_encode([
|
||||
|
||||
Reference in New Issue
Block a user