Problem/Motivation

#3452314: [MR Only] provide UI foundation with Drag and Drop + panels aka https://git.drupalcode.org/project/experience_builder/-/merge_requests/33 added SdcController to provide a skeleton of backend listings. In a retrospective review a few issues were flagged.

Functional Requirements

  1. Provide permissions for Content Creator, Designer, Developer, and Content Manager (the Digital Strategist in the Drupal CMS personas)
  2. Show or hide UI elements based on permissions
  3. Allow site admins to configure these permissions from Drupal’s existing roles/permissions system
  4. Allow users with “Publish Experience Builder Content” to access the review changes panel, and to view all content that is about to be published.
  5. User with permission “Publish Experience Builder Content” must have access to edit all underlying entities at the time of publishing, in order to be able to publish changes.
  6. User with “Edit pages” without the “Publish Experience Builder Content” permission must be able to view changes to all content that they have edit access to.
  7. The following permissions must be available:
    1. Administer Page Template (for PageRegion config entities, which together make up the "page template")
    2. Administer Sections (for Pattern config entities)
    3. Administer Components administer themes (for Component config entities), per @lauriii in #3508694-18: Permissions for XB config entity types
    4. Administer Code Components (for JavaScriptComponent and AssetLibrary config entities)
    5. Administer Component Overrides (⚠️ on hold until the highly experimental code that #3505993: Code Components as Block Overrides, step 1 added stabilizes)
    6. Administer Component Content Type Templates (⚠️ on hold until #3511366: [META] Introduce a `ContentTypeTemplate` config entity + related infrastructure lands)
    7. View Pages (for Page content entities) core's access content per #3502048-10: Permissions for XB Page content entities: edit/delete/create, reuse core's `access content` for viewing
    8. Edit Pages (for Page content entities)
    9. Delete Pages (for Page content entities)
    10. Create Pages (for Page content entities)
    11. Publish Experience Builder Content (covers multiple content + config entity types, see functional requirements above for details)

Non-Functional Requirements or Constraints

  1. Access control logic MUST NOT prevent efficient cacheability: per-user caching must be avoided; all XB API responses that can be cached by Dynamic Page Cache are expected to continue to do so.

Out of Scope

Preventing deletion of Code Components when there are instances using it.
Impact: It’s possible to break existing XB component trees in Page and Node content entities, by deleting Code Components.

(Config entity dependencies prevent this from occurring for Pattern and PageRegion config entities.)

Use Dynamic Components permission
Impact: All users have access to the same set of components and dynamic components until we introduce “slot restrictions” and/or category based permissions.
#3513563: [later phase] [META] Component slot restrictions ("which?") + limits ("how many?")

Proposed resolution

(Numbered lists must happen one after the other, bulleted lists can happen in parallel.)

  1. Add missing access control logic + use it on routes (server)
  2. Update Internal HTTP API to respect access control itself (by omitting inaccessible data or by passing permission information to the client)
  3. XB UI must respect permissions
    1. ✅ Build out a set of utils: #3516641: Make the XB UI show only UI elements/operations available to the current user
    2. … to enable the following:
  • Missing test coverage: to ensure the access control handlers work not only in isolation, but also in reality
  • Missing test coverage: to ensure access to field on auto-save:
  • Docs
  • User interface changes

    None.

    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

    larowlan created an issue. See original summary.

    larowlan’s picture

    Issue summary: View changes
    larowlan’s picture

    Issue tags: +Posthumous review
    wim leers’s picture

    Assigned: Unassigned » larowlan
    Issue summary: View changes
    Issue tags: +Novice
    Related issues: +#3452314: [MR Only] provide UI foundation with Drag and Drop + panels

    Thanks for the review!

    • I think everybody would agree all of the things you listed should happen eventually.
    • But they should not be required to happen now.

    We need to be able to iterate quickly, without accumulating enormous MRs like we tend to do in Drupal core. In Drupal core this makes sense because it's already a consistent whole, but that's not yet true for Experience Builder.
    In other words: for XB, we intentionally want to avoid the "every commit must be perfect" strategy that Drupal core uses.

    I acknowledge this means outside participation is more difficult: what is in a "ready for detailed review" state vs "slapped together, don't bother to review" state? So I think that is the challenge we should solve rather than disallowing imperfect/incomplete MRs to be reviewed.

    So I propose to introduce a way to convey this. Ideas:

    1. an impossible to miss
      // ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
      // ⚠️ 🔨🧹  This file is an early iteration. Do not review in detail yet.   🧹🔨 ⚠️
      // ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
      

      at the top of the file

    2. Issues like the one you created here make for excellent Novice tasks! 😊 So it's not like this is a wasted effort at all. Perhaps we should even intentionally call this out, by adding comments like // @todo Novice: inject service, // @todo Novice: introduce new permission, et cetera?
    3. introduce src-rough (back end) and ui/src-rough (front end) directories
    4. … something else?
    wim leers’s picture

    wim leers’s picture

    Assigned: larowlan » wim leers
    Status: Active » Postponed
    Issue tags: +Needs issue summary update

    I'm going to update the issue summary to outline, to make this a great issue to sprint on at DrupalCon Barcelona :)

    wim leers’s picture

    Title: SdcController cleanup tasks » SdcController clean-up: remove dead routes + introduce XB-specific permission for routes
    Version: » 0.x-dev
    Assigned: wim leers » Unassigned
    Issue summary: View changes
    Status: Postponed » Active
    Issue tags: -Needs issue summary update +Barcelona2024
    Related issues: +#3477164: Lift all methods out of `SdcController` into separate invokable services-as-controllers, +#3471070: `/xb-components` takes multiple seconds when *many* SDCs are present, +#3450308: Create an Open API spec for the current mock HTTP responses
    wim leers’s picture

    Title: SdcController clean-up: remove dead routes + introduce XB-specific permission for routes » Introduce XB-specific permission for routes
    Issue summary: View changes
    Issue tags: -Barcelona2024
    Related issues:

    Nobody picked this up during DrupalCon. Narrowing scope. Removing dead routes should happen in #3477164: Lift all methods out of `SdcController` into separate invokable services-as-controllers.

    wim leers’s picture

    Still relevant!

    wim leers’s picture

    Title: Introduce XB-specific permission for routes » [META] XB Permissions
    Component: Page builder » Code
    Assigned: Unassigned » wim leers
    Category: Task » Plan
    Issue summary: View changes
    Issue tags: -Novice +stable blocker
    Related issues: +#3513563: [later phase] [META] Component slot restrictions ("which?") + limits ("how many?")

    Discussed this in detail with @lauriii. Converting this to a meta issue instead.

    wim leers’s picture

    Issue summary: View changes

    Refinements:

    • Added: Administer Components (as in: XB Component config entities)
    • Put Administer Component Overrides on hold, see issue summary for details.
    • Put Administer Content Type Templates on hold, see issue summary for details.
    wim leers’s picture

    Issue summary: View changes

    Content Manager is a persona that did not exist until now. It's the Digital Strategist in the Drupal CMS personas.

    wim leers’s picture

    wim leers’s picture

    wim leers credited lauriii.

    wim leers’s picture

    • wim leers committed 682c3ffb on 0.x
      Issue #3452581 by wim leers, larowlan, lauriii: [META] XB Permissions
      
    wim leers’s picture

    Issue summary: View changes

    Another important oversight spotted while refining the issue summary for #3508694: #3508694-14: Permissions for XB config entity types, asked @lauriii to confirm.

    wim leers’s picture

    Issue summary: View changes

    Outline of remaining plan.

    wim leers’s picture

    Issue summary: View changes
    jessebaker’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    lauriii’s picture

    Issue summary: View changes
    wim leers’s picture

    wim leers’s picture

    Assigned: wim leers » jessebaker
    Issue summary: View changes

    Hide parts of UI current user cannot access instead of always showing everything

    is unblocked!

    wim leers’s picture

    wim leers’s picture

    Issue summary: View changes

    wim leers credited tedbow.

    wim leers’s picture

    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Issue summary: View changes
    penyaskito’s picture

    If I got this right, we are missing issues for:

    Edited for links.

    wim leers’s picture

    Issue summary: View changes
    wim leers’s picture

    Assigned: jessebaker » penyaskito
    Issue summary: View changes
    Issue tags: +Needs issue summary update

    I did the simple first pass, but I think this would benefit a lot from identifying next steps — @penyaskito, what else do you think is needed for all the BE pieces here to be done, to allow the FE (the XB UI) to start respecting permissions throughout?

    penyaskito’s picture

    penyaskito’s picture

    Issue summary: View changes
    penyaskito’s picture

    Issue summary: View changes
    wim leers’s picture

    penyaskito’s picture

    wim leers’s picture

    #3516657: Update `ApiContentControllers::list()` to expose available content entity operations in `meta` informs the client which operations are available on existing entities. But what about informing the client of when creating a new entity is supported?

    i.e. conveying when this should be visible:

    Note that this too must be done in a way that is not specific to Page content entities, even though that's the only type of content entity that can currently be created via XB. Because eventually #3513566: [later phase] [PP-1] Add generic create entity support (currently just `Page` content entities) will need to be supported (not by beta).

    EDIT: I missed #42 😅🙈

    wim leers’s picture

    Concern: we're blanket granting all permissions in XBTestSetup. This makes it less clear which functionality requires which permissions, and makes it so that we don't end up using the extraPermissions infrastructure that exists in the e2e tests.

    I'm not blocking merges for that because of the time pressure we're under, but it is this meta that is introducing many permissions, so it SHOULD (IMHO) also be up to the MRs for this meta to refine the e2e tests as needed. (In particular when testing the "test functionality when permission is not granted" case, which is true for #3529892: Add a Publish Experience Builder Content permission, use it on `experience_builder.api.auto-save.(delete|post)` routes.)

    Thoughts?

    wim leers’s picture

    I expanded the scope at #3529892: Add a Publish Experience Builder Content permission, use it on `experience_builder.api.auto-save.(delete|post)` routes to also cover the route that was just added by #3529207: For selective reverting add DELETE auto-save endpoint under that new permission.

    But … IMHO the following should also be covered by it:

    experience_builder.api.auto-save.get:
      path: '/xb/api/v0/auto-saves/pending'
      defaults:
        _controller: 'Drupal\experience_builder\Controller\ApiAutoSaveController::get'
      requirements:
        _permission: 'access administration pages'
      methods: ['GET']
      options:
        _format: 'json'
    

    👆 Will mean that you won't be able to see Review changes unless you have the necessary permissions. That will need a XB UI logic update too, to either avoid making that request at all (which would then require the UI being informed via drupalSettings.xb.permissions and hence requiring an update to ExperienceBuilderController), or to allow making that request but then NOT erroring (which would also harden against the case where the permission is revoked after the XB UI has been loaded).

    penyaskito’s picture

    #47: Right, we got to the same conclusion in the document Jesse created for making an overview on what needs to be changed in the UI app for having permission-awareness.

    I'm wondering if they should be able to see the review panel though, as that's the way to see error messages on validation at the moment.

    But agree that ideally we wouldn't have any reference to "access administration pages" in routing.yml. That should be a check for the permission added on #3529892: Add a Publish Experience Builder Content permission, use it on `experience_builder.api.auto-save.(delete|post)` routes, or even better, the check access in #3529924: Add access check for using Experience Builder at all: if >=1 content entity type with an XB field can be created or edited..

    penyaskito’s picture

    penyaskito’s picture

    wim leers’s picture

    #3531858: CanvasController's response must vary by access result cacheability is a stable-blocking follow-up for #3529895: Provide the client with `create` operation access information similar to #3516657, because without it an information disclosure is possible in principle, if contrib/custom modules are installed that alter access control.

    wim leers’s picture

    Issue summary: View changes

    #3529895: Provide the client with `create` operation access information similar to #3516657 is in.

    @penyaskito in #51: thanks! Can you please check every route in experience_builder.routing.yml and ensure they have the appropriate access control, and if not, create corresponding issues? 🙏

    For example, zero routes should be using access administration pages, and anonymous/unauthenticated access should be prevented (see #3531913: `api.config.get` route returns data without any authentication due to broad `view` access for example).

    penyaskito’s picture

    re: zero routes should be using `access administration pages`

    We have experience_builder.api.auto-save.get and experience_builder.api.log_error still using `access administration pages`. I think we can't remove that until we can depend on the new access handler in #3529924: Add access check for using Experience Builder at all: if >=1 content entity type with an XB field can be created or edited., so I suggest we unpospone that one.

    When that lands, I think it will be great replacing _user_is_logged_in with that new access handler, which will reduce the exposure of end-points for just those using XB.

    I verified all routes as of now have access checks in place (aside of the known #3531913: `api.config.get` route returns data without any authentication due to broad `view` access)

    penyaskito’s picture

    Issue summary: View changes

    Updated IS with front-end issues now that we expose most required permissions/operations.
    TBD: Create the issues.

    penyaskito’s picture

    Issue summary: View changes
    wim leers’s picture

    wim leers’s picture

    penyaskito’s picture

    penyaskito’s picture

    penyaskito’s picture

    Issue summary: View changes
    penyaskito’s picture

    Issue summary: View changes
    penyaskito’s picture

    ♻️

    penyaskito’s picture

    penyaskito’s picture

    Issue summary: View changes

    Update meta with some non-priority low-hanging fruit.
    Tempted to remove #3519737: ADR for dynamic code components from the meta.

    penyaskito’s picture

    penyaskito’s picture

    ♻️

    penyaskito’s picture

    Issue summary: View changes
    wim leers’s picture

    penyaskito’s picture

    wim leers’s picture

    Assigned: penyaskito » Unassigned
    Status: Active » Fixed

    I think this actually all was finished back in #75 🤓

    Yay, thanks everyone! 🥳

    Status: Fixed » Closed (fixed)

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