#66064Use configurationBuilder for generating propertyMappingConfiguration in controller arguments
Description
Currently the propertyMappingConfiguration in “TYPO3\CMS\Extbase\Mvc\Controller\Argument” gets injected and thus will be empty.
I guess it would make sense to use “TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationBuilder” to generate a new propertyMappingConfiguration having sane defaults. Or is the ConfigurationBuilder just intended for property mapping internally in a domain object and not for domain models being passed as controller arguments?
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 3
-
Bernhard Kraft commented <span data-processor="relativetime" data-value="2015-03-26T18:45:16+00:00" > 03/26/15, 18:45 </span>
-
Mathias Schreiber changed target version <span data-processor="relativetime" data-value="2015-11-12T17:07:17+00:00" > 11/12/15, 17:07 </span>
-
Georg Ringer commented and changed status
NewClosed <span data-processor="relativetime" data-value="2026-10-06T18:02:11+00:00" > 10/06/26, 18:02 </span>Thanks for the report. This is intended behaviour, so I am closing the issue.
The defaults of
PropertyMappingConfigurationBuilderare meant for code that callsPropertyMapper::convert()itself with data it trusts:allowAllProperties()PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED => truePersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED => true
Controller arguments are mapped from request data. With these defaults every request could set any property of a domain object and create or modify persisted objects (mass assignment). That is why
Argumentstarts with an emptyMvcPropertyMappingConfiguration: Extbase is secure by default and only allows what was explicitly permitted.Permissions are granted in two ways:
- Forms rendered with
<f:form>include an HMAC-signed__trustedPropertiesfield.MvcPropertyMappingConfigurationService::initializePropertyMappingConfigurationFromRequest()allows exactly the properties the form rendered, and allows modification when__identityis present, creation otherwise. - Without a form, the controller opts in explicitly, e.g. in
initializeCreateAction():
$this->arguments->getArgument('blog') ->getPropertyMappingConfiguration() ->allowProperties('title', 'description') ->setTypeConverterOption( PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true );Flow, where the Extbase property mapper comes from, follows the same principle.
At least the the configurationBuilder is used in “TYPO3\CMS\Extbase\Property\PropertyMapper” when calling ->convert() with a NULL value for property configuration.
The “TYPO3\CMS\Extbase\Mvc\Controller\Argument” class creates an propertyMappingConfiguration by injection and thus will pass a non-null value which is not enriched with the default settings. So my assumption was that Mvc\Controller\Argument should use the propertyMappingConfigurationBuilder.