Consul ACLs best practices with Vault Consul Secret engine
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 43
Description
Related to https://github.com/hashicorp/consul/issues/3957
#### Feature Description
The way the Consul ACL is structured at the moment makes it hard to have recommended ACL Production best practices based on the Hashicorp [Docs](https://learn.hashicorp.com/consul/advanced/day-1-operations/acl-guide).
#### Use Case(s)
What we are trying to achieve is to automate Consul ACL Tokens generation and lifecycle using the Vault Consul Secret Engine along with Vault Agent Caching. Hashicorp recommendations are to give exact hostname match rules on `write` for `node` and `agent` to allow catalog and internal operations by the agent. `session` rules are also subject to benefit from this.
```hcl
node "exact_match_hostname" { policy = "write" }
agent "exact_match_hostname" { policy = "write" }
session "exact_match_hostname" { policy = "write" }
```
Creating 1 policy per hostname (manually or via other automation tools) goes against the idea of policies in the sense of allowing them to be shared among tokens and reduce clutter and load with thousands of policies with 1-1 relationships with tokens.
#### Suggestion
1. This could be enabled by flags in the config where the agent would allow `agent` and `node` writes to its own hostname without requiring explicit policies to do so.
Ex:
```json
{
"acl": {
"default_internal_rule": "write"
}
}
```
or
2. This could be done via templating variables or placeholders in the policy.
Ex:
```hcl
node "{{ self }}" { policy = "write" }
agent "{{ self }}" { policy = "write" }
session "{{ self }}" { policy = "write" }
```
Either way would help people to follow the Production ACL hardening in a much easier way and would give the Vault Consul Secret engine capabilities to follow Consul's ACL best practices
Contributor guide
Assessment
This issue has not been assessed yet.