-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[SecurityBundle] fix setLogoutOnUserChange calls for context listeners #25272
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d4a6f6c
98abd1e
fb42305
d9d7477
3ece4c6
4657298
8174c95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ class SecurityExtension extends Extension | |
private $factories = array(); | ||
private $userProviderFactories = array(); | ||
private $expressionLanguage; | ||
private $logoutOnUserChangeByContextKey = array(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @chalasr should I add some deprecation info here? Did not see that for private member variables elsewhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's let it as is and keep it in mind, note for mergers: this prop should be removed when merging in 4.0 (I can take care of the merge) |
||
|
||
public function __construct() | ||
{ | ||
|
@@ -276,12 +277,6 @@ private function createFirewalls($config, ContainerBuilder $container) | |
$customUserChecker = true; | ||
} | ||
|
||
if (!isset($firewall['logout_on_user_change']) || !$firewall['logout_on_user_change']) { | ||
@trigger_error(sprintf('Not setting "logout_on_user_change" to true on firewall "%s" is deprecated as of 3.4, it will always be true in 4.0.', $name), E_USER_DEPRECATED); | ||
} | ||
|
||
$contextListenerDefinition->addMethodCall('setLogoutOnUserChange', array($firewall['logout_on_user_change'])); | ||
|
||
$configId = 'security.firewall.map.config.'.$name; | ||
|
||
list($matcher, $listeners, $exceptionListener) = $this->createFirewall($container, $name, $firewall, $authenticationProviders, $providerIds, $configId); | ||
|
@@ -370,7 +365,16 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a | |
$contextKey = $firewall['context']; | ||
} | ||
|
||
$listeners[] = new Reference($this->createContextListener($container, $contextKey)); | ||
if (!$logoutOnUserChange = $firewall['logout_on_user_change']) { | ||
@trigger_error(sprintf('Not setting "logout_on_user_change" to true on firewall "%s" is deprecated as of 3.4, it will always be true in 4.0.', $id), E_USER_DEPRECATED); | ||
} | ||
|
||
if (isset($this->logoutOnUserChangeByContextKey[$contextKey]) && $this->logoutOnUserChangeByContextKey[$contextKey][1] !== $logoutOnUserChange) { | ||
throw new InvalidConfigurationException(sprintf('Firewalls "%s" and "%s" need to have the same value for option "logout_on_user_change" as they are sharing the context "%s"', $this->logoutOnUserChangeByContextKey[$contextKey][0], $id, $contextKey)); | ||
} | ||
|
||
$this->logoutOnUserChangeByContextKey[$contextKey] = array($id, $logoutOnUserChange); | ||
$listeners[] = new Reference($this->createContextListener($container, $contextKey, $logoutOnUserChange)); | ||
} | ||
|
||
$config->replaceArgument(6, $contextKey); | ||
|
@@ -481,7 +485,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a | |
return array($matcher, $listeners, $exceptionListener); | ||
} | ||
|
||
private function createContextListener($container, $contextKey) | ||
private function createContextListener($container, $contextKey, $logoutUserOnChange) | ||
{ | ||
if (isset($this->contextListeners[$contextKey])) { | ||
return $this->contextListeners[$contextKey]; | ||
|
@@ -490,6 +494,7 @@ private function createContextListener($container, $contextKey) | |
$listenerId = 'security.context_listener.'.count($this->contextListeners); | ||
$listener = $container->setDefinition($listenerId, new ChildDefinition('security.context_listener')); | ||
$listener->replaceArgument(2, $contextKey); | ||
$listener->addMethodCall('setLogoutOnUserChange', array($logoutUserOnChange)); | ||
|
||
return $this->contextListeners[$contextKey] = $listenerId; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chalasr this is now actually not needed anymore since triggering the deprecation is moved and it's not triggered anymore at all if
stateless = true
orsecurity = false
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!