Skip to content

Commit e36259d

Browse files
committed
[Security] Deprecate UserInterface & TokenInterface's eraseCredentials()
1 parent 0deaa1e commit e36259d

File tree

149 files changed

+372
-38
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+372
-38
lines changed

UPGRADE-7.3.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,23 @@ backward compatibility breaks. Minor backward compatibility breaks are prefixed
66
`[BC BREAK]`, make sure your code is compatible with these entries before upgrading.
77
Read more about this in the [Symfony documentation](https://symfony.com/doc/7.3/setup/upgrade_minor.html).
88

9-
If you're upgrading from a version below 7.1, follow the [7.2 upgrade guide](UPGRADE-7.2.md) first.
9+
If you're upgrading from a version below 7.2, follow the [7.2 upgrade guide](UPGRADE-7.2.md) first.
10+
11+
Ldap
12+
----
13+
14+
* Deprecate `LdapUser::eraseCredentials()`, use `LdapUser::setPassword(null)` instead
15+
16+
Security
17+
--------
18+
19+
* Deprecate `UserInterface::eraseCredentials()` and `TokenInterface::eraseCredentials()`,
20+
use a dedicated DTO or erase credentials on your own e.g. upon `AuthenticationTokenCreatedEvent` instead
21+
22+
SecurityBundle
23+
--------------
24+
25+
* Deprecate the `erase_credentials` config option, erase credentials on your own e.g. upon `AuthenticationTokenCreatedEvent` instead
1026

1127
Console
1228
-------
@@ -109,3 +125,4 @@ VarDumper
109125

110126
* Deprecate `ResourceCaster::castCurl()`, `ResourceCaster::castGd()` and `ResourceCaster::castOpensslX509()`
111127
* Mark all casters as `@internal`
128+
* Deprecate the `CompiledClassMetadataFactory` and `CompiledClassMetadataCacheWarmer` classes

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CacheAttributeListener/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
public: true
1111

1212
security:
13+
erase_credentials: false
1314
providers:
1415
main:
1516
memory:

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Security/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ services:
88
- container.service_subscriber
99

1010
security:
11+
erase_credentials: false
1112
providers:
1213
main:
1314
memory:

src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
* Add `Security::isGrantedForUser()` to test user authorization without relying on the session. For example, users not currently logged in, or while processing a message from a message queue
88
* Add encryption support to `OidcTokenHandler` (JWE)
9+
* Deprecate the `erase_credentials` config option, erase credentials on your own e.g. upon `AuthenticationTokenCreatedEvent` instead
910

1011
7.2
1112
---

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/LdapFactoryTrait.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\DependencyInjection\Definition;
1717
use Symfony\Component\DependencyInjection\Reference;
1818
use Symfony\Component\Ldap\Security\CheckLdapCredentialsListener;
19+
use Symfony\Component\Ldap\Security\EraseLdapUserCredentialsListener;
1920
use Symfony\Component\Ldap\Security\LdapAuthenticator;
2021

2122
/**
@@ -42,6 +43,12 @@ public function createAuthenticator(ContainerBuilder $container, string $firewal
4243
->addArgument(new Reference('security.ldap_locator'))
4344
;
4445

46+
if (class_exists(EraseLdapUserCredentialsListener::class && !$container->getParameter('security.authentication.manager.erase_credentials'))) {
47+
$container->setDefinition('security.listener.'.$key.'.'.$firewallName.'erase_ldap_credentials', new Definition(EraseLdapUserCredentialsListener::class))
48+
->addTag('kernel.event_subscriber', ['dispatcher' => 'security.event_dispatcher.'.$firewallName])
49+
;
50+
}
51+
4552
$ldapAuthenticatorId = 'security.authenticator.'.$key.'.'.$firewallName;
4653
$definition = $container->setDefinition($ldapAuthenticatorId, new Definition(LdapAuthenticator::class))
4754
->setArguments([

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ public function load(array $configs, ContainerBuilder $container): void
135135

136136
// set some global scalars
137137
$container->setParameter('security.access.denied_url', $config['access_denied_url']);
138+
if (true === $config['erase_credentials']) {
139+
trigger_deprecation('symfony/security-bundle', '7.3', 'Setting the "security.erase_credentials" config option to true is deprecated and won\'t have any effect in 8.0, set it to false instead and use your own erasing logic if needed.');
140+
}
138141
$container->setParameter('security.authentication.manager.erase_credentials', $config['erase_credentials']);
139142
$container->setParameter('security.authentication.session_strategy.strategy', $config['session_fixation_strategy']);
140143

src/Symfony/Bundle/SecurityBundle/Tests/Debug/TraceableFirewallListenerTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ public function testOnKernelRequestRecordsAuthenticatorsInfo()
103103
[new TraceableAuthenticator($notSupportingAuthenticator), new TraceableAuthenticator($supportingAuthenticator)],
104104
$tokenStorage,
105105
$dispatcher,
106-
'main'
106+
'main',
107+
null,
108+
false
107109
);
108110

109111
$listener = new TraceableAuthenticatorManagerListener(new AuthenticatorManagerListener($authenticatorManager));

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ private function createContainer($sessionStorageOptions)
139139

140140
$config = [
141141
'security' => [
142+
'erase_credentials' => false,
142143
'providers' => ['some_provider' => ['id' => 'foo']],
143144
'firewalls' => ['some_firewall' => ['security' => false]],
144145
],

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/MakeFirewallsEventDispatcherTraceablePassTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ protected function setUp(): void
3434

3535
$this->container->registerExtension(new SecurityExtension());
3636
$this->container->loadFromExtension('security', [
37+
'erase_credentials' => false,
3738
'firewalls' => ['main' => ['pattern' => '/', 'http_basic' => true]],
3839
]);
3940

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/RegisterGlobalSecurityEventListenersPassTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ protected function setUp(): void
5656
public function testEventIsPropagated(string $configuredEvent, string $registeredEvent)
5757
{
5858
$this->container->loadFromExtension('security', [
59+
'erase_credentials' => false,
5960
'firewalls' => ['main' => ['pattern' => '/', 'http_basic' => true]],
6061
]);
6162

@@ -89,6 +90,7 @@ public static function providePropagatedEvents(): array
8990
public function testRegisterCustomListener()
9091
{
9192
$this->container->loadFromExtension('security', [
93+
'erase_credentials' => false,
9294
'firewalls' => ['main' => ['pattern' => '/', 'http_basic' => true]],
9395
]);
9496

@@ -109,6 +111,7 @@ public function testRegisterCustomListener()
109111
public function testRegisterCustomSubscriber()
110112
{
111113
$this->container->loadFromExtension('security', [
114+
'erase_credentials' => false,
112115
'firewalls' => ['main' => ['pattern' => '/', 'http_basic' => true]],
113116
]);
114117

@@ -128,6 +131,7 @@ public function testRegisterCustomSubscriber()
128131
public function testMultipleFirewalls()
129132
{
130133
$this->container->loadFromExtension('security', [
134+
'erase_credentials' => false,
131135
'firewalls' => ['main' => ['pattern' => '/', 'http_basic' => true], 'api' => ['pattern' => '/api', 'http_basic' => true]],
132136
]);
133137

@@ -157,6 +161,7 @@ public function testMultipleFirewalls()
157161
public function testListenerAlreadySpecific()
158162
{
159163
$this->container->loadFromExtension('security', [
164+
'erase_credentials' => false,
160165
'firewalls' => ['main' => ['pattern' => '/', 'http_basic' => true]],
161166
]);
162167

0 commit comments

Comments
 (0)