-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Hotfix: isGranted for failed routing #1
Hotfix: isGranted for failed routing #1
Conversation
The problem here is that even if we are going to return false on Maybe it should be fixed somehow in |
The same issue we will have also in ACL implementation:
When routing failed |
I got 500 as well for ACL |
I'm a bit confused by the test results. They indicate a |
We have RouteResult in the request attributes but routing failed so `getMatchedRouteName` will return `false`. In that case everyone can access non-existing resource, so the result of `isGranted` should be `true`.
More reliable results we can get if we create proper instance of RouteResult. This class has two states - when matched routing is found and when routing is failed. It is hard to properly mock internal state of the object with all public methods. THat's why it's easier to use static method to create the object with desired state.
… access If there is no matching route in RouteResult we return true, as the permission is granted. It read that everyone can access non-existing resource. AuthorizationMiddleware will then just pass this request to the next middleware and as the result we will get 404.
@weierophinney PR is now updated with the fix as we discussed - adapter returns The same hotfix I've provided for acl adapter: mezzio/mezzio-authorization-acl#1 |
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.
This makes sense for me. Since these adapters are route-based, they cannot examine anything that is a routing failure, and that case will more than likely mean a 404 scenario.
If users want to do differently (e.g., return a 403 for routing failures), they can decorate the AuthorizationMiddleware
to do so.
Hotfix: isGranted for failed routing
Description
We have RouteResult in the request attributes but routing failed so
getMatchedRouteName
will returnfalse
.In that case everyone can access non-existing resource, so the result of
isGranted
should betrue
.I hit the error with my application when navigating to non-existing page. I got exception instead of proper 404 page. My pipeline is as follows: