如何在Sinatra应用中使用ActivereCord加密?

发布于 2025-02-05 07:43:52 字数 714 浏览 2 评论 0原文

我有一个Sinatra应用程序,该应用程序通过使用activerecordsinatra-activerecord gems来运行ActiverEcord。我想使用ActiverEcord加密,但是“ nofollow noreferrer”> activerecord加密指南并指定如何将所需的加密密钥添加到Rails凭据文件中。由于这不是Rails应用程序,因此如何为ActiverEcord指定替代密钥库?

具体来说,我看到的错误是:

ActiveRecord::Encryption::Errors::Configuration:
        key_derivation_salt is not configured. Please configure it via credential active_record_encryption.key_derivation_salt or by setting config.active_record.encryption.key_derivation_salt

因此,我认为它运行正确,我只是不知道如何在没有Rails凭据文件的情况下进行配置。

I have a Sinatra app which runs ActiveRecord by using the activerecord and sinatra-activerecord gems. I would like to use ActiveRecord encryption, but the ActiveRecord Encryption guide assumes that I have a Rails app and specifies how to add the required encryption keys to the Rails credentials file. As this is not a Rails app, how do I specify an alternate keystore for ActiveRecord to use?

Specifically the error I am seeing is:

ActiveRecord::Encryption::Errors::Configuration:
        key_derivation_salt is not configured. Please configure it via credential active_record_encryption.key_derivation_salt or by setting config.active_record.encryption.key_derivation_salt

So I think that it is running correctly, I just don't know how to configure it without the Rails credentials file.

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

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

发布评论

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

评论(1

執念 2025-02-12 07:43:52

Try this:

ActiveRecord::Encryption.configure(
  primary_key:         xxx,
  deterministic_key:   yyy,
  key_derivation_salt: zzz
)

Looks undocumented, but found在源代码中。

Try this:

ActiveRecord::Encryption.configure(
  primary_key:         xxx,
  deterministic_key:   yyy,
  key_derivation_salt: zzz
)

Looks undocumented, but found in the source code.

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