Problem/Motivation
Assume that we have user 'A' and user 'B'. User 'A' has the required permissions to access the moderation dashboard, user 'B' doesn't.
Right now if user 'A' navigates user/B/moderation/dashboard, he/she will get a hit and can access that page (however, until #3000637: Add personalized elements to the dashboard, use the User object from the route context instead of the current user won't be merged, he/she will see his/her own moderation dashboard page).
Proposed resolution
Route access checking should be improved. I see two main ways to do this:
- Create a new
Conditionplugin which checks that the user provided by context IS the current user as well and add it to the page manager page. - Extend the
_moderation_dashboard_page_access()function and check {user-from-context} === {current-user} there (adding the$userargument seems to work)
I think that throwing a NotFoundHttpException in the needed case/phase would be the best solution if it is feasible.
Remaining tasks
Decide whether the described case should be resolved or not.
If the answer is yes, then
- decide how to solve the access check
- add test coverage
- provide a patch
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | 3000641-25.patch | 20.53 KB | bendeguz.csirmaz |
| #20 | 3000641-20.patch | 18.79 KB | bendeguz.csirmaz |
| #20 | interdiff-3000641-18-20.txt | 3.14 KB | bendeguz.csirmaz |
| #18 | 3000641-18.patch | 16.35 KB | bendeguz.csirmaz |
| #17 | 3000641-17.patch | 16.35 KB | bendeguz.csirmaz |
Comments
Comment #2
samuel.mortensonAccessing another user's dashboard is desired behavior, I think. If you're a reviewer or manager it would be useful to check in on your content editors to see what's in their dashboard. The case where user B doesn't have the permissions to use the dashboard and user A visits their dashboard is interesting but not something we need to handle as a special case, I think.
So maybe resolving #3000637: Add personalized elements to the dashboard, use the User object from the route context instead of the current user is the best next step?
Comment #3
huzookaWhat about adding a permission for the case you described?
Comment #4
samuel.mortenson@huzooka I'd be OK with that, if you think it would be useful. Since Views does its own access checking I don't think any sensitive information would be disclosed by viewing another user's dashboard, but maybe it would be confusing if content editors could click that tab on a non-content-editor's user page.
Maybe we should only show the tab on another user's page if the current user has the new permission _and_ the other user would normally be able to visit the dashboard. You wouldn't want to see the dashboard tab for a user who's not a content editor, if that makes sense.
Comment #5
bendeguz.csirmaz commentedMy suggestion is to have the following two permissions:
Comment #6
bendeguz.csirmaz commentedThe problem with this is, what if you don't want the content editor (someone with the "view own moderation dashboard" permission) to see their dashboard, but you still want to see it as an admin user (someone with the "view any moderation dashboard" permission)?
We need something else for deciding whether a user has a moderation dashboard or not.
It could either be a third permission, or a flag on the User entity, or something else.
We could use the existing "use moderation dashboard" permission for this.
What do you think @samuel.mortenson?
Comment #7
samuel.mortenson@bendeguz.csirmaz I think "use moderation dashboard" and "view own moderation dashboard" are equivalent permissions, if you want to rename it you can, but if a user has the "use moderation dashboard" permission, they have a dashboard. So the two cases we should cover:
1. User is viewing their own dashboard, check if they have the "use/view own moderation dashboard" permission.
2. User A is viewing User B's dashboard, check if User B has the "use/view own moderation dashboard" permission and User A has the "view any moderation dashboard" permission.
Comment #8
bendeguz.csirmaz commentedOkay, so just to confirm: we shouldn't cover the case where where User A can view User B's dashboard, but User B can't?
Comment #9
samuel.mortensonConfirmed, in that case - I would expect access to be denied. Otherwise the dashboard tab would be available to admins on all user accounts and they wouldn't know when it's relevant for a specific user. I see your point about a third permission now but don't want to complicate the logic too much.
Comment #10
bendeguz.csirmaz commentedComment #11
bendeguz.csirmaz commentedComment #12
bendeguz.csirmaz commentedFixed coding standards.
Comment #14
bendeguz.csirmaz commentedMy bad, interdiff is not a patch.
Comment #15
huzookaI cant see the advantages of solving the access control by a service.
This should be solved by a module-provided Condition plugin with two required context, one for the dashboard owner, and one for the current user. If we latter would need it, we'll be able to use the
plugin.manager.conditionservice to get the plugin, set the contexts and check it's result.That would simplify the codebase.
* the condition plugin can be set up in the
page_manager.pageconfiguration* the
moderation_dashboard.route_subscriberservice and it's class could be removed as well* we don't have to use a procedural function just for asking a service (
_moderation_dashboard_page_access)* well,
_moderation_dashboard_page_accesscould be removed completely as well* we would be able to test the condition plugin with a kernel test as well, without the need of visiting routes.
If the user parameter would be set up properly in the
page_manager.page.moderation_dashboard, you won't need this.Remove this completely.
Comment #16
bendeguz.csirmaz commentedComment #17
bendeguz.csirmaz commentedA few words about this:
ConditionPluginBase::validateConfigurationFormand theConditionPluginBase::validateContextsfunctions.Comment #18
bendeguz.csirmaz commentedFixed coding standard.
Comment #19
huzookaI think we need a
statusconfig here for this plugin and formoderation_dashboard_accessas well since without that it's impossible to use these conditions on the standard block layout.Add
statusfor this as well.The response subscriber's
onResponsemethod deserves a little refactor as well.has_moderated_content_typecondition plugin returns TRUE before the response's target url is changedview any moderation dashboardpermission, so check that as wellComment #20
bendeguz.csirmaz commentedI think it would be easier if we just didn't display those conditions on the block form. This can easily be done with the
hook_plugin_filter_TYPE__CONSUMER_alter.Added a check for moderated content types before redirecting.
If a user only has the
view any moderation dashboardpermission they can't view their own dashboard because they do not have one (this is extensively covered in the test).Are you saying this permission should also come with dashboard ownership?
Comment #21
bendeguz.csirmaz commentedComment #23
bendeguz.csirmaz commentedRerolled.
Comment #25
bendeguz.csirmaz commentedFixed test.
Comment #26
huzookaExcellent work, looks right to me now, thanks!
@samuel.mortenson, any thoughts?
Comment #28
samuel.mortensonThis looks great - little details like not showing the new condition plugins on block forms is a smart addition too. Thanks for all the hard work!