Overview

Forked from #3494915-45: Support entity-level + field-level access checking in auto-save — i.e. in `experience_builder.api.api.(layout.post|auto-save.post)` and #3529426: Add entity access check on `ApiAutoSaveController::post()` later.

Add field access check on `ApiAutoSaveController::post()`

Proposed resolution

  • Update `ApiAutoSaveController::post()`, which must:
    • if a content entity, iterate over all changed fields, throw a CacheableAccessDeniedHttpException if any of them fail on $entity->get($field_name)->access(operation: 'edit', return_as_object: TRUE).
  • Update `\Drupal\Tests\experience_builder\Kernel\ApiAutoSaveControllerTest::testApiAutoSaveControllerPost`

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

penyaskito created an issue. See original summary.

wim leers’s picture

I think this is the intent?

wim leers’s picture

Test coverage looks great already 👍

tedbow’s picture

Priority: Normal » Critical
Status: Active » Needs work

Marking as critical see https://git.drupalcode.org/project/experience_builder/-/merge_requests/1... in #3527156: Add test coverage for access exception in \Drupal\experience_builder\ClientDataToEntityConverter::checkPatchFieldAccess()

Basically \Drupal\experience_builder\Controller\ApiAutoSaveController::post use to call \Drupal\experience_builder\ClientDataToEntityConverter::convert which did field access checks but it no longer does since #3529622: Make auto-save manager only support passing and returning entity objects, remove support for arbitrary data, use deterministic hashing to ensure entries are actually updates

so basically 1 user with edit permission could get a field update into the auto-save and then another user without field update permission could publish the field update. I think the product goal is that user publishing should have all the permissions to do all the updates that happen on publish

We should move the test coverage from #3527156 https://git.drupalcode.org/project/experience_builder/-/blob/fe773efe8f3... to this issue, or make sure we have the same coverage

penyaskito’s picture

penyaskito’s picture

Assigned: penyaskito » wim leers
Status: Needs work » Needs review

Marking for preliminary review. We might want to do the trait for checking the field as Lee suggested, but could perfectly be part of the follow-up we wanted to open anyway and clear another critical beta blocker.

Leaving for Wim to evaluate.

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs review » Needs work
Issue tags: +Needs tests

I think @tedbow's Q should be answered by test coverage. 😇 This is a security matter, so here it makes sense to err on the side of caution.

wim leers’s picture

Assigned: Unassigned » penyaskito
penyaskito’s picture

Assigned: penyaskito » wim leers
Status: Needs work » Needs review
Issue tags: -Needs tests

Tagging needs review. We need to verify #note_543156 and #note_545354 is the expected outcome.

wim leers’s picture

Merged in upstream after #3492722: Update XB to require Drupal 11.2 landed; resolved several conflicts.

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs review » Reviewed & tested by the community

Very nice end result, and @penyaskito showing off with code elegance rarely seen! 🤓🤩🙇

wim leers’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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