Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aa3e1a3

Browse filesBrowse files
committed
merged 2.0
2 parents bde26b1 + bdf9b7e commit aa3e1a3
Copy full SHA for aa3e1a3

File tree

Expand file treeCollapse file tree

10 files changed

+91
-13
lines changed
Filter options
Expand file treeCollapse file tree

10 files changed

+91
-13
lines changed

‎src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeIdentEntity.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeIdentEntity.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class CompositeIdentEntity implements UserInterface
2828
/** @Column(type="string") */
2929
public $name;
3030

31-
public function __construct($id1, $id2, $name) {
31+
public function __construct($id1, $id2, $name)
32+
{
3233
$this->id1 = $id1;
3334
$this->id2 = $id2;
3435
$this->name = $name;

‎src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeStringIdentEntity.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeStringIdentEntity.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class CompositeStringIdentEntity
2727
/** @Column(type="string") */
2828
public $name;
2929

30-
public function __construct($id1, $id2, $name) {
30+
public function __construct($id1, $id2, $name)
31+
{
3132
$this->id1 = $id1;
3233
$this->id2 = $id2;
3334
$this->name = $name;

‎src/Symfony/Bridge/Doctrine/Tests/Fixtures/NoToStringSingleIdentEntity.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Fixtures/NoToStringSingleIdentEntity.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class NoToStringSingleIdentEntity
2424
/** @Column(type="string", nullable=true) */
2525
public $name;
2626

27-
public function __construct($id, $name) {
27+
public function __construct($id, $name)
28+
{
2829
$this->id = $id;
2930
$this->name = $name;
3031
}

‎src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleStringIdentEntity.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleStringIdentEntity.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class SingleStringIdentEntity
2424
/** @Column(type="string") */
2525
public $name;
2626

27-
public function __construct($id, $name) {
27+
public function __construct($id, $name)
28+
{
2829
$this->id = $id;
2930
$this->name = $name;
3031
}

‎src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubFilesystemLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubFilesystemLoader.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
// Preventing autoloader throwing E_FATAL when Twig is now available
1515
if (!class_exists('Twig_Environment')) {
16-
class StubFilesystemLoader {
16+
class StubFilesystemLoader
17+
{
1718
}
1819
} else {
1920
class StubFilesystemLoader extends \Twig_Loader_Filesystem

‎src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ protected function tearDown()
3434
$this->removeDirectory($this->directory);
3535
}
3636

37-
protected function removeDirectory($directory) {
37+
protected function removeDirectory($directory)
38+
{
3839
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory), \RecursiveIteratorIterator::CHILD_FIRST);
3940
foreach ($iterator as $path) {
4041
if (preg_match('#/\.\.?$#', $path->__toString())) {

‎src/Symfony/Component/HttpFoundation/ServerBag.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/ServerBag.php
+35-3Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*
1717
* @author Fabien Potencier <fabien@symfony.com>
1818
* @author Bulat Shakirzyanov <mallluhuct@gmail.com>
19+
* @author Robert Kiss <kepten@gmail.com>
1920
*/
2021
class ServerBag extends ParameterBag
2122
{
@@ -37,10 +38,41 @@ public function getHeaders()
3738
}
3839
}
3940

40-
// PHP_AUTH_USER/PHP_AUTH_PW
4141
if (isset($this->parameters['PHP_AUTH_USER'])) {
42-
$pass = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : '';
43-
$headers['AUTHORIZATION'] = 'Basic '.base64_encode($this->parameters['PHP_AUTH_USER'].':'.$pass);
42+
$headers['PHP_AUTH_USER'] = $this->parameters['PHP_AUTH_USER'];
43+
$headers['PHP_AUTH_PW'] = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : '';
44+
} else {
45+
/*
46+
* php-cgi under Apache does not pass HTTP Basic user/pass to PHP by default
47+
* For this workaround to work, add this line to your .htaccess file:
48+
* RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
49+
*
50+
* A sample .htaccess file:
51+
* RewriteEngine On
52+
* RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
53+
* RewriteCond %{REQUEST_FILENAME} !-f
54+
* RewriteRule ^(.*)$ app.php [QSA,L]
55+
*/
56+
57+
$authorizationHeader = null;
58+
if (isset($this->parameters['HTTP_AUTHORIZATION'])) {
59+
$authorizationHeader = $this->parameters['HTTP_AUTHORIZATION'];
60+
} elseif (isset($this->parameters['REDIRECT_HTTP_AUTHORIZATION'])) {
61+
$authorizationHeader = $this->parameters['REDIRECT_HTTP_AUTHORIZATION'];
62+
}
63+
64+
// Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW
65+
if (null !== $authorizationHeader) {
66+
$exploded = explode(':', base64_decode(substr($authorizationHeader, 6)));
67+
if (count($exploded) == 2) {
68+
list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded;
69+
}
70+
}
71+
}
72+
73+
// PHP_AUTH_USER/PHP_AUTH_PW
74+
if (isset($headers['PHP_AUTH_USER'])) {
75+
$headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.$headers['PHP_AUTH_PW']);
4476
}
4577

4678
return $headers;

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php
+40-1Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,52 @@ public function testShouldExtractHeadersFromServerArray()
4040
'CONTENT_LENGTH' => '0',
4141
'ETAG' => 'asdf',
4242
'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'),
43+
'PHP_AUTH_USER' => 'foo',
44+
'PHP_AUTH_PW' => 'bar',
4345
), $bag->getHeaders());
4446
}
4547

4648
public function testHttpPasswordIsOptional()
4749
{
4850
$bag = new ServerBag(array('PHP_AUTH_USER' => 'foo'));
4951

50-
$this->assertEquals(array('AUTHORIZATION' => 'Basic '.base64_encode('foo:')), $bag->getHeaders());
52+
$this->assertEquals(array(
53+
'AUTHORIZATION' => 'Basic '.base64_encode('foo:'),
54+
'PHP_AUTH_USER' => 'foo',
55+
'PHP_AUTH_PW' => ''
56+
), $bag->getHeaders());
57+
}
58+
59+
public function testHttpBasicAuthWithPhpCgi()
60+
{
61+
$bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:bar')));
62+
63+
$this->assertEquals(array(
64+
'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'),
65+
'PHP_AUTH_USER' => 'foo',
66+
'PHP_AUTH_PW' => 'bar'
67+
), $bag->getHeaders());
68+
}
69+
70+
public function testHttpBasicAuthWithPhpCgiRedirect()
71+
{
72+
$bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:bar')));
73+
74+
$this->assertEquals(array(
75+
'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'),
76+
'PHP_AUTH_USER' => 'foo',
77+
'PHP_AUTH_PW' => 'bar'
78+
), $bag->getHeaders());
79+
}
80+
81+
public function testHttpBasicAuthWithPhpCgiEmptyPassword()
82+
{
83+
$bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:')));
84+
85+
$this->assertEquals(array(
86+
'AUTHORIZATION' => 'Basic '.base64_encode('foo:'),
87+
'PHP_AUTH_USER' => 'foo',
88+
'PHP_AUTH_PW' => ''
89+
), $bag->getHeaders());
5190
}
5291
}

