Follow-up from #1912602: Changing view access from "Permission" to "Role" causes AJAX error message re getRoles().
Problem/Motivation
As mentioned in [#8277631-39] by @catch
You start with a route having the following configuration:
route_name:
options:
_access_mode: 'ALL'
requirements:
_permission: 'example permission'
_additional_thingy: 'blub'
Views comes in and modifies the route definition in the following way (even with this patch):
route_name:
options:
_access_mode: 'ANY' // note this line
requirements:
_permission: 'example permission'
_additional_thingy: 'blub'
_views_access_all_views: 'TRUE'
As you see we now allow access if just one of the three things return TRUE and there we have our comparable small security problem.
Proposed resolution
Drop the support for it, its not that much of a well-known feature.
In D6 someone patched views to make it possible to opt-out of that already, so there is even demand to not have this feature.
Remaining tasks
1. Write a change record
User interface changes
N/A
API changes
No 'access all views' permission anyway.
Comments
Comment #1
catchComment #2
dawehnerLet's document the usecase: Views wants to provide a permission "access all views". You need to have an logical ANY between them, though this is problematic in case you have more than 2 other access checks.
Comment #3
tim.plunkettTo be clear: without this line, \Drupal\views\ViewsAccessCheck will not work.
But that took me a couple minutes to figure out *why* we needed it, and how it works.
Might this be better? It is less obfuscated, and the 'ANY' doesn't raise red flags the same way when we're explicitly setting another requirement right before it.
I tested this manually, this should work...
Comment #5
penyaskitoAdvice: I'm not sure what I am doing, so please review carefully.
Tim patch added a requirement, and the failing test was asserting on the number of requirements.
I increased the expected count (reordered assertEqual arguments), and added more explicit checks for those.
Comment #6
dawehner+1 on adding test coverage here but yeah we also need some sort of proper integration test in case we know what we want to do.
Comment #7
xjm5: views-access-any-2157541-5.patch queued for re-testing.
Comment #8
xjmComment #10
dawehnerOne alternative approach could be to maybe ran another subscriber on the routing layer which runs somehow before
the actual access checking and allows to skip the other one.
Comment #11
dawehnerJust made a small research, symfony for example has several so called voters, http://symfony.com/doc/current/cookbook/security/voters.html#the-voter-i...
Comment #12
dawehnerNote: Once #1986640: Support AND/OR conjunctions for permission checks is in we can probably solve this issue properly.
Comment #13
dawehnerI don't believe @dawehner in #12 though.
Comment #14
Désiré commentedTry to reroll the last patch.
Comment #15
penyaskito#14 still applies.
Comment #16
fabianx commentedRTBC - looks great to me and tests make sense.
Comment #17
dawehnerThank you for working on this issue, but are we aware of the fact that we haven't solved the critical bug yet?
Originally and with the patch the problem stays the same:
@Fabianx
One thing security related code should always have is a total integration test, so you are kind of sure that things don't break
Comment #18
fabianx commentedIn this case: CNW and we need an issue summary update as that is totally not clear from the summary.
Comment #19
dawehnerUpdated the IS
Comment #20
dawehnerI really wonder whether we need this feature in the first place.
For all other ones, like based upon roles, you can also configure it somehow.
So the question is whether we can lieve with "regression" ...
Comment #21
dawehnerComment #22
dawehner@catch was fine with killing it, so:
Let's kill it!
Comment #23
xjmI used this feature like once ever. I'm okay with removing it. But does this resolve the underlying "ANY" problem?
Comment #24
xjmWill need a CR if we remove the feature.
Comment #25
tim.plunkettI think we'd need to kill
from PathPluginBase, right?
Comment #26
dawehnerAbsolutely!
Comment #27
catchHere's a draft change record: https://www.drupal.org/node/2381665
Comment #28
fabianx commentedMuch much cleaner, love it.
RTBC from my side, Change record looks great.
Comment #29
catchLooks good to me too.
Comment #30
alexpottNice diffstat :)
This issue addresses a critical bug and is allowed per https://www.drupal.org/core/beta-changes. Committed ed01f40 and pushed to 8.0.x. Thanks!