Overview

Right now we only have an administration permission for pages. We should have (relatively) granular ones:

  1. View Pages → use core's access content instead per #10.
  2. Edit Pages
  3. Delete Pages
  4. 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.

Command icon 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

mglaman created an issue. See original summary.

mglaman’s picture

Assigned: Unassigned » mglaman

Our team has an upcoming ticket for this.

attilatilman made their first commit to this issue’s fork.

wim leers’s picture

Issue tags: +Novice

philalonso made their first commit to this issue’s fork.

mglaman’s picture

Assigned: mglaman » Unassigned
wim leers’s picture

Title: Provide granular permissions for pages » Permissions for XB Page content entities
Assigned: Unassigned » lauriii
Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)
Issue tags: -Novice +Needs tests, +Needs product manager review
Parent issue: » #3452581: [META] XB Permissions
Related issues: +#3508694: Permissions for XB config entity types

Per @lauriii, we're actually indeed going to skip ownership permissions as indicated as a maybe (We can decide to skip any/own and ignore ownership permissions.). @lauriii specifically listed these 4:

  1. View Pages (view xb_page)
  2. Edit Pages (edit xb_page)
  3. Delete Pages (delete xb_page)
  4. Create Pages (create xb_page)

AFAICT this means @lauriii also intends us to remove HEAD's administer xb_page permission.

@lauriii to confirm

  1. Am I extrapolating correctly that you think permissions should be as simple as possible, and hence we should refactor away the administer xb_page permission 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.
  2. Do we indeed want to add View Pages (view xb_page) instead of relying on access content? That permission used to be Node-specific, but has since been kind of generalized:
    # Note that the 'access content' permission is moved to the Node section of the
    # permission form when the Node module is enabled.
    access content:
      title: 'View published content'
    

    system.permissions.yml
    Impact: an additional permission must be enabled for XB's landing pages to be viewable by anonymous users; the access content permission is already typically assigned because it us used for: viewing nodes, viewing public:// files, file upload progress, and more.

wim leers’s picture

Issue summary: View changes
lauriii’s picture

Assigned: lauriii » Unassigned
Status: Postponed (maintainer needs more info) » Active
Issue tags: -Needs product manager review

Am I extrapolating correctly that you think permissions should be as simple as possible, and hence we should refactor away the administer xb_page permission in this issue?

Yes, 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_page permission 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.

Do we indeed want to add View Pages (view xb_page) instead of relying on access content? That permission used to be Node-specific, but has since been kind of generalized:

I agree that we should rely on the generic access content permission. 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. 🤯

wim leers’s picture

Title: Permissions for XB Page content entities » Permissions for XB Page content entities: edit/delete/create, reuse core's `access content` for viewing
Issue summary: View changes

Perfect, incorporated 👍

wim leers’s picture

Issue summary: View changes
mglaman’s picture

We should keep administer pages and follow normal permission patterns. Otherwise users will need to have edit, create, and delete instead of one permission.

I noticed that the administer xb_page permission 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.

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.

Note: this means the Page content entity type will NOT use the node module's access content.

I think this is wrong in issue summary as we are using it, but it's provided by the system module.

wim leers’s picture

Issue summary: View changes
Note: this means the Page content entity type will NOT use the node module's access content.

I think this is wrong in issue summary as we are using it, but it's provided by the system module.

You're right — I failed to remove this in #11 — my bad! 😅

wim leers’s picture

Otherwise users will need to have edit, create, and delete instead of one permission.
[…] Removing this makes the granular permissions more complicated.

I 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.

mglaman’s picture

+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?

lauriii’s picture

We're not providing upgrade paths for XB currently, so it'd be fine to change this without an upgrade path.

isholgueras’s picture

Assigned: Unassigned » isholgueras
wim leers’s picture

We're not providing upgrade paths for XB currently, so it'd be fine to change this without an upgrade path.

Indeed. While XB is in alpha, we don't provide this.

isholgueras’s picture

Status: Active » Needs review

I think I've finished the new permissions, replace administer xb_page by access content , create xb_page , edit xb_page and delete 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.

penyaskito’s picture

Status: Needs review » Needs work

Nice!
Some of my comments need @Wim confirmation, but there are some actionable already.

isholgueras’s picture

Status: Needs work » Needs review
wim leers’s picture

Status: Needs review » Needs work

Nice to see this moving forward! 😄

isholgueras’s picture

Status: Needs work » Needs review
penyaskito’s picture

Status: Needs review » Needs work

Some tests are failing

wim leers’s picture

🏓 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_permission and how that should change. This needs to be reflected in the issue summary.

isholgueras’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update
isholgueras’s picture

Issue summary: View changes
isholgueras’s picture

Status: Needs work » Needs review
isholgueras’s picture

Assigned: isholgueras » Unassigned
wim leers’s picture

Status: Needs review » Needs work

🏓

isholgueras’s picture

Status: Needs work » Needs review
wim leers’s picture

Status: Needs review » Reviewed & tested by the community
wim leers’s picture

Assigned: Unassigned » mglaman

As the owner of the Page content entity type, I'd like @mglaman to explicitly approve 😊

mglaman’s picture

Assigned: mglaman » Unassigned

Approved!

  • lauriii committed 5e59bae9 on 0.x authored by philalonso
    Issue #3502048 by isholgueras, wim leers, lauriii, philalonso, mglaman,...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Thank you @isholgueras for pushing this over the finish line! 👏 🎉

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.