Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dd2fb85

Browse files
committed
bug #13633 [ServerBag] Handled bearer authorization header in REDIRECT_ form (Lance0312)
This PR was merged into the 2.3 branch. Discussion ---------- [ServerBag] Handled bearer authorization header in REDIRECT_ form | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Apache rewrite module renames client request header (`HTTP_`) by prepending `REDIRECT_` to it. http basic authentication and http digest authentication are properly processed in REDIRECT_ form, while bearer is processed in HTTP_ form, but dropped in REDIRECT_ form. Example: The following auth headers are handled in ServerBag, ``` HTTP_AUTHORIZATION => Basic aGVsbG86d29ybGQ= REDIREDCT_HTTP_AUTHOIZATION => Basic aGVsbG86d29ybGQ= HTTP_AUTHORIZATION => Digest blah REDIRECT_HTTP_AUTHORIZATION => Digest blah HTTP_AUTHORIZATION => Bearer mF_9.B5f-4.1JqM ``` while ``` REDIRECT_HTTP_AUTHORIZATION => Bearer mF_9.B5f-4.1JqM ``` is dropped. Commits ------- 7b2e2df Handled bearer authorization header in REDIRECT_ form
2 parents 2ffd5a4 + 7b2e2df commit dd2fb85

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/Symfony/Component/HttpFoundation/ServerBag.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ public function getHeaders()
7575
// In some circumstances PHP_AUTH_DIGEST needs to be set
7676
$headers['PHP_AUTH_DIGEST'] = $authorizationHeader;
7777
$this->parameters['PHP_AUTH_DIGEST'] = $authorizationHeader;
78+
} elseif (0 === stripos($authorizationHeader, 'bearer ')) {
79+
/*
80+
* XXX: Since there is no PHP_AUTH_BEARER in PHP predefined variables,
81+
* I'll just set $headers['AUTHORIZATION'] here.
82+
* http://php.net/manual/en/reserved.variables.server.php
83+
*/
84+
$headers['AUTHORIZATION'] = $authorizationHeader;
7885
}
7986
}
8087
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,14 @@ public function testOAuthBearerAuth()
141141
'AUTHORIZATION' => $headerContent,
142142
), $bag->getHeaders());
143143
}
144+
145+
public function testOAuthBearerAuthWithRedirect()
146+
{
147+
$headerContent = 'Bearer L-yLEOr9zhmUYRkzN1jwwxwQ-PBNiKDc8dgfB4hTfvo';
148+
$bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => $headerContent));
149+
150+
$this->assertEquals(array(
151+
'AUTHORIZATION' => $headerContent,
152+
), $bag->getHeaders());
153+
}
144154
}

0 commit comments

Comments
 (0)