File tree Expand file tree Collapse file tree 3 files changed +53
-1
lines changed
src/Symfony/Bundle/Resources/config/symfony
tests/Fixtures/TestBundle/Entity Expand file tree Collapse file tree 3 files changed +53
-1
lines changed Original file line number Diff line number Diff line change
1
+ Feature : Authorization checking
2
+ In order to use the API
3
+ I need to be authorized to access a given resource.
4
+
5
+ @!mongodb
6
+ @createSchema
7
+ Scenario : An anonymous user retrieves a secured resource
8
+ When I add "Accept" header equal to "application/ld+json"
9
+ When I am on "/secured_dummy_with_filters?required=&required-allow-empty=&arrayRequired[foo]="
10
+ Then the response status code should be 401
11
+
Original file line number Diff line number Diff line change 27
27
<argument type =" service" id =" api_platform.metadata.resource.metadata_collection_factory" />
28
28
<argument >%api_platform.validator.query_parameter_validation%</argument >
29
29
30
- <tag name =" kernel.event_listener" event =" kernel.request" method =" onKernelRequest" priority =" 16 " />
30
+ <tag name =" kernel.event_listener" event =" kernel.request" method =" onKernelRequest" priority =" 2 " />
31
31
</service >
32
32
</services >
33
33
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the API Platform project.
5
+ *
6
+ * (c) Kévin Dunglas <dunglas@gmail.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ declare (strict_types=1 );
13
+
14
+ namespace ApiPlatform \Tests \Fixtures \TestBundle \Entity ;
15
+
16
+ use ApiPlatform \Metadata \ApiResource ;
17
+ use ApiPlatform \Tests \Fixtures \TestBundle \Filter \ArrayRequiredFilter ;
18
+ use Doctrine \ORM \Mapping as ORM ;
19
+
20
+ /**
21
+ * Secured resource.
22
+ *
23
+ * @author Kévin Dunglas <dunglas@gmail.com>
24
+ */
25
+ #[ApiResource(
26
+ security: 'is_granted( \'ROLE_USER \') ' ,
27
+ filters: [ArrayRequiredFilter::class],
28
+ )]
29
+ #[ORM \Entity]
30
+ class SecuredDummyWithFilter
31
+ {
32
+ #[ORM \Column(type: 'integer ' )]
33
+ #[ORM \Id]
34
+ #[ORM \GeneratedValue(strategy: 'AUTO ' )]
35
+ private ?int $ id = null ;
36
+
37
+ public function getId (): ?int
38
+ {
39
+ return $ this ->id ;
40
+ }
41
+ }
You can’t perform that action at this time.
0 commit comments