ruby-on-rails - 无法理解 secret_token 的 Rails 弃用警告
问题描述
从 升级rails 5.1
到后,rails 5.2.3
我收到此弃用警告:
secrets.secret_token` is deprecated in favor of `secret_key_base` and will be removed in Rails 6.0. (called from <main> at /config/initializers/stripe.rb:3
如果我查看条带初始化程序,我有:
Rails.configuration.stripe = {
publishable_key: Rails.application.secrets.stripe_publishable_key,
secret_key: Rails.application.secrets.stripe_secret_key
}
所以没有提及secret.token
. 如果我看config.secrets.yml
我有
test:
secret_key_base: some-key
stripe_secret_key: another_key
stripe_publishable_key: yet_another_key
那么为什么我会收到弃用警告?
解决方案
Rails 5.2 已将机密替换为凭据,以在存储库中存储加密的凭据或 API 密钥。您可以在以下文章中阅读有关从机密更改为凭据的更多信息。
https://medium.com/@wintermeyer/goodbye-secrets-welcome-credentials-f4709d9f4698
尽管 Rails 5.2 已经用凭证替换了秘密,但如果你愿意,你仍然可以使用秘密。然而,正如警告消息所述,机密将从 Rails 6 中删除,您必须接受使用凭证来存储 API 密钥和 secret_keys。
推荐阅读
- spring-boot - 如何对 Spring Boot 应用程序的镜像进行 docker 处理?
- azure - 如何将 VMSS 实例计数作为指标?
- database - DBMS_JAVA 无法验证或授权
- r - r:ggplot 将突出显示的注释添加到类别轴
- python - 将 PNG 转换为 Numpy 数组 -> 更改颜色值 -> 组合通道并保存图像
- excel - VLOOKUP 具有多个结果的同一项目
- javascript - 使用 docker-compose 运行 nuxt.js 项目
- c# - 关于 C# 中 appsettings.json 中的路径
- python - Python/Selenium - 如何从模态淡化内容中提取文本?
- tableau-api - 在 Tableau 中使用工作簿监控数据指示器