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 */
|
||||
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);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user