Skip to content

Commit 240a6b7

Browse files
author
3m5/frohberg
committed
TASK: remove Authorization header if username and password are null
1 parent 7a8a85f commit 240a6b7

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

Classes/Domain/Model/Client/ClientConfiguration.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ class ClientConfiguration
3838
protected $scheme = 'http';
3939

4040
/**
41-
* @var string
41+
* @var string|null
4242
*/
43-
protected $username = '';
43+
protected $username = null;
4444

4545
/**
46-
* @var string
46+
* @var string|null
4747
*/
48-
protected $password = '';
48+
protected $password = null;
4949

5050
/**
5151
* @Flow\Inject
@@ -120,7 +120,7 @@ public function getUsername(): string
120120
* @param string $username
121121
* @return void
122122
*/
123-
public function setUsername(string $username): void
123+
public function setUsername(?string $username): void
124124
{
125125
$this->username = $username;
126126
}
@@ -138,10 +138,10 @@ public function getPassword(): string
138138
/**
139139
* Sets password
140140
*
141-
* @param string $password
141+
* @param string|null $password
142142
* @return void
143143
*/
144-
public function setPassword(string $password): void
144+
public function setPassword(?string $password): void
145145
{
146146
$this->password = $password;
147147
}
@@ -151,10 +151,15 @@ public function setPassword(string $password): void
151151
*/
152152
public function getUri(): UriInterface
153153
{
154-
return $this->uriFactory->createUri()
154+
$uriWithoutAuthorization = $this->uriFactory->createUri()
155155
->withScheme($this->scheme)
156156
->withHost($this->host)
157-
->withPort($this->port)
158-
->withUserInfo($this->username, $this->password);
157+
->withPort($this->port);
158+
159+
if ($this->username === null && $this->password === null) {
160+
return $uriWithoutAuthorization;
161+
}
162+
163+
return $uriWithoutAuthorization->withUserInfo($this->username, $this->password);
159164
}
160165
}

0 commit comments

Comments
 (0)