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
- Provide permissions for Content Creator, Designer, Developer, and Content Manager (the
Digital Strategist
in the Drupal CMS personas) - Show or hide UI elements based on permissions
- Allow site admins to configure these permissions from Drupal’s existing roles/permissions system
- Allow users with “Publish Experience Builder Content” to access the review changes panel, and to view all content that is about to be published.
- 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.
- 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.
-
The following permissions must be available:
- Administer Page Template (for
PageRegionconfig entities, which together make up the "page template") - Administer Sections (for
Patternconfig entities) Administer Componentsadminister themes(forComponentconfig entities), per @lauriii in #3508694-18: Permissions for XB config entity types- Administer Code Components (for
JavaScriptComponentandAssetLibraryconfig entities) Administer Component Overrides(⚠️ on hold until the highly experimental code that #3505993: Code Components as Block Overrides, step 1 added stabilizes)Administer Component Content Type Templates(⚠️ on hold until #3511366: [META] Introduce a `ContentTypeTemplate` config entity + related infrastructure lands)View Pages (forcore'sPagecontent entities)access contentper #3502048-10: Permissions for XB Page content entities: edit/delete/create, reuse core's `access content` for viewing- Edit Pages (for
Pagecontent entities) - Delete Pages (for
Pagecontent entities) - Create Pages (for
Pagecontent entities) - Publish Experience Builder Content (covers multiple content + config entity types, see functional requirements above for details)
- Administer Page Template (for
Non-Functional Requirements or Constraints
- 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.)
- Add missing access control logic + use it on routes (server)
- ✅ #3508694: Permissions for XB config entity types
- ✅ #3502048: Permissions for XB Page content entities: edit/delete/create, reuse core's `access content` for viewing
- ✅ #3519992: Previewing the Layout causes an error when the user does not have access to all fields in the auto-save data
- ✅ #3518836: experience_builder.api.config.list route should not require 'administer themes' permission
- ✅ #3519878: ContentCreatorVisibleXbConfigEntityAccessControlHandler's `view` access must refuse access to disabled config entities
- ✅ #3494915: Support entity-level + field-level access checking in auto-save — i.e. in `experience_builder.api.api.(layout.post|auto-save.post)`
- ✅ #3516432: Update all XB routes to respect content entity update/field edit access of edited XB field
- ✅ #3529892: Add a Publish Experience Builder Content permission, use it on `experience_builder.api.auto-save.(delete|post)` routes
- ✅ #3506434: Disallow deleting an XB-enabled content entity if it's currently the homepage
- ✅#3531916: `api.config.delete` allows deleting `global` asset library
- ✅#3533781: Allow users with edit permissions to see and manage revisions of `Page` content entities
- [blocked/on hold: block override components] → #3519737: ADR for dynamic code components (to be removed?)
- ✅#3529924: Add access check for using Experience Builder at all: if >=1 content entity type with an XB field can be created or edited.
- ✅#3533728: Duplicate operation should require 'create' permission, not 'update' permission
- Update
Internal HTTP API
to respect access control itself (by omitting inaccessible data or by passing permission information to the client)- ✅ #3516655: Omit `PageRegion` representation from `ApiLayoutController::get()`, 403 if sending it in `::patch()` or `::post()`
- ✅ #3516648: Update `ExperienceBuilderController` to pass current user's XB high-level permissions to the client
- ✅ #3516657: Update `ApiContentControllers::list()` to expose available content entity operations in `meta`
- ✅ #3529895: Provide the client with `create` operation access information similar to #3516657
- ✅ #3531841: Expose Publish Experience Builder Content permission to the client UI
- ✅ #3531913: `api.config.get` route returns data without any authentication due to broad `view` access
- ✅ #3529426: Add entity access check on `ApiAutoSaveController::post()`
- ✅ #3527244: Add test coverage that ensure fields values the user has view but not edit access to can NOT be saved to AutoSave
- ✅ #3532454: Add field access check on `ApiAutoSaveController::post()`
- #3533641: Add reason when denied access to `api.config.get` Assigned to: penyaskito
- XB UI must respect permissions
- ✅ Build out a set of utils: #3516641: Make the XB UI show only UI elements/operations available to the current user
- … to enable the following:
- ✅
🛑 Blockedunblocked by #3516657: Update `ApiContentControllers::list()` to expose available content entity operations in `meta`: #3516641: Make the XB UI show only UI elements/operations available to the current user (by checking`drupalSettings.xb.permission`and`drupalSettings.xb.contentEntityCreateOperations`) - ✅ Respecting the individual operations present in each object returned by
`/xb/api/v0/content/{entity_type}`(covered also in #3516641) - Selective publishing: if I don't have access to update an entity (the edit-form operation), I shouldn't see a checkbox for publishing even if I have the publishing permission (we might cover this directly in #3530493: Create UI for selective publishing or discarding of changes)
- ✅
- "content manager" persona: #12, https://git.drupalcode.org/project/experience_builder/-/merge_requests/828
User interface changes
None.
Issue fork experience_builder-3452581
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
larowlanComment #3
larowlanComment #4
wim leersThanks for the review!
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:
at the top of the file
// @todo Novice: inject service,// @todo Novice: introduce new permission, et cetera?src-rough(back end) andui/src-rough(front end) directoriesComment #5
wim leersStarted adopting #4.1: https://git.drupalcode.org/project/experience_builder/-/merge_requests/2... 🤠
Comment #6
wim leersI'm going to update the issue summary to outline, to make this a great issue to sprint on at DrupalCon Barcelona :)
Comment #7
wim leersComment #8
wim leersNobody 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.
Comment #9
wim leersStill relevant!
Comment #10
wim leersDiscussed this in detail with @lauriii. Converting this to a meta issue instead.
Comment #11
wim leersRefinements:
Componentconfig entities)Comment #12
wim leersis a persona that did not exist until now. It's the in the Drupal CMS personas.
Comment #13
wim leersClosed #3513569: Gate editing global regions behind 'administer blocks' permission in the UI in favor of this issue.
Comment #15
wim leersUpdating XB's docs per #12: https://git.drupalcode.org/project/experience_builder/-/merge_requests/828
(This updates the docs that #3454677: Diagram tying the product requirements + decisions together introduced.)
Comment #17
wim leersOversights in #3502048: Permissions for XB Page content entities: edit/delete/create, reuse core's `access content` for viewing clarified by @lauriii. 👍
Comment #19
wim leersAnother important oversight spotted while refining the issue summary for #3508694: #3508694-14: Permissions for XB config entity types, asked @lauriii to confirm.
Comment #20
wim leersOutline of remaining plan.
Comment #21
wim leersComment #22
jessebaker commentedComment #23
wim leersComment #24
wim leersComment #25
lauriiiComment #26
wim leers#3508694: Permissions for XB config entity types is in 🥳
Comment #27
wim leersis unblocked!
Comment #29
wim leersAdded #3519878: ContentCreatorVisibleXbConfigEntityAccessControlHandler's `view` access must refuse access to disabled config entities — great find, @penyaskito!
Comment #30
wim leersComment #32
wim leersAdded #3519992: Previewing the Layout causes an error when the user does not have access to all fields in the auto-save data, found by @tedbow.
Comment #33
wim leersComment #34
wim leersComment #35
penyaskitoIf I got this right, we are missing issues for:
Edited for links.
Comment #36
wim leers#3516657: Update `ApiContentControllers::list()` to expose available content entity operations in `meta` landed, which means this meta is very much in need of an overhaul.
Comment #37
wim leersI 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?
Comment #38
penyaskitoPer #3508694-18: Permissions for XB config entity types and #23 here.
Comment #39
penyaskitoComment #40
penyaskitoComment #41
wim leers#3516432: Update all XB routes to respect content entity update/field edit access of edited XB field is in :)
Comment #42
penyaskitoCreated #3529895: Provide the client with `create` operation access information similar to #3516657, #3529892: Add a Publish Experience Builder Content permission, use it on `experience_builder.api.auto-save.(delete|post)` routes
Comment #43
penyaskitoCreated #3529924: Add access check for using Experience Builder at all: if >=1 content entity type with an XB field can be created or edited.
Comment #44
wim leers#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
Pagecontent 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 😅🙈
Comment #45
wim leers#3505224: XbConfigEntityHttpApiTest missing test coverage for individual GET requests for JavaScriptComponent + AssetLibrary is in.
Comment #46
wim leersConcern: 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 theextraPermissionsinfrastructure 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?
Comment #47
wim leersI 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:
👆 Will mean that you won't be able to see 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.permissionsand hence requiring an update toExperienceBuilderController), 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).Comment #48
wim leers#3529892: Add a Publish Experience Builder Content permission, use it on `experience_builder.api.auto-save.(delete|post)` routes landed. 🎉
Comment #49
penyaskito#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..
Comment #50
penyaskitoCreated #3531841: Expose Publish Experience Builder Content permission to the client UI
Comment #51
penyaskitoAdded #3531913: `api.config.get` route returns data without any authentication due to broad `view` access
Comment #52
wim leers#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.
Comment #53
wim leers#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.ymland 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).Comment #54
penyaskitore: zero routes should be using `access administration pages`
We have
experience_builder.api.auto-save.getandexperience_builder.api.log_errorstill 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_inwith 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)
Comment #55
penyaskitoUpdated IS with front-end issues now that we expose most required permissions/operations.
TBD: Create the issues.
Comment #56
penyaskitoComment #57
wim leersRemoved because #3455629: [PP-1] [META] 7. Content Templates — aka "default layouts" — affects the tree+props data model is not happening before
beta1.#3531841: Expose Publish Experience Builder Content permission to the client UI is in.
Comment #58
wim leers#3531913: `api.config.get` route returns data without any authentication due to broad `view` access landed yesterday.
Comment #59
penyaskitoSplit field access checks from #3529426: Add entity access check on `ApiAutoSaveController::post()` to #3532454: Add field access check on `ApiAutoSaveController::post()`.
Comment #60
penyaskito#3529426: Add entity access check on `ApiAutoSaveController::post()` landed
Comment #61
penyaskitoComment #62
penyaskitoComment #63
penyaskito♻️
Comment #64
penyaskito#3506434: Disallow deleting an XB-enabled content entity if it's currently the homepage just landed
Comment #65
wim leers#3506434: Disallow deleting an XB-enabled content entity if it's currently the homepage is in! 🎉
Reviewed all of the remaining server-side ones:
They're all in the hands of @penyaskito and/or @tedbow.
Comment #66
wim leersBumped #3529924 to beta blocking per #3529924-19: Add access check for using Experience Builder at all: if >=1 content entity type with an XB field can be created or edited..
#3527244: Add test coverage that ensure fields values the user has view but not edit access to can NOT be saved to AutoSave landed 🎉
Comment #67
penyaskitoUpdate meta with some non-priority low-hanging fruit.
Tempted to remove #3519737: ADR for dynamic code components from the meta.
Comment #68
penyaskitoAdded #3533781: Allow users with edit permissions to see and manage revisions of `Page` content entities
Comment #69
penyaskito♻️
Comment #70
penyaskitoComment #71
wim leersJust landed:
Comment #72
wim leersOh, and #3527156: Add test coverage for access exception in \Drupal\experience_builder\ClientDataToEntityConverter::checkPatchFieldAccess(), too, last week!
Comment #73
penyaskito#3529924: Add access check for using Experience Builder at all: if >=1 content entity type with an XB field can be created or edited. and #3533728: Duplicate operation should require 'create' permission, not 'update' permission landed.
Comment #74
wim leersBugs reported relating to this meta:
Comment #75
penyaskito4. #3535221: Pending changes leaking entities that user might have no access to
Comment #76
wim leersI think this actually all was finished back in #75 🤓
Yay, thanks everyone! 🥳