Fix regression issue and readd basic auth support (#328)

This commit is contained in:
Marcel Pociot
2022-07-04 13:26:21 +02:00
committed by GitHub
parent 5d99a0d7d8
commit 2d3b10b63d
4 changed files with 25 additions and 4 deletions

View File

@@ -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);

View File

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

View File

@@ -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],

View File

@@ -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'),