Skip to content

Commit f6db5cb

Browse files
committed
chore: deprecate link_security and set it default to true
1 parent d0dffea commit f6db5cb

5 files changed

Lines changed: 14 additions & 6 deletions

File tree

filters.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,13 +587,17 @@ The `IriConverterParameterProvider` supports the following options in `extraProp
587587

588588
### `ReadLinkParameterProvider`
589589

590-
This provider must be enabled before it can be used.
590+
This provider is now enabled by default (since API Platform 4.2).
591+
592+
Previously, this provider required the following configuration:
591593

592594
```yaml
593595
api_platform:
594596
enable_link_security: true
595597
```
596598
599+
> [!NOTE] The `enable_link_security` option is deprecated since API Platform 4.2 and will be removed in 5.0.
600+
597601
This provider fetches a linked resource from a given identifier. This is useful when you need to
598602
load a related entity to use later, for example in your own state provider. When you have an API
599603
resource with a custom `uriTemplate` that includes parameters, the `ReadLinkParameterProvider` can

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,9 +1018,7 @@ private function registerArgumentResolverConfiguration(PhpFileLoader $loader): v
10181018

10191019
private function registerLinkSecurityConfiguration(PhpFileLoader $loader, array $config): void
10201020
{
1021-
if ($config['enable_link_security']) {
1022-
$loader->load('link_security.php');
1023-
}
1021+
$loader->load('link_security.php');
10241022
}
10251023

10261024
private function registerJsonStreamerConfiguration(ContainerBuilder $container, PhpFileLoader $loader, array $formats, array $config): void

src/Symfony/Bundle/DependencyInjection/Configuration.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ public function getConfigTreeBuilder(): TreeBuilder
117117
->booleanNode('enable_docs')->defaultTrue()->info('Enable the docs')->end()
118118
->booleanNode('enable_profiler')->defaultTrue()->info('Enable the data collector and the WebProfilerBundle integration.')->end()
119119
->booleanNode('enable_phpdoc_parser')->defaultTrue()->info('Enable resource metadata collector using PHPStan PhpDocParser.')->end()
120-
->booleanNode('enable_link_security')->defaultFalse()->info('Enable security for Links (sub resources)')->end()
120+
->booleanNode('enable_link_security')
121+
->defaultTrue()
122+
->info('Enable security for Links (sub resources).')
123+
->setDeprecated('api-platform/symfony', '4.2', 'This option is always enabled and will be removed in API Platform 5.0.')
124+
->end()
121125
->arrayNode('collection')
122126
->addDefaultsIfNotSet()
123127
->children()

tests/Fixtures/app/config/config_common.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ api_platform:
8282
http_cache:
8383
invalidation:
8484
enabled: true
85+
# TODO: remove in 5.0
8586
enable_link_security: true
8687
# see also defaults in AppKernel
8788
doctrine_mongodb_odm: false

tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ private function runDefaultConfigTests(array $doctrineIntegrationsToLoad = ['orm
230230
],
231231
'use_symfony_listeners' => false,
232232
'handle_symfony_errors' => false,
233-
'enable_link_security' => false,
233+
// TODO: remove in 5.0
234+
'enable_link_security' => true,
234235
'serializer' => [
235236
'hydra_prefix' => null,
236237
],

0 commit comments

Comments
 (0)