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 1d5c229

Browse filesBrowse files
bug #26009 [SecurityBundle] Allow remember-me factory creation when multiple user providers are configured. (iisisrael)
This PR was merged into the 3.4 branch. Discussion ---------- [SecurityBundle] Allow remember-me factory creation when multiple user providers are configured. | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | none When more than one user provider is configured, and `remember_me` is enabled on a firewall, this avoids the deprecation notice in 3.4 and thrown `InvalidConfigurationException` in 4.0 ("Not configuring explicitly the provider for the "remember_me" listener on "foo" firewall is ambiguous as there is more than one registered provider."). The `RememberMeFactory` ignores the `$userProvider` argument and uses the secret configured for the firewall. (If no secret is configured, it throws its own exception.) The added test passes in 3.4 with a deprecation notice without the change, so would expect it to fail in 4.0 without the change. Other tests in the `SecurityBundle` already included two errors and one failure, not related to this change. Commits ------- 6ab8dd9 Allow remember-me factory creation when multiple user providers are configured.
2 parents 003e616 + 6ab8dd9 commit 1d5c229
Copy full SHA for 1d5c229

File tree

Expand file treeCollapse file tree

2 files changed

+25
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+25
-0
lines changed

‎src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,9 @@ private function createAuthenticationListeners($container, $id, $firewall, &$aut
515515
throw new InvalidConfigurationException(sprintf('Invalid firewall "%s": user provider "%s" not found.', $id, $firewall[$key]['provider']));
516516
}
517517
$userProvider = $providerIds[$normalizedName];
518+
} elseif ('remember_me' === $key) {
519+
// RememberMeFactory will use the firewall secret when created
520+
$userProvider = null;
518521
} else {
519522
$userProvider = $defaultProvider ?: $this->getFirstProvider($id, $key, $providerIds);
520523
}

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,28 @@ public function testPerListenerProvider()
259259
$this->addToAssertionCount(1);
260260
}
261261

262+
public function testPerListenerProviderWithRememberMe()
263+
{
264+
$container = $this->getRawContainer();
265+
$container->loadFromExtension('security', array(
266+
'providers' => array(
267+
'first' => array('id' => 'foo'),
268+
'second' => array('id' => 'bar'),
269+
),
270+
271+
'firewalls' => array(
272+
'default' => array(
273+
'form_login' => array('provider' => 'second'),
274+
'logout_on_user_change' => true,
275+
'remember_me' => array('secret' => 'baz'),
276+
),
277+
),
278+
));
279+
280+
$container->compile();
281+
$this->addToAssertionCount(1);
282+
}
283+
262284
protected function getRawContainer()
263285
{
264286
$container = new ContainerBuilder();

0 commit comments

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