Skip to content

Commit 7b2e2df

Browse files
committed
Handled bearer authorization header in REDIRECT_ form
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.
1 parent ce95fa8 commit 7b2e2df

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)