Skip to content

Commit ae5b20c

Browse files
committed
Change priority of me e ndpoint to prevent all users getting /me iri
1 parent 2c7b525 commit ae5b20c

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

features/user/security.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ Feature: Prevent disabled users from logging in
5353
@loginSuperAdmin
5454
Scenario: A logged in user can fetch a list of all users
5555
Given there is a user with the username "another_user" password "password" and role "ROLE_USER"
56-
When I send a "GET" request to "/users"
56+
When I send a "GET" request to "/users?perPage=5"
5757
Then the response status code should be 200
5858
And the JSON node "member" should have 2 elements
59-
And the JSON node "member[0].username" should be equal to "another_user"
60-
And the JSON node "member[1].username" should be equal to "new_user"
59+
And the JSON node "member[0].@id" should match "/^\/users\/([a-zA-Z0-9\-]+)$/"
60+
And the JSON node "member[1].@id" should match "/^\/users\/([a-zA-Z0-9\-]+)$/"
6161

6262
Scenario: A successful login
6363
Given there is a user with the username "admin" password "password" and role "ROLE_ADMIN"

src/ApiPlatform/Metadata/Resource/UserResourceMetadataCollectionFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ private function createMeOperation(Get $operation): Operation
7373
{
7474
return new Get(
7575
uriTemplate: '/me{._format}',
76+
uriVariables: [],
7677
routePrefix: $operation->getRoutePrefix(),
7778
cacheHeaders: [
7879
'public' => false,
@@ -82,6 +83,7 @@ private function createMeOperation(Get $operation): Operation
8283
shortName: '__api_me',
8384
class: $operation->getClass(),
8485
security: 'is_granted("IS_AUTHENTICATED_FULLY")',
86+
priority: 1000,
8587
name: '_api_me',
8688
provider: UserStateProvider::class
8789
);

0 commit comments

Comments
 (0)