Skip to content

Commit ec17cb3

Browse files
committed
mark providers final, disable feature by default
1 parent ee98312 commit ec17cb3

File tree

8 files changed

+24
-6
lines changed

8 files changed

+24
-6
lines changed

behat.yml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ legacy:
203203
- 'Behat\MinkExtension\Context\MinkContext'
204204
- 'behatch:context:rest'
205205
filters:
206-
tags: '~@postgres&&~@mongodb&&~@elasticsearch'
206+
tags: '~@postgres&&~@mongodb&&~@elasticsearch&&~@link_security'
207207
extensions:
208208
'FriendsOfBehat\SymfonyExtension':
209209
bootstrap: 'tests/Fixtures/app/bootstrap.php'

features/authorization/deny.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,15 @@ Feature: Authorization checking
211211
And the response should contain "ownerOnlyProperty"
212212
And the JSON node "ownerOnlyProperty" should be equal to the string "updated"
213213

214+
@link_security
214215
Scenario: An non existing entity should return Not found
215216
When I add "Accept" header equal to "application/ld+json"
216217
And I add "Content-Type" header equal to "application/ld+json"
217218
And I add "Authorization" header equal to "Basic ZHVuZ2xhczprZXZpbg=="
218219
And I send a "GET" request to "/secured_dummies/40000/to_from"
219220
Then the response status code should be 404
220221

222+
@link_security
221223
Scenario: An user can get related linked dummies for an secured dummy they own
222224
Given there are 1 SecuredDummy objects owned by dunglas with related dummies
223225
When I add "Accept" header equal to "application/ld+json"
@@ -228,6 +230,7 @@ Feature: Authorization checking
228230
And the response should contain "securedDummy"
229231
And the JSON node "hydra:member[0].id" should be equal to 1
230232

233+
@link_security
231234
Scenario: I define a custom name of the security object
232235
When I add "Accept" header equal to "application/ld+json"
233236
And I add "Content-Type" header equal to "application/ld+json"
@@ -237,6 +240,7 @@ Feature: Authorization checking
237240
And the response should contain "securedDummy"
238241
And the JSON node "hydra:member[0].id" should be equal to 1
239242

243+
@link_security
240244
Scenario: I define a from from link
241245
When I add "Accept" header equal to "application/ld+json"
242246
And I add "Content-Type" header equal to "application/ld+json"
@@ -246,6 +250,7 @@ Feature: Authorization checking
246250
And the response should contain "id"
247251
And the JSON node "hydra:member[0].id" should be equal to 4
248252

253+
@link_security
249254
Scenario: I define multiple links with security
250255
When I add "Accept" header equal to "application/ld+json"
251256
And I add "Content-Type" header equal to "application/ld+json"
@@ -255,6 +260,7 @@ Feature: Authorization checking
255260
And the response should contain "id"
256261
And the JSON node "hydra:member[0].id" should be equal to 1
257262

263+
@link_security
258264
Scenario: An user can not get related linked dummies for an secured dummy they do not own
259265
Given there are 1 SecuredDummy objects owned by someone with related dummies
260266
When I add "Accept" header equal to "application/ld+json"
@@ -263,20 +269,23 @@ Feature: Authorization checking
263269
And I send a "GET" request to "/secured_dummies/5/to_from"
264270
Then the response status code should be 403
265271

272+
@link_security
266273
Scenario: I define a custom name of the security object
267274
When I add "Accept" header equal to "application/ld+json"
268275
And I add "Content-Type" header equal to "application/ld+json"
269276
And I add "Authorization" header equal to "Basic ZHVuZ2xhczprZXZpbg=="
270277
And I send a "GET" request to "/secured_dummies/5/with_name"
271278
Then the response status code should be 403
272279

280+
@link_security
273281
Scenario: I define a from from link
274282
When I add "Accept" header equal to "application/ld+json"
275283
And I add "Content-Type" header equal to "application/ld+json"
276284
And I add "Authorization" header equal to "Basic ZHVuZ2xhczprZXZpbg=="
277285
And I send a "GET" request to "/related_linked_dummies/2/from_from"
278286
Then the response status code should be 403
279287

288+
@link_security
280289
Scenario: I define multiple links with security
281290
When I add "Accept" header equal to "application/ld+json"
282291
And I add "Content-Type" header equal to "application/ld+json"

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ private function registerInflectorConfiguration(array $config): void
896896

897897
private function registerLinkSecurityConfiguration(XmlFileLoader $loader, array $config): void
898898
{
899-
if ($config['enable_link_security'] ?? true) {
899+
if ($config['enable_link_security']) {
900900
$loader->load('link_security.xml');
901901
}
902902
}

src/Symfony/Bundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function getConfigTreeBuilder(): TreeBuilder
111111
->booleanNode('enable_docs')->defaultTrue()->info('Enable the docs')->end()
112112
->booleanNode('enable_profiler')->defaultTrue()->info('Enable the data collector and the WebProfilerBundle integration.')->end()
113113
->booleanNode('keep_legacy_inflector')->defaultTrue()->info('Keep doctrine/inflector instead of symfony/string to generate plurals for routes.')->end()
114-
->booleanNode('enable_link_security')->defaultTrue()->info('Enable security for Links (sub resources)')->end()
114+
->booleanNode('enable_link_security')->defaultFalse()->info('Enable security for Links (sub resources)')->end()
115115
->arrayNode('collection')
116116
->addDefaultsIfNotSet()
117117
->children()

src/Symfony/Security/State/LinkAccessCheckerProvider.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
use ApiPlatform\Symfony\Security\Exception\AccessDeniedException;
2121
use ApiPlatform\Symfony\Security\ResourceAccessCheckerInterface;
2222

23-
class LinkAccessCheckerProvider implements ProviderInterface
23+
/**
24+
* Checks the individual parts of the linked resource for access rights.
25+
* @experimental
26+
*/
27+
final class LinkAccessCheckerProvider implements ProviderInterface
2428
{
2529
public function __construct(
2630
private readonly ProviderInterface $decorated,

src/Symfony/Security/State/LinkedReadProvider.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
use ApiPlatform\State\ProviderInterface;
2424
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
2525

26-
class LinkedReadProvider implements ProviderInterface
26+
/**
27+
* Checks if the linked resources have security attributes and prepares them for access checking.
28+
* @experimental
29+
*/
30+
final class LinkedReadProvider implements ProviderInterface
2731
{
2832
public function __construct(
2933
private readonly ProviderInterface $decorated,

tests/Fixtures/app/config/config_common.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ api_platform:
7878
invalidation:
7979
enabled: true
8080
keep_legacy_inflector: false
81+
enable_link_security: true
8182
# see also defaults in AppKernel
8283

8384
doctrine_mongodb_odm: false

tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ private function runDefaultConfigTests(array $doctrineIntegrationsToLoad = ['orm
227227
'keep_legacy_inflector' => true,
228228
'event_listeners_backward_compatibility_layer' => true,
229229
'handle_symfony_errors' => false,
230-
'enable_link_security' => true,
230+
'enable_link_security' => false,
231231
], $config);
232232
}
233233

0 commit comments

Comments
 (0)