checkLockedBackend(); if (!empty($redirectToUri)) { return new RedirectResponse($redirectToUri, 302); } } catch (BackendLockedException $e) { // Looks like an AJAX request that can handle JSON, (usually from the timeout functionality) // So, let's form a request that fits if (strpos($request->getHeaderLine('Accept'), 'application/json') !== false) { $session = [ 'timed_out' => false, 'will_time_out' => false, 'locked' => true, 'message' => $e->getMessage() ]; return new JsonResponse(['login' => $session]); } throw $e; } $this->validateVisitorsIpAgainstIpMaskList( $request->getAttribute('normalizedParams')->getRemoteAddress(), trim((string)$GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList']) ); return $handler->handle($request); } /** * Check adminOnly configuration variable and redirects to an URL in file typo3conf/LOCK_BACKEND * * @return string|null * @throws BackendLockedException */ protected function checkLockedBackend() { if ($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] < 0) { throw new BackendLockedException('TYPO3 Backend locked: Backend and Install Tool are locked for maintenance. [BE][adminOnly] is set to "' . (int)$GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] . '".', 1517949794); } if (@is_file(Environment::getLegacyConfigPath() . '/LOCK_BACKEND')) { $fileContent = file_get_contents(Environment::getLegacyConfigPath() . '/LOCK_BACKEND'); if ($fileContent) { return $fileContent; } throw new BackendLockedException('TYPO3 Backend locked: Browser backend is locked for maintenance. Remove lock by removing the file "typo3conf/LOCK_BACKEND" or use CLI-scripts.', 1517949793); } } /** * Compare client IP with IPmaskList and throw an exception * * @param string $ipAddress * @param string $ipMaskList * @throws \RuntimeException */ protected function validateVisitorsIpAgainstIpMaskList(string $ipAddress, string $ipMaskList = '') { if ($ipMaskList !== '' && !GeneralUtility::cmpIP($ipAddress, $ipMaskList)) { throw new \RuntimeException('TYPO3 Backend access denied: The IP address of your client does not match the list of allowed IP addresses.', 1517949792); } } }