Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nacos 能不能对接 HashiCorp Vault,实现 数据库相关配置动态更新 #13000

Open
junlintianxiazhifulinzhongguo opened this issue Dec 30, 2024 · 5 comments
Labels
kind/discussion Category issues related to discussion

Comments

@junlintianxiazhifulinzhongguo

我想实现这样一个功能, 通过 HashiCorp Vault 的数据库引擎,实现动态更新 数据库 账号密码, 我想通过 nacos 来感知 HashiCorp Vault中的数据库账号动态变更,从而更新 nacos 中 项目springboot 的配置文件,实现动态更新数据库账号信息,来满足相关安全需求,有没有相关的实现方法

@KomachiSion KomachiSion added the kind/discussion Category issues related to discussion label Dec 30, 2024
@KomachiSion
Copy link
Collaborator

这个链路看起来好长,意思是通过nacos修改HashiCorp Vault的配置?

@junlintianxiazhifulinzhongguo
Copy link
Author

因为有等保要求,需要定期更改数据库密码,所以就想实现下面这个功能

+----------------+ 1. 动态生成密码 +----------------+
| HashiCorp | --------------------> | MySQL |
| Vault | <---------------------| (更新账号密码) |
+----------------+ 2. 密码轮换触发 +----------------+
|
| 3. 注入密码到Nacos
v
+----------------+ 4. 下发新配置 +-----------------+
| Nacos | --------------------> | Spring Cloud |
| (配置中心) | <---------------------| 应用(动态刷新) |
+----------------+ 5. 监听配置变更 +-----------------+

@junlintianxiazhifulinzhongguo
Copy link
Author

Image

@junlintianxiazhifulinzhongguo
Copy link
Author

@KomachiSion 这样就不能每次都手动去修改 nacos 里面的 配置文件中的mysql 数据库账号密码了,就是不知道怎么实现

@shiyiyue1102
Copy link
Collaborator

实现这个需求有几个点:

  1. mysql的用户密码的更新触发在vault侧,包括密码的生成以及定时轮转,调用,需要确认下vault有没有开放接口,当账密变化时调用nacos的publishConfig接口实现配置的更新
  2. nacos作为mysql的用户名密码的配置存储和下发链路,需要考虑敏感信息的加解密,可以通过nacos的加解密插件实现
  3. 应用程序侧数据库连接池的动态更新,这里需要考虑动态更新的问题以及刷新过程是否有损的问题,通过自定义DatasourceBean并且加上@RefreshScope注解可以在属性更新时将数据源Bean刷新,但是中间是先destroy &createBean的方式,切换期间是有损的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/discussion Category issues related to discussion
Projects
None yet
Development

No branches or pull requests

3 participants