-
-
Notifications
You must be signed in to change notification settings - Fork 921
Fixed dependency issue when SecurityBundle is not installed #3149
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
Conversation
You need to modify the code inside the stages too to handle the case when |
What do you mean? Not following you on the word |
The services you are modifying are "stages" ( |
You mean add an extra check for
|
Even before this condition but that's the idea. And make the variable in the constructor nullable. |
if (null === $isGranted || null === $this->resourceAccessChecker || $this->resourceAccessChecker->isGranted($resourceClass, (string) $isGranted, $context['extra_variables'])) {
return;
} This is wrong. We must not silently allow access if the user has specified some condition (i.e. |
Oh yes you're right @teohhanhui |
@teohhanhui and by "fail" you mean throw the Error as in last line on that
@alanpoulain yes, I will add the test once the desired solution is approved by you both :) Sorry for not being following you guys, first time "fixing" an api-platform issue and understanding it's internal. |
I think we should do something like: throw new \LogicException('Cannot check security expression when SecurityBundle is not installed. Try running "composer require symfony/security-bundle".'); as this is a configuration issue. Or do you always want to avoid throwing exceptions at all costs, @alanpoulain? (Why?) |
We can throw a |
@teohhanhui / @alanpoulain better now? Did I miss something else? |
@@ -53,12 +53,12 @@ | |||
|
|||
<service id="api_platform.graphql.resolver.stage.security" class="ApiPlatform\Core\GraphQl\Resolver\Stage\SecurityStage" public="false"> | |||
<argument type="service" id="api_platform.metadata.resource.metadata_factory" /> | |||
<argument type="service" id="api_platform.security.resource_access_checker" /> | |||
<argument type="service" id="api_platform.security.resource_access_checker" on-invalid="ignore" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be null
, not ignore
isn't it? Or calling the constructor will still fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder why test are passing with this configuration? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the security component is installed on Travis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, they behave the same way. The only difference is when inside a method call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest for consistency's sake, we should not use on-invalid="null"
except in the specific cases where we need that behaviour (i.e. a method call with null
value).
tests/GraphQl/Resolver/Stage/SecurityPostDenormalizeStageTest.php
Outdated
Show resolved
Hide resolved
256c4bf
to
57705bb
Compare
57705bb
to
c61cbb9
Compare
I've rebased your PR for 2.5 and made some little changes. Thank you @reypm! |
Uh oh!
There was an error while loading. Please reload this page.