8000 feature #43835 [SecurityBundle] Deprecate not configuring explicitly … · symfony/symfony@fcfcc32 · GitHub
[go: up one dir, main page]

Skip to content

Commit fcfcc32

Browse files
committed
feature #43835 [SecurityBundle] Deprecate not configuring explicitly a provider for custom_authenticators when there is more than one registered provider (lyrixx)
This PR was merged into the 5.4 branch. Discussion ---------- [SecurityBundle] Deprecate not configuring explicitly a provider for custom_authenticators when there is more than one registered provider | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | yes | Tickets | | License | MIT | Doc PR | not needed I guess Commits ------- a2c9a44 [SecurityBundle] Deprecate not configuring explicitly a provider for custom_authenticators when there is more than one registered provider
2 parents a3c6cca + a2c9a44 commit fcfcc32
10000

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

UPGRADE-5.4.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ Security
139139
* Deprecate `AuthenticatorInterface::createAuthenticatedToken()`, use `AuthenticatorInterface::createToken()` instead
140140
* Deprecate `PassportInterface`, `UserPassportInterface` and `PassportTrait`, use `Passport` instead.
141141
As such, the return type declaration of `AuthenticatorInterface::authenticate()` will change to `Passport` in 6.0
142+
* Deprecate not configuring explicitly a provider for custom_authenticators when there is more than one registered provider
142143

143144
Before:
144145
```php

UPGRADE-6.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ SecurityBundle
430430
* Remove the `security.authentication.provider.*` services, use the new authenticator system instead
431431
* Remove the `security.authentication.listener.*` services, use the new authenticator system instead
432432
* Remove the Guard component integration, use the new authentica 10000 tor system instead
433+
* Remove the default provider for custom_authenticators when there is more than one registered provider
433434

434435
Serializer
435436
----------

src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ CHANGELOG
1717
* Deprecate the `always_authenticate_before_granting` option
1818
* Display the roles of the logged-in user in the Web Debug Toolbar
1919
* Add the `security.access_decision_manager.strategy_service` option
20+
* Deprecate not configuring explicitly a provider for custom_authenticators when there is more than one registered provider
2021

2122
5.3
2223
---

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,10 @@ private function getUserProvider(ContainerBuilder $container, string $id, array
703703
}
704704

705705
if ('remember_me' === $factoryKey || 'anonymous' === $factoryKey || 'custom_authenticators' === $factoryKey) {
706+
if ('custom_authenticators' === $factoryKey) {
707+
trigger_deprecation('symfony/security-bundle', '5.4', 'Not configuring explicitly the provider for the "%s" listener on "%s" firewall is deprecated because it\'s ambiguous as there is more than one registered provider.', $factoryKey, $id);
708+
}
709+
706710
return 'security.user_providers';
707711
}
708712

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1516
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
1617
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FirewallListenerFactoryInterface;
1718
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
@@ -44,6 +45,8 @@
4445

4546
class SecurityExtensionTest extends TestCase
4647
{
48+
use ExpectDeprecationTrait;
49+
4750
public function testInvalidCheckPath()
4851
{
4952
$this->expectException(InvalidConfigurationException::class);
@@ -373,6 +376,33 @@ public function testDoNotRegisterTheUserProviderAliasWithMultipleProviders()
373376
$this->assertFalse($container->has(UserProviderInterface::class));
374377
}
375378

379+
/**
380+
* @group legacy
381+
*/
382+
public function testFirewallWithNoUserProviderTriggerDeprecation()
383+
{
384+
$container = $this->getRawContainer();
385+
386+
$container->loadFromExtension('security', [
387+
'enable_authenticator_manager' => true,
388+
389+
'providers' => [
390+
'first' => ['id' => 'foo'],
391+
'second' => ['id' => 'foo'],
392+
],
393+
394+
'firewalls' => [
395+
'some_firewall' => [
396+
'custom_authenticator' => 'my_authenticator',
397+
],
398+
],
399+
]);
400+
401+
$this->expectDeprecation('Since symfony/security-bundle 5.4: Not configuring explicitly the provider for the "custom_authenticators" listener on "some_firewall" firewall is deprecated because it\'s ambiguous as there is more than one registered provider.');
402+
403+
$container->compile();
404+
}
405+
376406
/**
377407
* @dataProvider sessionConfigurationProvider
378408
* @group legacy

0 commit comments

Comments
 (0)
0