‎src/Symfony/Component/Locale/Resources/data/update-data.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Locale/Resources/data/update-data.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ function get_data($index, $dataDir, $locale = 'en', $constraint = null)
125125
return $data;
126126
}
127127

128-
function create_stub_datafile($locale, $target, $data) {
128+
function create_stub_datafile($locale, $target, $data)
129+
{
129130
$template = <<<TEMPLATE
130131
<?php
131132

‎src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function handle(GetResponseEvent $event)
5656
{
5757
$request = $event->getRequest();
5858

59-
if (false === $username = $request->server->get('PHP_AUTH_USER', false)) {
59+
if (false === $username = $request->headers->get('PHP_AUTH_USER', false)) {
6060
return;
6161
}
6262

@@ -71,7 +71,7 @@ public function handle(GetResponseEvent $event)
7171
}
7272

7373
try {
74-
$token = $this->authenticationManager->authenticate(new UsernamePasswordToken($username, $request->server->get('PHP_AUTH_PW'), $this->providerKey));
74+
$token = $this->authenticationManager->authenticate(new UsernamePasswordToken($username, $request->headers->get('PHP_AUTH_PW'), $this->providerKey));
7575
$this->securityContext->setToken($token);
7676
} catch (AuthenticationException $failed) {
7777
$this->securityContext->setToken(null);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.