Skip to content

Commit 0a9cc18

Browse files
feature #60928 [SecurityBundle] Remove deprecated hide_user_not_found option (OskarStark)
This PR was squashed before being merged into the 8.0 branch. Discussion ---------- [SecurityBundle] Remove deprecated `hide_user_not_found` option | Q | A | ------------- | --- | Branch? | 8.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | -- | License | MIT Commits ------- e9b2998 [SecurityBundle] Remove deprecated `hide_user_not_found` option
2 parents 29f8fca + e9b2998 commit 0a9cc18

File tree

4 files changed

+15
-55
lines changed

4 files changed

+15
-55
lines changed

UPGRADE-8.0.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,20 @@ Security
362362
* Remove `AbstractListener::__invoke`
363363
* Remove `LazyFirewallContext::__invoke()`
364364

365+
SecurityBundle
366+
--------------
367+
368+
* Remove the deprecated `hide_user_not_found` configuration option, use `expose_security_errors` instead
369+
370+
```diff
371+
# config/packages/security.yaml
372+
security:
373+
- hide_user_not_found: false
374+
+ expose_security_errors: true
375+
```
376+
377+
Note: `expose_security_errors: true` is equivalent to `hide_user_not_found: false`. The logic is inverted.
378+
365379
Serializer
366380
----------
367381

src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

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

7+
* Remove the deprecated `hide_user_not_found` configuration option, use `expose_security_errors` instead
78
* Remove `LazyFirewallContext::__invoke()`
89

910
7.4

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,12 @@ public function getConfigTreeBuilder(): TreeBuilder
5656

5757
$rootNode
5858
->docUrl('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/security.html', 'symfony/security-bundle')
59-
->beforeNormalization()
60-
->always()
61-
->then(function ($v) {
62-
if (isset($v['hide_user_not_found']) && isset($v['expose_security_errors'])) {
63-
throw new InvalidConfigurationException('You cannot use both "hide_user_not_found" and "expose_security_errors" at the same time.');
64-
}
65-
66-
if (isset($v['hide_user_not_found']) && !isset($v['expose_security_errors'])) {
67-
$v['expose_security_errors'] = $v['hide_user_not_found'] ? ExposeSecurityLevel::None : ExposeSecurityLevel::All;
68-
}
69-
70-
return $v;
71-
})
72-
->end()
7359
->children()
7460
->scalarNode('access_denied_url')->defaultNull()->example('/foo/error403')->end()
7561
->enumNode('session_fixation_strategy')
7662
->values([SessionAuthenticationStrategy::NONE, SessionAuthenticationStrategy::MIGRATE, SessionAuthenticationStrategy::INVALIDATE])
7763
->defaultValue(SessionAuthenticationStrategy::MIGRATE)
7864
->end()
79-
->booleanNode('hide_user_not_found')
80-
->setDeprecated('symfony/security-bundle', '7.3', 'The "%node%" option is deprecated and will be removed in 8.0. Use the "expose_security_errors" option instead.')
81-
->end()
8265
->enumNode('expose_security_errors')
8366
->beforeNormalization()->ifString()->then(fn ($v) => ExposeSecurityLevel::tryFrom($v))->end()
8467
->values(ExposeSecurityLevel::cases())

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

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -259,42 +259,4 @@ public static function provideHideUserNotFoundData(): iterable
259259
yield [['expose_security_errors' => 'all'], ExposeSecurityLevel::All];
260260
}
261261

262-
/**
263-
* @dataProvider provideHideUserNotFoundLegacyData
264-
*
265-
* @group legacy
266-
*/
267-
public function testExposeSecurityErrorsWithLegacyConfig(array $config, ExposeSecurityLevel $expectedExposeSecurityErrors, ?bool $expectedHideUserNotFound)
268-
{
269-
$this->expectUserDeprecationMessage('Since symfony/security-bundle 7.3: The "hide_user_not_found" option is deprecated and will be removed in 8.0. Use the "expose_security_errors" option instead.');
270-
271-
$config = array_merge(static::$minimalConfig, $config);
272-
273-
$processor = new Processor();
274-
$configuration = new MainConfiguration([], []);
275-
$processedConfig = $processor->processConfiguration($configuration, [$config]);
276-
277-
$this->assertEquals($expectedExposeSecurityErrors, $processedConfig['expose_security_errors']);
278-
$this->assertEquals($expectedHideUserNotFound, $processedConfig['hide_user_not_found']);
279-
}
280-
281-
public static function provideHideUserNotFoundLegacyData(): iterable
282-
{
283-
yield [['hide_user_not_found' => true], ExposeSecurityLevel::None, true];
284-
yield [['hide_user_not_found' => false], ExposeSecurityLevel::All, false];
285-
}
286-
287-
public function testCannotUseHideUserNotFoundAndExposeSecurityErrorsAtTheSameTime()
288-
{
289-
$processor = new Processor();
290-
$configuration = new MainConfiguration([], []);
291-
292-
$this->expectException(InvalidConfigurationException::class);
293-
$this->expectExceptionMessage('You cannot use both "hide_user_not_found" and "expose_security_errors" at the same time.');
294-
295-
$processor->processConfiguration($configuration, [static::$minimalConfig + [
296-
'hide_user_not_found' => true,
297-
'expose_security_errors' => ExposeSecurityLevel::None,
298-
]]);
299-
}
300262
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy