This question tests your ability to understand how templated policies work as well as following the principle of least privilege, meaning only providing access to the paths required. In this instance, only the policy:
path "kv/team/{{identity.entity.id}}/*" {
capabilities = ["create", "update", "read", "delete"]
}
path "kv/team/{{identity.entity.id}}" {
capabilities = ["create", "update", "read", "delete"]
}
meets all the requirements. This policy would permit all current and future users with a custom path based on their entity ID when they log into Vault using a variable replacement within the path.
Information about templated policies can be found here: https://www.vaultproject.io/docs/concepts/policies#templated-policies
***************************************************************************************
Incorrect Answers:
***************************************************************************************
path "kv/team/frank/*" {
capabilities = ["create", "update", "read", "delete"]
}
path "kv/team/steve/*" {
capabilities = ["create", "update", "read", "delete"]
}
path "kv/team/bryan/*" {
capabilities = ["create", "update", "read", "delete"]
}
This may work for the current users of frank, steve, and bryan but it would not work for future users as required in the question. Plus, the users would also need to be granted access to kv/team/<name> as well, not just the paths after their name.
***************************************************************************************
path "kv/team/*" {
capabilities = ["create", "update", "read", "delete"]
}
While this is the least administrative way to permit access, it is not secure at all since it provides WAY too much access to our users. With this policy, any user under the kv/team path would be able to read any secret stored by any other user. It does NOT follow the principle of least privilege since it provides far too many paths due to the wildcard (*).
***************************************************************************************
path "secret/data/groups/{{identity.groups.ids.fb036ebc-2f62-4124-9503-42aa7A869741.name}}/*" {
capabilities = ["list"]
}
This is a variable replacement for a group, not individual users. There was no requirement to add these users to a group in Vault. Additionally, the capabilities provided in the policy do not permit them to manage secrets. They could only list what's already stored at the path.