‪TYPO3CMS  ‪main
CspModuleController.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ResponseInterface;
21 use Psr\Http\Message\ServerRequestInterface;
29 
34 #[AsController]
36 {
37  public function ‪__construct(
38  protected readonly ‪Features $features,
39  protected readonly ‪UriBuilder $uriBuilder,
40  protected readonly ‪PageRenderer $pageRenderer,
41  protected readonly ‪ScopeRepository $scopeRepository,
42  protected readonly ‪ModuleTemplateFactory $moduleTemplateFactory,
43  ) {}
44 
45  public function ‪mainAction(ServerRequestInterface $request): ResponseInterface
46  {
47  $this->pageRenderer->addInlineLanguageLabelFile(
48  'EXT:backend/Resources/Private/Language/Modules/content-security-policy.xlf',
49  'module.',
50  'module.'
51  );
52  $view = $this->moduleTemplateFactory->create($request);
53  $view->assignMultiple([
54  'configurationStatus' => $this->‪getConfigurationStatus(),
55  'scopes' => array_map(strval(...), $this->scopeRepository->findAll()),
56  'controlUri' => $this->uriBuilder->buildUriFromRoutePath('/ajax/security/csp/control'),
57  ]);
58  return $view->renderResponse('Security/CspModule');
59  }
60 
61  protected function ‪getConfigurationStatus(): array
62  {
63  return [
64  'featureDisabled' => array_filter([
65  'backend' => false,
66  'frontend' => !$this->features->isFeatureEnabled('security.frontend.enforceContentSecurityPolicy'),
67  ]),
68  'customReporting' => array_filter([
69  'BE' => ‪$GLOBALS['TYPO3_CONF_VARS']['BE']['contentSecurityPolicyReportingUrl'] ?? '',
70  'FE' => ‪$GLOBALS['TYPO3_CONF_VARS']['FE']['contentSecurityPolicyReportingUrl'] ?? '',
71  ]),
72  ];
73  }
74 
76  {
77  return ‪$GLOBALS['BE_USER'];
78  }
79 }
‪TYPO3\CMS\Backend\Template\ModuleTemplateFactory
Definition: ModuleTemplateFactory.php:33
‪TYPO3\CMS\Backend\Security\ContentSecurityPolicy
Definition: CspAjaxController.php:18
‪TYPO3\CMS\Core\Page\PageRenderer
Definition: PageRenderer.php:44
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:44
‪TYPO3\CMS\Core\Configuration\Features
Definition: Features.php:56
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\ScopeRepository
Definition: ScopeRepository.php:27
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Backend\Security\ContentSecurityPolicy\CspModuleController\__construct
‪__construct(protected readonly Features $features, protected readonly UriBuilder $uriBuilder, protected readonly PageRenderer $pageRenderer, protected readonly ScopeRepository $scopeRepository, protected readonly ModuleTemplateFactory $moduleTemplateFactory,)
Definition: CspModuleController.php:37
‪TYPO3\CMS\Backend\Security\ContentSecurityPolicy\CspModuleController\getConfigurationStatus
‪getConfigurationStatus()
Definition: CspModuleController.php:61
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Attribute\AsController
Definition: AsController.php:25
‪TYPO3\CMS\Backend\Security\ContentSecurityPolicy\CspModuleController\mainAction
‪mainAction(ServerRequestInterface $request)
Definition: CspModuleController.php:45
‪TYPO3\CMS\Backend\Security\ContentSecurityPolicy\CspModuleController\getBackendUser
‪getBackendUser()
Definition: CspModuleController.php:75
‪TYPO3\CMS\Backend\Security\ContentSecurityPolicy\CspModuleController
Definition: CspModuleController.php:36