Hashicorp 金库中的秘密 ID 和客户端令牌轮换
我正在使用 approle
身份验证类型,它接受 role-id
和 secret-id
以及 root token
中的header 来生成一个客户端令牌
,它可以进一步用作 header 中的auth token
来创建和检索机密。我猜这就是使用 Spring Cloud Vault 时内部发生的情况。如果我错了请纠正我。
现在,我需要每 30 天轮换一次秘密 ID,每 24 小时轮换一次客户端令牌。我该如何实现这一目标? spring cloud Vault 是否提供内置库来执行此操作?如果不是我应该在哪里进行更改?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要执行与
vault write -f auth/approle/role/my-role/secret-id
等效的操作来获取新的秘密 ID。你这样做的地方就变得有趣了...我假设你已经有一个 Vault 策略,允许你 生成一个新的secret_id。确保
role_name
参数固定为您的应用程序当前角色。您很可能也想限制元数据。我建议采用这种模式:
现在,在您的应用程序中,您必须有一个定期任务来查找最新的秘密 ID 并使用它重新向 Vault 进行身份验证。
如果可能的话,我建议您完全避免这个问题,并使用您所在平台提供的身份验证方法,Vault 支持它,例如 GCP、AWS 或 Kubernetes。
You need to do the equivalent of a
vault write -f auth/approle/role/my-role/secret-id
to get a new secret id. Where you do this is where it gets interesting...I assume you already have a Vault policy that allows you to generate a new secret_id. Make sure that the
role_name
parameter is fixed to your application current role. Chances are you will want to limit the metadata, too.I would suggest this pattern:
Now in your application, you must have a periodic task that looks up the latest secret id and reauthenticates to Vault with it.
If possible, I would suggest that you avoid the problem altogether and use the authentication method provided the platform your are on, it Vault supports it, like GCP, AWS or Kubernetes.