8000 bug #17478 [HttpFoundation] Do not overwrite the Authorization header… · symfony/symfony@9a90cde · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a90cde

Browse files
committed
bug #17478 [HttpFoundation] Do not overwrite the Authorization header if it is already set (jakzal)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #17478). Discussion ---------- [HttpFoundation] Do not overwrite the Authorization header if it is already set | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17345 | License | MIT | Doc PR | - Commits ------- 53ebfda [HttpFoundation] Do not overwrite the Authorization header if it is already set
2 parents 385f23e + 53ebfda commit 9a90cde

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Symfony/Component/HttpFoundation/ServerBag.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public function getHeaders()
8686
}
8787
}
8888

89+
if (isset($headers['AUTHORIZATION'])) {
90+
return $headers;
91+
}
92+
8993
// PHP_AUTH_USER/PHP_AUTH_PW
9094
if (isset($headers['PHP_AUTH_USER'])) {
9195
$headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.$headers['PHP_AUTH_PW']);

src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,19 @@ public function testOAuthBearerAuthWithRedirect()
151151
'AUTHORIZATION' => $headerContent,
152152
), $bag->getHeaders());
153153
}
154+
155+
/**
156+
* @see https://github.com/symfony/symfony/issues/17345
157+
*/
158+
public function testItDoesNotOverwriteTheAuthorizationHeaderIfItIsAlreadySet()
159+
{
160+
$headerContent = 'Bearer L-yLEOr9zhmUYRkzN1jwwxwQ-PBNiKDc8dgfB4hTfvo';
161+
$bag = new ServerBag(array('PHP_AUTH_USER' => 'foo', 'HTTP_AUTHORIZATION' => $headerContent));
162+
163+
$this->assertEquals(array(
164+
'AUTHORIZATION' => $headerContent,
165+
'PHP_AUTH_USER' => 'foo',
166+
'PHP_AUTH_PW' => '',
167+
), $bag->getHeaders());
168+
}
154169
}

0 commit comments

Comments
 (0)
0