summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxjm2017-04-19 11:07:22 -0500
committerxjm2017-04-19 13:28:30 -0500
commit92e613aefac3af2c861e8118a2fe98f399521c50 (patch)
tree54720b979044dea670ae1ba2b764a97f39f16467
parent2dc6d91d609ee76a3d463eedcb9eba0903c94580 (diff)
SA-CORE-2017-002 by alexpott, xjm, larowlan, Wim Leers, samuel.mortenson, Berdir, dawehner, tstoeckler, catch
(cherry picked from commit 6b7f47fc3a9e08aa64a73faaa25dd0ddb8f33dd8)
-rw-r--r--core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php b/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
index d1d43ee..3b16d1c 100644
--- a/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
+++ b/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
@@ -303,6 +303,19 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce
// Get the default access restriction that lives within this field.
$default = $items ? $items->defaultAccess($operation, $account) : AccessResult::allowed();
+ // Explicitly disallow changing the entity ID and entity UUID.
+ if ($operation === 'edit') {
+ if ($field_definition->getName() === $this->entityType->getKey('id')) {
+ return $return_as_object ? AccessResult::forbidden('The entity ID cannot be changed') : FALSE;
+ }
+ elseif ($field_definition->getName() === $this->entityType->getKey('uuid')) {
+ // UUIDs can be set when creating an entity.
+ if ($items && ($entity = $items->getEntity()) && !$entity->isNew()) {
+ return $return_as_object ? AccessResult::forbidden('The entity UUID cannot be changed')->addCacheableDependency($entity) : FALSE;
+ }
+ }
+ }
+
// Get the default access restriction as specified by the access control
// handler.
$entity_default = $this->checkFieldAccess($operation, $field_definition, $account, $items);