Skip to content

Commit dc4fc84

Browse files
Merge commit from fork
Co-authored-by: Vincent Amstoutz <[email protected]>
1 parent 9eb5c4e commit dc4fc84

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

features/graphql/query.feature

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,3 +677,20 @@ Feature: GraphQL query support
677677
Then the response status code should be 200
678678
And the header "Content-Type" should be equal to "application/json"
679679
And the JSON node "data.getSecurityAfterResolver.name" should be equal to "test"
680+
681+
682+
Scenario: Call security after resolver with 403 error (ensure /2 does not match securityAfterResolver)
683+
When I send the following GraphQL request:
684+
""""
685+
{
686+
getSecurityAfterResolver(id: "/security_after_resolvers/2") {
687+
name
688+
}
689+
}
690+
"""
691+
Then the response status code should be 200
692+
And the response should be in JSON
693+
And the header "Content-Type" should be equal to "application/json"
694+
And the JSON node "errors[0].extensions.status" should be equal to 403
695+
And the JSON node "errors[0].message" should be equal to "Access Denied."
696+
And the JSON node "data.getSecurityAfterResolver.name" should not exist

src/Symfony/Security/State/AccessCheckerProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
5353

5454
$isGranted = $operation->getSecurityAfterResolver();
5555
$message = $operation->getSecurityMessageAfterResolver();
56-
// no break
56+
break;
5757
default:
5858
$isGranted = $operation->getSecurity();
5959
$message = $operation->getSecurityMessage();

tests/Fixtures/TestBundle/ApiResource/Issue6427/SecurityAfterResolverResolver.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ final class SecurityAfterResolverResolver implements QueryItemResolverInterface
2323
*/
2424
public function __invoke($item, array $context): SecurityAfterResolver
2525
{
26+
$idUrl = $context['args']['id'];
27+
28+
if (str_contains($idUrl, '2')) {
29+
// Unknown to simulate a 403 error
30+
return new SecurityAfterResolver('2', 'nonexistent');
31+
}
32+
2633
return new SecurityAfterResolver('1', 'test');
2734
}
2835
}

0 commit comments

Comments
 (0)