Hashicorp 金库中的秘密 ID 和客户端令牌轮换

发布于 2025-01-13 07:28:04 字数 354 浏览 5 评论 0 原文

我正在使用 approle 身份验证类型,它接受 role-idsecret-id 以及 root token 中的header 来生成一个客户端令牌,它可以进一步用作 header 中的auth token来创建和检索机密。我猜这就是使用 Spring Cloud Vault 时内部发生的情况。如果我错了请纠正我。

现在,我需要每 30 天轮换一次秘密 ID,每 24 小时轮换一次客户端令牌。我该如何实现这一目标? spring cloud Vault 是否提供内置库来执行此操作?如果不是我应该在哪里进行更改?

I am using approle authentication type which takes in role-id and secret-id along with root token in the header to generate a client token which can further be used as an auth token in the header to create and retrieve secrets. This is what happens internally when using spring cloud vault I guess. Correct me if I'm wrong.

Now, I need to rotate my secret-id for every 30 days and the client token for every 24 hours. How do I achieve this? Does spring cloud vault provides an inbuilt library to do this? If not where should I make the changes?

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

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

发布评论

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

评论(1

意中人 2025-01-20 07:28:04

您需要执行与 vault write -f auth/approle/role/my-role/secret-id 等效的操作来获取新的秘密 ID。你这样做的地方就变得有趣了...

我假设你已经有一个 Vault 策略,允许你 生成一个新的secret_id。确保 role_name 参数固定为您的应用程序当前角色。您很可能也想限制元数据。

我建议采用这种模式:

  1. 某些东西(某种管道或预定作业)创建新的秘密 ID。如果它是包装好的并且是一次性的,那就加分了,但我们把它留到另一个问题吧。
  2. 该东西会将秘密 ID 存储在安全的地方。可能位于应用程序可以读取的 Vault KV 版本 2 存储中。
  3. 创建新的秘密 ID 后,该东西会列出秘密并保留 N 个最新的秘密 ID。说最后的 5。这使得进程异步并允许运行的应用程序继续运行。

现在,在您的应用程序中,您必须有一个定期任务来查找最新的秘密 ID 并使用它重新向 Vault 进行身份验证。

如果可能的话,我建议您完全避免这个问题,并使用您所在平台提供的身份验证方法,Vault 支持它,例如 GCPAWSKubernetes

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:

  1. Something (a pipeline or scheduled job of some kind) creates the new secret-id. Bonus points if it is wrapped and single use, but let's save that for another question.
  2. That something will store the secret-id in a secure place. Could be in the Vault KV version 2 store where the application can read.
  3. After creating the new secret-id, that something lists the secrets and keeps the N most recent secret ids. Say the last 5. This makes the process asynchronous and allows running applications to keep going.

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.

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