Merge branch '5.1'
* 5.1: fix forward compatibility with Doctrine DBAL 2.11+ [SecurityBundle] Fix the session listener registration under the new authentication manager allow cursor to be used even when STDIN is not defined
This commit is contained in:
commit
5a74790bfd
@ -168,14 +168,6 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||||||
$container->getDefinition('security.authentication.guard_handler')
|
$container->getDefinition('security.authentication.guard_handler')
|
||||||
->replaceArgument(2, $this->statelessFirewallKeys);
|
->replaceArgument(2, $this->statelessFirewallKeys);
|
||||||
|
|
||||||
if ($this->authenticatorManagerEnabled) {
|
|
||||||
foreach ($this->statelessFirewallKeys as $statelessFirewallId) {
|
|
||||||
$container
|
|
||||||
->setDefinition('security.listener.session.'.$statelessFirewallId, new ChildDefinition('security.listener.session'))
|
|
||||||
->addTag('kernel.event_subscriber', ['dispatcher' => 'security.event_dispatcher.'.$statelessFirewallId]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($config['encoders']) {
|
if ($config['encoders']) {
|
||||||
$this->createEncoders($config['encoders'], $container);
|
$this->createEncoders($config['encoders'], $container);
|
||||||
}
|
}
|
||||||
@ -373,6 +365,12 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||||||
$contextKey = $firewall['context'] ?? $id;
|
$contextKey = $firewall['context'] ?? $id;
|
||||||
$listeners[] = new Reference($contextListenerId = $this->createContextListener($container, $contextKey));
|
$listeners[] = new Reference($contextListenerId = $this->createContextListener($container, $contextKey));
|
||||||
$sessionStrategyId = 'security.authentication.session_strategy';
|
$sessionStrategyId = 'security.authentication.session_strategy';
|
||||||
|
|
||||||
|
if ($this->authenticatorManagerEnabled) {
|
||||||
|
$container
|
||||||
|
->setDefinition('security.listener.session.'.$id, new ChildDefinition('security.listener.session'))
|
||||||
|
->addTag('kernel.event_subscriber', ['dispatcher' => $firewallEventDispatcherId]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->statelessFirewallKeys[] = $id;
|
$this->statelessFirewallKeys[] = $id;
|
||||||
$sessionStrategyId = 'security.authentication.session_strategy_noop';
|
$sessionStrategyId = 'security.authentication.session_strategy_noop';
|
||||||
|
@ -63,7 +63,6 @@
|
|||||||
class="Symfony\Component\Security\Http\EventListener\SessionStrategyListener"
|
class="Symfony\Component\Security\Http\EventListener\SessionStrategyListener"
|
||||||
abstract="true">
|
abstract="true">
|
||||||
<argument type="service" id="security.authentication.session_strategy" />
|
<argument type="service" id="security.authentication.session_strategy" />
|
||||||
<argument type="abstract">stateless firewall keys</argument>
|
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="security.listener.remember_me"
|
<service id="security.listener.remember_me"
|
||||||
|
@ -559,6 +559,48 @@ class SecurityExtensionTest extends TestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCompilesWithoutSessionListenerWithStatelessFirewallWithAuthenticationManager()
|
||||||
|
{
|
||||||
|
$container = $this->getRawContainer();
|
||||||
|
|
||||||
|
$firewallId = 'stateless_firewall';
|
||||||
|
$container->loadFromExtension('security', [
|
||||||
|
'enable_authenticator_manager' => true,
|
||||||
|
'firewalls' => [
|
||||||
|
$firewallId => [
|
||||||
|
'pattern' => '/.*',
|
||||||
|
'stateless' => true,
|
||||||
|
'http_basic' => null,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$container->compile();
|
||||||
|
|
||||||
|
$this->assertFalse($container->has('security.listener.session.'.$firewallId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCompilesWithSessionListenerWithStatefulllFirewallWithAuthenticationManager()
|
||||||
|
{
|
||||||
|
$container = $this->getRawContainer();
|
||||||
|
|
||||||
|
$firewallId = 'statefull_firewall';
|
||||||
|
$container->loadFromExtension('security', [
|
||||||
|
'enable_authenticator_manager' => true,
|
||||||
|
'firewalls' => [
|
||||||
|
$firewallId => [
|
||||||
|
'pattern' => '/.*',
|
||||||
|
'stateless' => false,
|
||||||
|
'http_basic' => null,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$container->compile();
|
||||||
|
|
||||||
|
$this->assertTrue($container->has('security.listener.session.'.$firewallId));
|
||||||
|
}
|
||||||
|
|
||||||
protected function getRawContainer()
|
protected function getRawContainer()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
@ -21,10 +21,10 @@ final class Cursor
|
|||||||
private $output;
|
private $output;
|
||||||
private $input;
|
private $input;
|
||||||
|
|
||||||
public function __construct(OutputInterface $output, $input = STDIN)
|
public function __construct(OutputInterface $output, $input = null)
|
||||||
{
|
{
|
||||||
$this->output = $output;
|
$this->output = $output;
|
||||||
$this->input = $input;
|
$this->input = $input ?? (\defined('STDIN') ? STDIN : fopen('php://input', 'r+'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function moveUp(int $lines = 1): self
|
public function moveUp(int $lines = 1): self
|
||||||
|
@ -13,13 +13,13 @@ namespace Symfony\Component\Messenger\Bridge\Doctrine\Tests\Transport;
|
|||||||
|
|
||||||
use Doctrine\DBAL\DBALException;
|
use Doctrine\DBAL\DBALException;
|
||||||
use Doctrine\DBAL\Driver\ResultStatement;
|
use Doctrine\DBAL\Driver\ResultStatement;
|
||||||
use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement;
|
|
||||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||||
use Doctrine\DBAL\Query\QueryBuilder;
|
use Doctrine\DBAL\Query\QueryBuilder;
|
||||||
use Doctrine\DBAL\Schema\AbstractSchemaManager;
|
use Doctrine\DBAL\Schema\AbstractSchemaManager;
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Doctrine\DBAL\Schema\SchemaConfig;
|
use Doctrine\DBAL\Schema\SchemaConfig;
|
||||||
use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer;
|
use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer;
|
||||||
|
use Doctrine\DBAL\Statement;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Messenger\Bridge\Doctrine\Tests\Fixtures\DummyMessage;
|
use Symfony\Component\Messenger\Bridge\Doctrine\Tests\Fixtures\DummyMessage;
|
||||||
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection;
|
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection;
|
||||||
@ -146,14 +146,10 @@ class ConnectionTest extends TestCase
|
|||||||
|
|
||||||
private function getStatementMock($expectedResult): ResultStatement
|
private function getStatementMock($expectedResult): ResultStatement
|
||||||
{
|
{
|
||||||
$mockedInterface = interface_exists(ForwardCompatibleResultStatement::class)
|
$stmt = $this->createMock(Statement::class);
|
||||||
? ForwardCompatibleResultStatement::class
|
|
||||||
: ResultStatement::class;
|
|
||||||
|
|
||||||
$stmt = $this->createMock($mockedInterface);
|
|
||||||
|
|
||||||
$stmt->expects($this->once())
|
$stmt->expects($this->once())
|
||||||
->method(method_exists($mockedInterface, 'fetchAssociative') ? 'fetchAssociative' : 'fetch')
|
->method(method_exists(Statement::class, 'fetchAssociative') ? 'fetchAssociative' : 'fetch')
|
||||||
->willReturn($expectedResult);
|
->willReturn($expectedResult);
|
||||||
|
|
||||||
return $stmt;
|
return $stmt;
|
||||||
@ -315,12 +311,9 @@ class ConnectionTest extends TestCase
|
|||||||
'headers' => json_encode(['type' => DummyMessage::class]),
|
'headers' => json_encode(['type' => DummyMessage::class]),
|
||||||
];
|
];
|
||||||
|
|
||||||
$mockedInterface = interface_exists(ForwardCompatibleResultStatement::class)
|
$stmt = $this->createMock(Statement::class);
|
||||||
? ForwardCompatibleResultStatement::class
|
|
||||||
: ResultStatement::class;
|
|
||||||
$stmt = $this->createMock($mockedInterface);
|
|
||||||
$stmt->expects($this->once())
|
$stmt->expects($this->once())
|
||||||
->method(method_exists($mockedInterface, 'fetchAllAssociative') ? 'fetchAllAssociative' : 'fetchAll')
|
->method(method_exists(Statement::class, 'fetchAllAssociative') ? 'fetchAllAssociative' : 'fetchAll')
|
||||||
->willReturn([$message1, $message2]);
|
->willReturn([$message1, $message2]);
|
||||||
|
|
||||||
$driverConnection
|
$driverConnection
|
||||||
|
Reference in New Issue
Block a user