Skip to content

Commit

Permalink
Fix regression issue and readd basic auth support (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot authored Jul 4, 2022
1 parent 5d99a0d commit 2d3b10b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
12 changes: 11 additions & 1 deletion app/Client/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,6 +50,11 @@ public function auth(): ?string
return $this->auth;
}

public function basicAuth(): ?string
{
return $this->basicAuth;
}

public function port(): int
{
return intval($this->port);
Expand Down
12 changes: 11 additions & 1 deletion app/Client/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class Factory
/** @var string */
protected $auth = '';

/** @var string */
protected $basicAuth;

/** @var \React\EventLoop\LoopInterface */
protected $loop;

Expand Down Expand Up @@ -67,6 +70,13 @@ public function setAuth(?string $auth)
return $this;
}

public function setBasicAuth(?string $basicAuth)
{
$this->basicAuth = $basicAuth;

return $this;
}

public function setLoop(LoopInterface $loop)
{
$this->loop = $loop;
Expand All @@ -77,7 +87,7 @@ public function setLoop(LoopInterface $loop)
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);
});
}

Expand Down
2 changes: 1 addition & 1 deletion app/Client/Http/Modifiers/CheckBasicAuthentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function requiresAuthentication(): bool
protected function getCredentials()
{
try {
$credentials = explode(':', $this->configuration->auth());
$credentials = explode(':', $this->configuration->basicAuth());

return [
$credentials[0] => $credentials[1],
Expand Down
3 changes: 2 additions & 1 deletion app/Commands/ShareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

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';

Expand Down Expand Up @@ -53,6 +53,7 @@ public function handle()
->setHost($this->getServerHost())
->setPort($this->getServerPort())
->setAuth($auth)
->setBasicAuth($this->option('basicAuth'))
->createClient()
->share(
$this->argument('host'),
Expand Down

0 comments on commit 2d3b10b

Please sign in to comment.