Commit 662512a9 authored by xjm's avatar xjm

SA-CORE-2017-002 by alexpott, xjm, larowlan, Wim Leers, samuel.mortenson,...

SA-CORE-2017-002 by alexpott, xjm, larowlan, Wim Leers, samuel.mortenson, Berdir, dawehner, tstoeckler, catch
parent e2fc6ffe
...@@ -303,6 +303,19 @@ public function fieldAccess($operation, FieldDefinitionInterface $field_definiti ...@@ -303,6 +303,19 @@ public function fieldAccess($operation, FieldDefinitionInterface $field_definiti
// Get the default access restriction that lives within this field. // Get the default access restriction that lives within this field.
$default = $items ? $items->defaultAccess($operation, $account) : AccessResult::allowed(); $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 // Get the default access restriction as specified by the access control
// handler. // handler.
$entity_default = $this->checkFieldAccess($operation, $field_definition, $account, $items); $entity_default = $this->checkFieldAccess($operation, $field_definition, $account, $items);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment