Overview
Right now we only have an administration permission for pages. We should have (relatively) granular ones:
View Pages→ use core'saccess contentinstead per #10.- Edit Pages
- Delete Pages
- Create Pages
That means we should remove the current administer xb_page permission (confirmed at #10).
Proposed resolution
Manually implement or leverage Entity API. → We should not add contrib module dependencies unless there's very strong reasons to do so. If the requirements specified the need for "own vs any" permissions, then https://git.drupalcode.org/project/entity/-/blob/8.x-1.x/src/EntityPermi... would've been possibly justifiable, but that is not the case. → confirmed by @lauriii in #10.
Update \Drupal\experience_builder\Entity\PageAccessControlHandler
The collection_permission for the Page entity, originally set up to access xb_page overview, must be tied to edit xb_page as @laurii confirmed in this comment.
User interface changes
None yet, that is out of scope.
Issue fork experience_builder-3502048
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mglamanOur team has an upcoming ticket for this.
Comment #4
wim leersComment #7
mglamanComment #8
wim leersPer @lauriii, we're actually indeed going to skip ownership permissions as indicated as a maybe (). @lauriii specifically listed these 4:
view xb_page)edit xb_page)delete xb_page)create xb_page)AFAICT this means @lauriii also intends us to remove HEAD's
administer xb_pagepermission.@lauriii to confirm
administer xb_pagepermission in this issue?Impact: either a "catch-all" admin permission for the Page content entity type or not. Having such an admin permission brings some mental model complexity.
access content? That permission used to be Node-specific, but has since been kind of generalized:—
system.permissions.ymlImpact: an additional permission must be enabled for XB's landing pages to be viewable by anonymous users; the
access contentpermission is already typically assigned because it us used for: viewing nodes, viewingpublic://files, file upload progress, and more.Comment #9
wim leersComment #10
lauriiiYes, we should keep the permissions as simple as we can at this point. We can keep adding more permissions as we add more functionality. We should avoid adding permissions which we don't have a clear use case for since they are pretty hard to remove later on.
I noticed that the
administer xb_pagepermission isn't used for anything at the moment, and I also couldn't think of anything that we should move behind that permission at the moment. We will have to introduce this permission later, once we have page entity specific configurations in the UI.I agree that we should rely on the generic
access contentpermission. I simply did not know that #2892821: Core modules check node module's "access content" permission for displaying things that have nothing to do with nodes had happened because the permission is still listed under Node. 🤯Comment #11
wim leersPerfect, incorporated 👍
Comment #12
wim leersComment #13
mglamanWe should keep
administer pagesand follow normal permission patterns. Otherwise users will need to have edit, create, and delete instead of one permission.It is. It is the edit/create/delete permission. Removing this makes the granular permissions more complicated. Someone may want authors to have full permissions whereas some may only want create/edit but no delete.
I think this is wrong in issue summary as we are using it, but it's provided by the system module.
Comment #14
wim leersYou're right — I failed to remove this in #11 — my bad! 😅
Comment #15
wim leersI don't see how granting all 3 permissions is more complicated than granting a single "administer" permission? In fact, this is one of those things where Drupal's been historically misleading, because it has no way of conveying to the site administrator that "administer" really means "edit+create+delete".
You wrote it's "normal", but I'd argue it's a Drupalism that is not worth perpetuating? 😅
IOW: I agree with @lauriii's preference for both the simplicity (no "administer" permission) and the explicitness.
Comment #16
mglaman+1 I'm okay with removing administer, we just need an upgrade path for adjusting on existing sites. Or are we going to just let end users handle that if they've decided to long-term run XB?
Comment #17
lauriiiWe're not providing upgrade paths for XB currently, so it'd be fine to change this without an upgrade path.
Comment #18
isholgueras commentedComment #19
wim leersIndeed. While XB is in
alpha, we don't provide this.Comment #20
isholgueras commentedI think I've finished the new permissions, replace
administer xb_pagebyaccess content,create xb_page,edit xb_pageanddelete xb_page.What I've done is adapt the permissions and review the tests that were already done, by maybe is something else needed to do.
Comment #21
penyaskitoNice!
Some of my comments need @Wim confirmation, but there are some actionable already.
Comment #22
isholgueras commentedComment #23
wim leersNice to see this moving forward! 😄
Comment #24
isholgueras commentedComment #25
penyaskitoSome tests are failing
Comment #26
wim leers🏓 Another review round. Found a number of problems, including changes that belong on #3516432: Update all XB routes to respect content entity update/field edit access of edited XB field and #3494915: Support entity-level + field-level access checking in auto-save — i.e. in `experience_builder.api.api.(layout.post|auto-save.post)`.
@lauriii clarified his stance on the
collection_permissionand how that should change. This needs to be reflected in the issue summary.Comment #27
isholgueras commentedComment #28
isholgueras commentedComment #29
isholgueras commentedComment #30
isholgueras commentedComment #31
wim leers🏓
Comment #32
isholgueras commentedComment #33
wim leersComment #34
wim leersAs the owner of the
Pagecontent entity type, I'd like @mglaman to explicitly approve 😊Comment #35
mglamanApproved!
Comment #37
lauriiiThank you @isholgueras for pushing this over the finish line! 👏 🎉