Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Security] Allow disabling redirect on logout#46320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jvasseur wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromjvasseur:allow-disabling-logout-redirect
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionssrc/Symfony/Bundle/SecurityBundle/CHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ CHANGELOG
* Deprecate the `Symfony\Component\Security\Core\Security` service alias, use `Symfony\Bundle\SecurityBundle\Security\Security` instead
* Add `Security::getFirewallConfig()` to help to get the firewall configuration associated to the Request
* Add `Security::login()` to login programmatically
* Allow disabling the redirection on successful logout by passing `null` to the `target` option
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should move to 7.3


6.1
---
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -413,10 +413,12 @@ private function createFirewall(ContainerBuilder $container, string $id, array $
'logout_path' => $firewall['logout']['path'],
]);

$logoutSuccessListenerId = 'security.logout.listener.default.'.$id;
$container->setDefinition($logoutSuccessListenerId, new ChildDefinition('security.logout.listener.default'))
->replaceArgument(1, $firewall['logout']['target'])
->addTag('kernel.event_subscriber', ['dispatcher' => $firewallEventDispatcherId]);
if (null !== $firewall['logout']['target']) {
$logoutSuccessListenerId = 'security.logout.listener.default.'.$id;
$container->setDefinition($logoutSuccessListenerId, new ChildDefinition('security.logout.listener.default'))
->replaceArgument(1, $firewall['logout']['target'])
->addTag('kernel.event_subscriber', ['dispatcher' => $firewallEventDispatcherId]);
}

// add CSRF provider
if (isset($firewall['logout']['csrf_token_generator'])) {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -780,6 +780,25 @@ public function testConfigureCustomFirewallListener()
$this->assertContains('custom_firewall_listener_id', $firewallListeners);
}

public function testDisableLogoutTarget()
{
$container = $this->getRawContainer();

$container->loadFromExtension('security', [
'firewalls' => [
'main' => [
'logout' => [
'target' => null,
],
],
],
]);

$container->compile();

$this->assertFalse($container->hasDefinition('security.logout.listener.default.main'));
}

protected function getRawContainer()
{
$container = new ContainerBuilder();
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -87,13 +87,12 @@ public function authenticate(RequestEvent $event)
$this->eventDispatcher->dispatch($logoutEvent);

$response = $logoutEvent->getResponse();
if (!$response instanceof Response) {
throw new \RuntimeException('No logout listener set the Response, make sure at least the DefaultLogoutListener is registered.');
}

$this->tokenStorage->setToken(null);

$event->setResponse($response);
if ($response) {
$event->setResponse($response);
}
}

/**
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,8 +122,6 @@ public function testHandleMatchedPathWithoutCsrfValidation()

public function testNoResponseSet()
{
$this->expectException(\RuntimeException::class);

[$listener, , $httpUtils, $options] = $this->getListener();

$request = new Request();
Expand All@@ -133,7 +131,11 @@ public function testNoResponseSet()
->with($request, $options['logout_path'])
->willReturn(true);

$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST));
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST);

$listener($event);

$this->assertNull($event->getResponse());
}

/**
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp