Python World类似Rails加密证书功能(以安全地存储秘密)

发布于 2025-01-29 23:28:02 字数 793 浏览 2 评论 0 原文

引用来自 trails of tobsuctions ob objection

rails将秘密存储在 config/recertentials.enc.enc 中,该>已加密,因此无法直接编辑。 Rails使用 config/master.key 或其他寻找环境变量 env [“ rails_master_key”] 来加密凭据文件。由于凭据文件已加密,只要主键保持安全。

要编辑凭据文件,运行 bin/rails凭据:编辑。如果不存在此命令将创建凭据文件。此外,此命令将创建 config/master.key 如果未定义主密钥。

可以通过 rails.application.credentials

访问凭据文件中的秘密

我的想法是:

  • 将所有秘密在存储库中加密;
  • 只有本地 master.key (或仅一个Env变量);
  • 一次手动传递到生产服务器 master.key ;
  • 然后通过自动部署过程通过git传递其他秘密。

Are the Python analogs of encrypted credentials Rails feature?

Quote from Rails Guides on subject:

Rails stores secrets in config/credentials.yml.enc, which is encrypted and hence cannot be edited directly. Rails uses config/master.key or alternatively looks for the environment variable ENV["RAILS_MASTER_KEY"] to encrypt the credentials file. Because the credentials file is encrypted, it can be stored in version control, as long as the master key is kept safe.

To edit the credentials file, run bin/rails credentials:edit. This command will create the credentials file if it does not exist. Additionally, this command will create config/master.key if no master key is defined.

Secrets kept in the credentials file are accessible via Rails.application.credentials.

My idea is:

  • to have all the secrets encrypted in repository;
  • to have locally only master.key (or only one env variable);
  • to once pass manually to production server master.key;
  • then pass other secrets by git through automated deployment process.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心奴独伤 2025-02-05 23:28:02

像铁路的加密凭证一样的作品,但我还没有看到它在我从事的任何项目中使用过。

通常,我会看到使用 os.environ 的环境变量:

import os

os.environ['API_USER']

软件包也非常受欢迎,通常与 .env 文件一起使用。

我没有自己使用过,但是 dynaconf 似乎也很受欢迎。

There is https://github.com/nzaillian/django-encrypted-secrets that works like Rail's encrypted credentials, but I haven't seen it used in any projects I've worked on.

Usually I see environment variables being used and accessed using os.environ:

import os

os.environ['API_USER']

The django-environ package is also very popular and is often used together with .env files.

I haven't used it myself, but dynaconf also seems popular.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文