简体   繁体   English

如何加密流利的 SQL 插件密码?

[英]How to encrypt fluentd SQL plugin password?

Because of security reasons, we can't keep SQL authentication in plain text, is there a way to hide or encrypt passwords?由于安全原因,我们不能将 SQL 身份验证保留为纯文本,有没有办法隐藏或加密密码?

Bad documentation and bad support from the plugin site, I'm stuck, please help and please don't mention about keeping in environment variables.插件站点的不良文档和不良支持,我被卡住了,请帮助,请不要提及保留环境变量。

Github link: https://github.com/fluent/fluent-plugin-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>

I recommend adding the SQL plugin password into your config/credentials.yml.enc which should be able to be accessed as an environmental variable.我建议将 SQL 插件密码添加到您的config/credentials.yml.enc中,该密码应该可以作为环境变量访问。

unencrypted config/credentials.yml.enc未加密的config/credentials.yml.enc

fluentd:
    password: yourpassword

Then when you need to access the password然后当你需要访问密码时

Rails.application.credentials.fluentd[:password] 

See more about encryption of secrets and its workflow in this guide: https://blog.corsego.com/ruby-on-rails-6-credentials-full在本指南中查看有关机密加密及其工作流程的更多信息: https://blog.corsego.com/ruby-on-rails-6-credentials-full

EDIT: Apologies, I did not read your question thoroughly and did not see the stipulation, " I'm stuck, please help and please don't mention about keeping in environment variables."编辑:抱歉,我没有仔细阅读您的问题,也没有看到规定,“我被卡住了,请帮忙,请不要提及保留环境变量。”

I would advocate for using environment variables but perhaps you could provide additional insight on why that solution would not fit your use case.我会提倡使用环境变量,但也许您可以提供关于为什么该解决方案不适合您的用例的更多见解。

There is a compelling conversation on an another Stack Overflow question在另一个 Stack Overflow 问题上有一个引人入胜的对话

Is it secure to store passwords as environment variables (rather than as plain text) in config files? 将密码作为环境变量(而不是纯文本)存储在配置文件中是否安全?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM