Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL: honor access control rules #1602

Merged
merged 3 commits into from Dec 24, 2017

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Dec 22, 2017

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR todo

And now the GraphQL subsystem is hooked in the authorization mechanism.

Next step: validation, and we'll be almost done!

TODO:

  • Add some unit tests

@dunglas dunglas force-pushed the graphql-security branch 2 times, most recently from 31edb9b to 1b12bf8 Compare December 23, 2017 11:09
@@ -59,7 +58,7 @@ Feature: Authorization checking
"""
Then the response status code should be 201

Scenario: An user retrieve cannot retrieve an item he doesn't own
Scenario: An user retrieves cannot retrieve an item he doesn't own
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better? An user cannot retrieve an item he doesn't own

@@ -65,6 +68,12 @@ public function __invoke(string $resourceClass = null, string $rootClass = null,
}

$resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
if (null !== $this->resourceAccessChecker) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you put this in an abstract or a service? This is duplicated in CollectionResolverFactory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And in ItemResolver.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved this logic in a trait in the meantime.

/**
* @expectedException \Symfony\Component\Security\Core\Exception\AccessDeniedException
*/
public function testIsNotGranted()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use @dataProvider and remove the duplication?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've done it below!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be done in the lowest branch or it will create merge conflicts later :(

@dunglas dunglas merged commit 337ffdf into api-platform:master Dec 24, 2017
@dunglas dunglas deleted the graphql-security branch December 24, 2017 17:45
hoangnd25 pushed a commit to hoangnd25/core that referenced this pull request Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants