Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: remove Authorization header if username and password are null #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions Classes/Domain/Model/Client/ClientConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ class ClientConfiguration
protected $scheme = 'http';

/**
* @var string
* @var string|null
*/
protected $username = '';
protected $username = null;

/**
* @var string
* @var string|null
*/
protected $password = '';
protected $password = null;

/**
* @Flow\Inject
Expand Down Expand Up @@ -120,7 +120,7 @@ public function getUsername(): string
* @param string $username
* @return void
*/
public function setUsername(string $username): void
public function setUsername(?string $username): void
{
$this->username = $username;
}
Expand All @@ -138,10 +138,10 @@ public function getPassword(): string
/**
* Sets password
*
* @param string $password
* @param string|null $password
* @return void
*/
public function setPassword(string $password): void
public function setPassword(?string $password): void
{
$this->password = $password;
}
Expand All @@ -151,10 +151,15 @@ public function setPassword(string $password): void
*/
public function getUri(): UriInterface
{
return $this->uriFactory->createUri()
$uriWithoutAuthorization = $this->uriFactory->createUri()
->withScheme($this->scheme)
->withHost($this->host)
->withPort($this->port)
->withUserInfo($this->username, $this->password);
->withPort($this->port);

if ($this->username === null && $this->password === null) {
return $uriWithoutAuthorization;
}

return $uriWithoutAuthorization->withUserInfo($this->username, $this->password);
}
}