2

由于安全原因,我们不能保持纯文本的 SQL 身份验证,有没有办法隐藏或加密密码?

插件站点的不良文档和不良支持,我被卡住了,请帮助,请不要提及保留环境变量。

Github 链接: https ://github.com/fluent/fluent-plugin-sql

<source>
  @type sql
  @id output_sql
  host "sqlserverhost.aws_region.rds.amazonaws.com"
  database db_name
  adapter sqlserver
  username user
  password pwd   ==============================>>>> This is in plain text
  tag_prefix myrdb # optional, but recommended
  select_interval 60s # optional
  select_limit 500 # optional
  state_file /var/run/fluentd/sql_state
  <table>
    table tbl_name
    update_column insert_timestamp
  </table>
</source>

<match **>
  @type stdout
</match>
4

1 回答 1

0

我建议将 SQL 插件密码添加到您config/credentials.yml.enc应该能够作为环境变量访问的密码中。

未加密config/credentials.yml.enc

fluentd:
    password: yourpassword

然后当你需要访问密码时

Rails.application.credentials.fluentd[:password] 

在本指南中查看有关机密加密及其工作流程的更多信息:https ://blog.corsego.com/ruby-on-rails-6-credentials-full

编辑:抱歉,我没有仔细阅读您的问题,也没有看到规定,“我被卡住了,请帮忙,请不要提及保留环境变量。”

我会提倡使用环境变量,但也许您可以提供关于为什么该解决方案不适合您的用例的更多见解。

在另一个 Stack Overflow 问题上有一个引人入胜的对话

将密码作为环境变量(而不是纯文本)存储在配置文件中是否安全?

于 2022-01-20T02:10:41.463 回答