【问题标题】:Secure storage of credentials from auth.json when using CI使用 CI 时从 auth.json 安全存储凭据
【发布时间】:2022-11-07 10:05:31
【问题描述】:
我们使用 CircleCI 在部署之前构建我们的 PHP 应用程序。 composer 的要求之一是存储在 Bitbucket 上的私有仓库中的模块。目前我们将凭证存储在 composer.json 中,这远非理想。问题是我找不到更好的解决方案来在构建期间管理这些凭据以进行 repo 访问。我假设我可以使用环境变量或类似的。
谢谢。
【问题讨论】:
标签:
drupal
composer-php
bitbucket
circleci
【解决方案1】:
环境变量COMPOSER_AUTH 可用于将任意数量的身份验证方法传递给composer,并允许在repo 之外管理任何密钥或机密。
在我的示例中,要使用 bitbucket 进行身份验证,var 看起来像这样;
export COMPOSER_AUTH='{"bitbucket-oauth": {"bitbucket.org": {"consumer-key": "xxxxxx","consumer-secret": "xxxxxx"}}}'
CircleCi(我假设大多数 CI 应用程序)有一个环境变量设置页面。在那里添加变量和值,然后您可以从 composer.json 中删除整个“bitbucket-oauth”块。