mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
Fix regression issue and readd basic auth support (#328)
This commit is contained in:
@@ -16,13 +16,18 @@ class Configuration
|
|||||||
/** @var string|null */
|
/** @var string|null */
|
||||||
protected $auth;
|
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->serverHost = $this->host = $host;
|
||||||
|
|
||||||
$this->port = $port;
|
$this->port = $port;
|
||||||
|
|
||||||
$this->auth = $auth;
|
$this->auth = $auth;
|
||||||
|
|
||||||
|
$this->basicAuth = $basicAuth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function host(): string
|
public function host(): string
|
||||||
@@ -45,6 +50,11 @@ class Configuration
|
|||||||
return $this->auth;
|
return $this->auth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function basicAuth(): ?string
|
||||||
|
{
|
||||||
|
return $this->basicAuth;
|
||||||
|
}
|
||||||
|
|
||||||
public function port(): int
|
public function port(): int
|
||||||
{
|
{
|
||||||
return intval($this->port);
|
return intval($this->port);
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ class Factory
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected $auth = '';
|
protected $auth = '';
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $basicAuth;
|
||||||
|
|
||||||
/** @var \React\EventLoop\LoopInterface */
|
/** @var \React\EventLoop\LoopInterface */
|
||||||
protected $loop;
|
protected $loop;
|
||||||
|
|
||||||
@@ -67,6 +70,13 @@ class Factory
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setBasicAuth(?string $basicAuth)
|
||||||
|
{
|
||||||
|
$this->basicAuth = $basicAuth;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setLoop(LoopInterface $loop)
|
public function setLoop(LoopInterface $loop)
|
||||||
{
|
{
|
||||||
$this->loop = $loop;
|
$this->loop = $loop;
|
||||||
@@ -77,7 +87,7 @@ class Factory
|
|||||||
protected function bindConfiguration()
|
protected function bindConfiguration()
|
||||||
{
|
{
|
||||||
app()->singleton(Configuration::class, function ($app) {
|
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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class CheckBasicAuthentication
|
|||||||
protected function getCredentials()
|
protected function getCredentials()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$credentials = explode(':', $this->configuration->auth());
|
$credentials = explode(':', $this->configuration->basicAuth());
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$credentials[0] => $credentials[1],
|
$credentials[0] => $credentials[1],
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||||||
|
|
||||||
class ShareCommand extends ServerAwareCommand
|
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';
|
protected $description = 'Share a local url with a remote expose server';
|
||||||
|
|
||||||
@@ -53,6 +53,7 @@ class ShareCommand extends ServerAwareCommand
|
|||||||
->setHost($this->getServerHost())
|
->setHost($this->getServerHost())
|
||||||
->setPort($this->getServerPort())
|
->setPort($this->getServerPort())
|
||||||
->setAuth($auth)
|
->setAuth($auth)
|
||||||
|
->setBasicAuth($this->option('basicAuth'))
|
||||||
->createClient()
|
->createClient()
|
||||||
->share(
|
->share(
|
||||||
$this->argument('host'),
|
$this->argument('host'),
|
||||||
|
|||||||
Reference in New Issue
Block a user