Problem/Motivation

This issue was initially addressed as a security concern, but it was determined that it could be made public without risk.

The WebformHandlerInterface::access method is called when attempting to perform an operation on an existing submission or to display it.
However, this does not seem to be the case when accessing the webform itself.

I thought the "create" operation would also be handled.
Just as you get an access denied error when attempting to view a webform for which the "Create submissions" access rule does not authorize your account/role, I thought the web form would not be accessible.

I expected \Drupal\webform\Entity\WebformSubmission::access() to be called when viewing or submitting the webform, which does not seem to be the case at the moment.
This would have been similar to the behavior of an entity form, such as the node form, for example. When attempting to access /node/add/{node_type}, \Drupal\node\Entity\Node::access() is called with the "create" operation.

Steps to reproduce

  1. Create a simple webform handler, implementing the WebformHandlerInterface::access method
  2. Attach this handler to any existing or new webform.
  3. Try displaying and submitting the webform.

Proposed resolution

In my opinion, this should at least be better documented to make sure a developer won't accidentally rely on this method to restrict access to a sensitive form.

Remaining tasks

Update the doc block for the method, or discuss further.

User interface changes

None.

API changes

None.

Data model changes

None.

Issue fork webform-3593002

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

arousseau created an issue. See original summary.

arousseau’s picture

Issue summary: View changes

drupal.ninja03 made their first commit to this issue’s fork.

drupal.ninja03’s picture

Status: Active » Needs review

Created an MR to clarify WebformHandlerInterface::access() documentation.

The update explains that the method controls access to operations on an existing webform submission, and updates the parameter descriptions to refer to the webform submission instead of generic entity wording.

Setting to Needs review.

erlingx’s picture

Status: Needs review » Reviewed & tested by the community

I reviewed the updated documentation and confirmed that it better describes the access restriction functionality of the WebformHandlerInterface::access() method.
It clearly explains that this method applies to operations on existing webform submissions.

liam morland’s picture

Status: Reviewed & tested by the community » Fixed

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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