merged 2.0
This commit is contained in:
commit
aa3e1a3b8c
@ -28,7 +28,8 @@ class CompositeIdentEntity implements UserInterface
|
|||||||
/** @Column(type="string") */
|
/** @Column(type="string") */
|
||||||
public $name;
|
public $name;
|
||||||
|
|
||||||
public function __construct($id1, $id2, $name) {
|
public function __construct($id1, $id2, $name)
|
||||||
|
{
|
||||||
$this->id1 = $id1;
|
$this->id1 = $id1;
|
||||||
$this->id2 = $id2;
|
$this->id2 = $id2;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
@ -27,7 +27,8 @@ class CompositeStringIdentEntity
|
|||||||
/** @Column(type="string") */
|
/** @Column(type="string") */
|
||||||
public $name;
|
public $name;
|
||||||
|
|
||||||
public function __construct($id1, $id2, $name) {
|
public function __construct($id1, $id2, $name)
|
||||||
|
{
|
||||||
$this->id1 = $id1;
|
$this->id1 = $id1;
|
||||||
$this->id2 = $id2;
|
$this->id2 = $id2;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
@ -24,7 +24,8 @@ class NoToStringSingleIdentEntity
|
|||||||
/** @Column(type="string", nullable=true) */
|
/** @Column(type="string", nullable=true) */
|
||||||
public $name;
|
public $name;
|
||||||
|
|
||||||
public function __construct($id, $name) {
|
public function __construct($id, $name)
|
||||||
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,8 @@ class SingleStringIdentEntity
|
|||||||
/** @Column(type="string") */
|
/** @Column(type="string") */
|
||||||
public $name;
|
public $name;
|
||||||
|
|
||||||
public function __construct($id, $name) {
|
public function __construct($id, $name)
|
||||||
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,8 @@ namespace Symfony\Bridge\Twig\Tests\Extension\Fixtures;
|
|||||||
|
|
||||||
// Preventing autoloader throwing E_FATAL when Twig is now available
|
// Preventing autoloader throwing E_FATAL when Twig is now available
|
||||||
if (!class_exists('Twig_Environment')) {
|
if (!class_exists('Twig_Environment')) {
|
||||||
class StubFilesystemLoader {
|
class StubFilesystemLoader
|
||||||
|
{
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
class StubFilesystemLoader extends \Twig_Loader_Filesystem
|
class StubFilesystemLoader extends \Twig_Loader_Filesystem
|
||||||
|
@ -34,7 +34,8 @@ class DirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->removeDirectory($this->directory);
|
$this->removeDirectory($this->directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function removeDirectory($directory) {
|
protected function removeDirectory($directory)
|
||||||
|
{
|
||||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory), \RecursiveIteratorIterator::CHILD_FIRST);
|
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory), \RecursiveIteratorIterator::CHILD_FIRST);
|
||||||
foreach ($iterator as $path) {
|
foreach ($iterator as $path) {
|
||||||
if (preg_match('#/\.\.?$#', $path->__toString())) {
|
if (preg_match('#/\.\.?$#', $path->__toString())) {
|
||||||
|
@ -16,6 +16,7 @@ namespace Symfony\Component\HttpFoundation;
|
|||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
* @author Bulat Shakirzyanov <mallluhuct@gmail.com>
|
* @author Bulat Shakirzyanov <mallluhuct@gmail.com>
|
||||||
|
* @author Robert Kiss <kepten@gmail.com>
|
||||||
*/
|
*/
|
||||||
class ServerBag extends ParameterBag
|
class ServerBag extends ParameterBag
|
||||||
{
|
{
|
||||||
@ -37,10 +38,41 @@ class ServerBag extends ParameterBag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PHP_AUTH_USER/PHP_AUTH_PW
|
|
||||||
if (isset($this->parameters['PHP_AUTH_USER'])) {
|
if (isset($this->parameters['PHP_AUTH_USER'])) {
|
||||||
$pass = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : '';
|
$headers['PHP_AUTH_USER'] = $this->parameters['PHP_AUTH_USER'];
|
||||||
$headers['AUTHORIZATION'] = 'Basic '.base64_encode($this->parameters['PHP_AUTH_USER'].':'.$pass);
|
$headers['PHP_AUTH_PW'] = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : '';
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* php-cgi under Apache does not pass HTTP Basic user/pass to PHP by default
|
||||||
|
* For this workaround to work, add this line to your .htaccess file:
|
||||||
|
* RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||||
|
*
|
||||||
|
* A sample .htaccess file:
|
||||||
|
* RewriteEngine On
|
||||||
|
* RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||||
|
* RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
* RewriteRule ^(.*)$ app.php [QSA,L]
|
||||||
|
*/
|
||||||
|
|
||||||
|
$authorizationHeader = null;
|
||||||
|
if (isset($this->parameters['HTTP_AUTHORIZATION'])) {
|
||||||
|
$authorizationHeader = $this->parameters['HTTP_AUTHORIZATION'];
|
||||||
|
} elseif (isset($this->parameters['REDIRECT_HTTP_AUTHORIZATION'])) {
|
||||||
|
$authorizationHeader = $this->parameters['REDIRECT_HTTP_AUTHORIZATION'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW
|
||||||
|
if (null !== $authorizationHeader) {
|
||||||
|
$exploded = explode(':', base64_decode(substr($authorizationHeader, 6)));
|
||||||
|
if (count($exploded) == 2) {
|
||||||
|
list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PHP_AUTH_USER/PHP_AUTH_PW
|
||||||
|
if (isset($headers['PHP_AUTH_USER'])) {
|
||||||
|
$headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.$headers['PHP_AUTH_PW']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $headers;
|
return $headers;
|
||||||
|
@ -40,6 +40,8 @@ class ServerBagTest extends \PHPUnit_Framework_TestCase
|
|||||||
'CONTENT_LENGTH' => '0',
|
'CONTENT_LENGTH' => '0',
|
||||||
'ETAG' => 'asdf',
|
'ETAG' => 'asdf',
|
||||||
'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'),
|
'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'),
|
||||||
|
'PHP_AUTH_USER' => 'foo',
|
||||||
|
'PHP_AUTH_PW' => 'bar',
|
||||||
), $bag->getHeaders());
|
), $bag->getHeaders());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +49,43 @@ class ServerBagTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$bag = new ServerBag(array('PHP_AUTH_USER' => 'foo'));
|
$bag = new ServerBag(array('PHP_AUTH_USER' => 'foo'));
|
||||||
|
|
||||||
$this->assertEquals(array('AUTHORIZATION' => 'Basic '.base64_encode('foo:')), $bag->getHeaders());
|
$this->assertEquals(array(
|
||||||
|
'AUTHORIZATION' => 'Basic '.base64_encode('foo:'),
|
||||||
|
'PHP_AUTH_USER' => 'foo',
|
||||||
|
'PHP_AUTH_PW' => ''
|
||||||
|
), $bag->getHeaders());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHttpBasicAuthWithPhpCgi()
|
||||||
|
{
|
||||||
|
$bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:bar')));
|
||||||
|
|
||||||
|
$this->assertEquals(array(
|
||||||
|
'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'),
|
||||||
|
'PHP_AUTH_USER' => 'foo',
|
||||||
|
'PHP_AUTH_PW' => 'bar'
|
||||||
|
), $bag->getHeaders());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHttpBasicAuthWithPhpCgiRedirect()
|
||||||
|
{
|
||||||
|
$bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:bar')));
|
||||||
|
|
||||||
|
$this->assertEquals(array(
|
||||||
|
'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'),
|
||||||
|
'PHP_AUTH_USER' => 'foo',
|
||||||
|
'PHP_AUTH_PW' => 'bar'
|
||||||
|
), $bag->getHeaders());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHttpBasicAuthWithPhpCgiEmptyPassword()
|
||||||
|
{
|
||||||
|
$bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:')));
|
||||||
|
|
||||||
|
$this->assertEquals(array(
|
||||||
|
'AUTHORIZATION' => 'Basic '.base64_encode('foo:'),
|
||||||
|
'PHP_AUTH_USER' => 'foo',
|
||||||
|
'PHP_AUTH_PW' => ''
|
||||||
|
), $bag->getHeaders());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,8 @@ function get_data($index, $dataDir, $locale = 'en', $constraint = null)
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_stub_datafile($locale, $target, $data) {
|
function create_stub_datafile($locale, $target, $data)
|
||||||
|
{
|
||||||
$template = <<<TEMPLATE
|
$template = <<<TEMPLATE
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class BasicAuthenticationListener implements ListenerInterface
|
|||||||
{
|
{
|
||||||
$request = $event->getRequest();
|
$request = $event->getRequest();
|
||||||
|
|
||||||
if (false === $username = $request->server->get('PHP_AUTH_USER', false)) {
|
if (false === $username = $request->headers->get('PHP_AUTH_USER', false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class BasicAuthenticationListener implements ListenerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$token = $this->authenticationManager->authenticate(new UsernamePasswordToken($username, $request->server->get('PHP_AUTH_PW'), $this->providerKey));
|
$token = $this->authenticationManager->authenticate(new UsernamePasswordToken($username, $request->headers->get('PHP_AUTH_PW'), $this->providerKey));
|
||||||
$this->securityContext->setToken($token);
|
$this->securityContext->setToken($token);
|
||||||
} catch (AuthenticationException $failed) {
|
} catch (AuthenticationException $failed) {
|
||||||
$this->securityContext->setToken(null);
|
$this->securityContext->setToken(null);
|
||||||
|
Reference in New Issue
Block a user