From 2d3b10b63d95969863bd743581b47d22c7a6a111 Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Mon, 4 Jul 2022 13:26:21 +0200 Subject: [PATCH] Fix regression issue and readd basic auth support (#328) --- app/Client/Configuration.php | 12 +++++++++++- app/Client/Factory.php | 12 +++++++++++- .../Http/Modifiers/CheckBasicAuthentication.php | 2 +- app/Commands/ShareCommand.php | 3 ++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/Client/Configuration.php b/app/Client/Configuration.php index 0fd9acf..c87df2c 100644 --- a/app/Client/Configuration.php +++ b/app/Client/Configuration.php @@ -16,13 +16,18 @@ class Configuration /** @var string|null */ protected $auth; - public function __construct(string $host, int $port, ?string $auth = null) + /** @var string|null */ + protected $basicAuth; + + public function __construct(string $host, int $port, ?string $auth = null, ?string $basicAuth = null) { $this->serverHost = $this->host = $host; $this->port = $port; $this->auth = $auth; + + $this->basicAuth = $basicAuth; } public function host(): string @@ -45,6 +50,11 @@ class Configuration return $this->auth; } + public function basicAuth(): ?string + { + return $this->basicAuth; + } + public function port(): int { return intval($this->port); diff --git a/app/Client/Factory.php b/app/Client/Factory.php index 59ab54e..858ba82 100644 --- a/app/Client/Factory.php +++ b/app/Client/Factory.php @@ -28,6 +28,9 @@ class Factory /** @var string */ protected $auth = ''; + /** @var string */ + protected $basicAuth; + /** @var \React\EventLoop\LoopInterface */ protected $loop; @@ -67,6 +70,13 @@ class Factory return $this; } + public function setBasicAuth(?string $basicAuth) + { + $this->basicAuth = $basicAuth; + + return $this; + } + public function setLoop(LoopInterface $loop) { $this->loop = $loop; @@ -77,7 +87,7 @@ class Factory protected function bindConfiguration() { app()->singleton(Configuration::class, function ($app) { - return new Configuration($this->host, $this->port, $this->auth); + return new Configuration($this->host, $this->port, $this->auth, $this->basicAuth); }); } diff --git a/app/Client/Http/Modifiers/CheckBasicAuthentication.php b/app/Client/Http/Modifiers/CheckBasicAuthentication.php index 4e0addb..3ccd2cc 100644 --- a/app/Client/Http/Modifiers/CheckBasicAuthentication.php +++ b/app/Client/Http/Modifiers/CheckBasicAuthentication.php @@ -89,7 +89,7 @@ class CheckBasicAuthentication protected function getCredentials() { try { - $credentials = explode(':', $this->configuration->auth()); + $credentials = explode(':', $this->configuration->basicAuth()); return [ $credentials[0] => $credentials[1], diff --git a/app/Commands/ShareCommand.php b/app/Commands/ShareCommand.php index fed6503..f8193b8 100644 --- a/app/Commands/ShareCommand.php +++ b/app/Commands/ShareCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Output\OutputInterface; class ShareCommand extends ServerAwareCommand { - protected $signature = 'share {host} {--subdomain=} {--auth=} {--dns=} {--domain=}'; + protected $signature = 'share {host} {--subdomain=} {--auth=} {--basicAuth=} {--dns=} {--domain=}'; protected $description = 'Share a local url with a remote expose server'; @@ -53,6 +53,7 @@ class ShareCommand extends ServerAwareCommand ->setHost($this->getServerHost()) ->setPort($this->getServerPort()) ->setAuth($auth) + ->setBasicAuth($this->option('basicAuth')) ->createClient() ->share( $this->argument('host'),