public function processFirewallFilters(array &$configuration)
{
if (!isset($configuration['TYPO3']['Flow']['security']['firewall']['filters'])) {
return;
}
$filtersConfiguration =& $configuration['TYPO3']['Flow']['security']['firewall']['filters'];
foreach ($filtersConfiguration as $filterIndex => &$filterOptions) {
// already converted?
if (isset($filterOptions['pattern']) || !isset($filterOptions['patternType'])) {
continue;
}
$patternValue = isset($filterOptions['patternValue']) ? $filterOptions['patternValue'] : '';
switch (strtolower($filterOptions['patternType'])) {
case 'controllerobjectname':
$patternClassName = ControllerObjectName::class;
$filterOptions['pattern'] = 'ControllerObjectName';
$filterOptions['patternOptions'] = ['controllerObjectNamePattern' => $patternValue];
break;
case 'csrfprotection':
$patternClassName = CsrfProtection::class;
$filterOptions['pattern'] = 'CsrfProtection';
break;
case 'host':
$patternClassName = Host::class;
$filterOptions['pattern'] = 'Host';
$filterOptions['patternOptions'] = ['hostPattern' => $patternValue];
break;
case 'ip':
$patternClassName = Ip::class;
$filterOptions['pattern'] = 'Ip';
$filterOptions['patternOptions'] = ['cidrPattern' => $patternValue];
break;
case 'uri':
$patternClassName = Uri::class;
$filterOptions['pattern'] = 'Uri';
$filterOptions['patternOptions'] = ['uriPattern' => $patternValue];
break;
default:
$this->showWarning(sprintf('Could not automatically convert the syntax of the custom firewall filter "%s". Please adjust it manually as described in the documentation.', $filterOptions['patternType']));
$patternClassName = $filterOptions['patternType'];
}
if (isset($filterOptions['pattern'])) {
unset($filterOptions['patternType'], $filterOptions['patternValue']);
}
if (is_numeric($filterIndex)) {
$patternIdentifier = $this->targetPackageData['packageKey'] . ':' . $this->getShortClassName($patternClassName);
$uniquePatternIdentifier = $patternIdentifier;
$loopCounter = 1;
while (isset($filtersConfiguration[$uniquePatternIdentifier])) {
$uniquePatternIdentifier = $patternIdentifier . '_' . ++$loopCounter;
}
unset($filtersConfiguration[$filterIndex]);
$filtersConfiguration[$uniquePatternIdentifier] = $filterOptions;
}
$this->showNote(sprintf('Adjusted configuration syntax of the "%s" firewall filter.', $patternClassName));
}
}