如何创建防止用户破坏秘密版本的 HashiCorp Vault 策略?

How can I create a HashiCorp Vault policy that prevents users from destroying secret versions?

我有一项政策是为需要能够创建新密文和新密文版本的新用户提供的,但他们不应该有删除密文或密文版本的能力。下面的代码片段阻止用户删除秘密;但是,他们仍然能够销毁每一个秘密版本。

我怎样才能防止他们使用策略破坏机密版本?

# This section grants all access on "secrets/*". Further restrictions can be
# applied to this broad policy, as shown below.
path "secrets/*" {
  capabilities = ["create", "read", "update", "list"]
}

您可以使用 HashiCorp Vault API 文档来解决这个问题:https://www.vaultproject.io/api/secret/kv/kv-v2.html https://github.com/hashicorp/vault/blob/master/website/source/docs/concepts/policies.html.md

# This section grants all access on "secrets/*". Further restrictions can be
# applied to this broad policy, as shown below.
path "secrets/*" {
  capabilities = ["create", "read", "update", "list"]
}

# This section explicitly denies the ability to destroy secret versions.
path "secrets/destroy/*" {
  capabilities = ["deny"]
}
path "secrets/delete/*" {
  capabilities = ["deny"]
}