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
- Create a simple webform handler, implementing the
WebformHandlerInterface::accessmethod - Attach this handler to any existing or new webform.
- 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
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
arousseau commentedComment #5
drupal.ninja03 commentedCreated 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.
Comment #6
erlingx commentedI 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.
Comment #8
liam morlandThanks!