在TYPO3项目上,我正在使用HTTP BasicAuth(basic access authentication)保护Production / Staging(或Production / Dev或任何其他)环境。
实例get通过typo3/surf进行部署。
如何配置typo3/surf以便通过BasicAuth受保护环境上的前端访问以前生成的OPcache清除脚本?
答案 0 :(得分:0)
\TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask
的任务选项\TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask
(例如package
,但肯定要在transfer
之前)\TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask
的任务选项\TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask
之后添加任务switch
自从“ Respect WebDirectory” patch起,脚本的路径就不能手动配置,因为它会自动使用正确的WebDirectory路径(通过之前的选项设置)。
如果您使用的是typo3 / surf旧版本,或者有任何特殊要求,可以设置选项scriptBasePath
来设置生成文件的绝对路径:
# In this example, I have to set the absolute path for the resulting php file.
# Since the deployment run in GitLab CI I get the path to the root of the project's GIT
# repository via the environment variable `CI_PROJECT_DIR`. Since the path to the webDirectory
# inside the GIT repository is `<GitRepoRootFOlder>/app/web` I add it manually and concatenate
# it as final string for the option `scriptBasePath`:
$workflow->setTaskOptions(\TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask::class, [
'scriptBasePath' => \TYPO3\Flow\Utility\Files::concatenatePaths([getenv('CI_PROJECT_DIR'), '/app/web']),
]);
目前,我们提供用户名和密码
$workflow->setTaskOptions('TYPO3\\Surf\\Task\\Php\\WebOpcacheResetExecuteTask', [
'baseUrl' => $application->getOption('baseUrl'),
'stream_context' => [
'http' => [
'header' => 'Authorization: Basic '.base64_encode("username:password"),
],
],
]);
$workflow->beforeStage('transfer', \TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask::class, $application)
->afterStage('switch', \TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask::class, $application);
请同时检查官方文档中的TYPO3 CMS deployment configuration example。
1 此答案基于typo3 / surf GIT分支dev-master,版本2.x
2 放置提到的代码片段的示例:
$deployment->onInitialize(function () use ($deployment, $application) {
/** @var SimpleWorkflow $workflow */
$workflow = $deployment->getWorkflow();
# the mentioned snippets have to be placed next to your existing configuration
});