1---
2layout: docs
3page_title: ACL System
4description: >-
5  Consul provides an optional Access Control List (ACL) system which can be used
6  to control access to data and APIs. The ACL system is a Capability-based
7  system that relies on tokens which can have fine grained rules applied to
8  them. It is very similar to AWS IAM in many ways.
9---
10
11# ACL System
12
13-> **1.4.0 and later:** This guide only applies in Consul versions 1.4.0 and later. The documentation for the legacy ACL system is [here](/docs/acl/acl-legacy).
14
15Consul provides an optional Access Control List (ACL) system which can be used to control access to data and APIs.
16The ACL is [Capability-based](https://en.wikipedia.org/wiki/Capability-based_security), relying on tokens which
17are associated with policies to determine which fine grained rules can be applied. Consul's capability based
18ACL system is very similar to the design of [AWS IAM](https://aws.amazon.com/iam/).
19
20To learn how to setup the ACL system on an existing Consul datacenter, use the [Bootstrapping The ACL System tutorial](https://learn.hashicorp.com/tutorials/consul/access-control-setup?utm_source=consul.io&utm_medium=docs).
21
22## ACL System Overview
23
24The ACL system is designed to be easy to use and fast to enforce while providing administrative insight.
25At the highest level, there are two major components to the ACL system:
26
27- **ACL Policies** - Policies allow the grouping of a set of rules into a logical unit that can be reused and linked with
28  many tokens.
29
30- **ACL Tokens** - Requests to Consul are authorized by using bearer token. Each ACL token has a public
31  Accessor ID which is used to name a token, and a Secret ID which is used as the bearer token used to
32  make requests to Consul.
33
34For many scenarios policies and tokens are sufficient, but more advanced setups
35may benefit from additional components in the ACL system:
36
37- **ACL Roles** - Roles allow for the grouping of a set of policies and service
38  identities into a reusable higher-level entity that can be applied to many
39  tokens. (Added in Consul 1.5.0)
40
41- **ACL Service Identities** - Service identities are a policy template for
42  expressing a link to a policy suitable for use in [Consul
43  Connect](/docs/connect). At authorization time this acts like an
44  additional policy was attached, the contents of which are described further
45  below. These are directly attached to tokens and roles and are not
46  independently configured. (Added in Consul 1.5.0)
47
48- **ACL Node Identities** - Node identities are a policy template for
49  expressing a link to a policy suitable for use as an [Consul `agent` token
50  ](/docs/agent/options#acl_tokens_agent). At authorization time this acts like an
51  additional policy was attached, the contents of which are described further
52  below. These are directly attached to tokens and roles and are not
53  independently configured. (Added in Consul 1.8.1)
54
55- **ACL Auth Methods and Binding Rules** - To learn more about these topics,
56  see the [auth methods documentation page](/docs/acl/auth-methods).
57
58ACL tokens, policies, roles, auth methods, and binding rules are managed by
59Consul operators via Consul's [ACL API](/api/acl/acl),
60[ACL CLI](/commands/acl), or systems like
61[HashiCorp's Vault](https://www.vaultproject.io/docs/secrets/consul).
62
63If the ACL system becomes inoperable, you can follow the
64[reset procedure](https://learn.hashicorp.com/tutorials/consul/access-control-troubleshoot#reset-the-acl-system) at any time.
65
66### ACL Policies
67
68An ACL policy is a named set of rules and is composed of the following elements:
69
70- **ID** - The policy's auto-generated public identifier.
71- **Name** - A unique meaningful name for the policy.
72- **Description** - A human readable description of the policy. (Optional)
73- **Rules** - Set of rules granting or denying permissions. See the [Rule Specification](/docs/acl/acl-rules#rule-specification) documentation for more details.
74- **Datacenters** - A list of datacenters the policy is valid within.
75- **Namespace** - <EnterpriseAlert inline /> - The namespace this policy resides within. (Added in Consul Enterprise 1.7.0)
76
77-> **Consul Enterprise Namespacing** - Rules defined in a policy in any namespace other than `default` will be [restricted](/docs/acl/acl-rules#namespace-rules) to being able to grant a subset of the overall privileges and only affecting that single namespace.
78
79#### Builtin Policies
80
81- **Global Management** - Grants unrestricted privileges to any token that uses it. When created it will be named `global-management`
82  and will be assigned the reserved ID of `00000000-0000-0000-0000-000000000001`. This policy can be renamed but modification
83  of anything else including the rule set and datacenter scoping will be prevented by Consul.
84
85- **Namespace Management** - <EnterpriseAlert inline /> - Every namespace created will have a policy injected with the name `namespace-management`. This policy gets injected with a randomized UUID and may be managed like any other user-defined policy
86  within the Namespace. (Added in Consul Enterprise 1.7.0)
87
88### ACL Service Identities
89
90-> Added in Consul 1.5.0
91
92An ACL service identity is an [ACL policy](/docs/acl/acl-system#acl-policies) template for expressing a link to a policy
93suitable for use in [Consul Connect](/docs/connect). They are usable
94on both tokens and roles and are composed of the following elements:
95
96- **Service Name** - The name of the service.
97- **Datacenters** - A list of datacenters the effective policy is valid within. (Optional)
98
99Services participating in the service mesh will need privileges to both _be
100discovered_ and to _discover other healthy service instances_. Suitable
101policies tend to all look nearly identical so a service identity is a policy
102template to aid in avoiding boilerplate policy creation.
103
104During the authorization process, the configured service identity is automatically
105applied as a policy with the following preconfigured [ACL
106rules](/docs/acl/acl-system#acl-rules-and-scope):
107
108```hcl
109# Allow the service and its sidecar proxy to register into the catalog.
110service "<Service Name>" {
111	policy = "write"
112}
113service "<Service Name>-sidecar-proxy" {
114	policy = "write"
115}
116
117# Allow for any potential upstreams to be resolved.
118service_prefix "" {
119	policy = "read"
120}
121node_prefix "" {
122	policy = "read"
123}
124```
125
126The [API documentation for roles](/api/acl/roles#sample-payload) has some
127examples of using a service identity.
128
129-> **Consul Enterprise Namespacing** - Service Identity rules will be scoped to the single namespace that
130the corresponding ACL Token or Role resides within.
131
132### ACL Node Identities
133
134-> Added in Consul 1.8.1
135
136An ACL node identity is an [ACL policy](/docs/acl/acl-system#acl-policies) template for expressing a link to a policy
137suitable for use as an [Consul `agent` token](/docs/agent/options#acl_tokens_agent). They are usable
138on both tokens and roles and are composed of the following elements:
139
140- **Node Name** - The name of the node to grant access to.
141- **Datacenter** - The datacenter that the node resides within.
142
143During the authorization process, the configured node identity is automatically
144applied as a policy with the following preconfigured [ACL
145rules](/docs/acl/acl-system#acl-rules-and-scope):
146
147```hcl
148# Allow the agent to register its own node in the Catalog and update its network coordinates
149node "<Node Name>" {
150  policy = "write"
151}
152
153# Allows the agent to detect and diff services registered to itself. This is used during
154# anti-entropy to reconcile difference between the agents knowledge of registered
155# services and checks in comparison with what is known in the Catalog.
156service_prefix "" {
157  policy = "read"
158}
159```
160
161-> **Consul Enterprise Namespacing** - Node Identities can only be applied to tokens and roles in the `default` namespace.
162The synthetic policy rules allow for `service:read` permissions on all services in all namespaces.
163
164### ACL Roles
165
166-> Added in Consul 1.5.0
167
168An ACL role is a named set of policies and service identities and is composed
169of the following elements:
170
171- **ID** - The role's auto-generated public identifier.
172- **Name** - A unique meaningful name for the role.
173- **Description** - A human readable description of the role. (Optional)
174- **Policy Set** - The list of policies that are applicable for the role.
175- **Service Identity Set** - The list of service identities that are applicable for the role.
176- **Namespace** <EnterpriseAlert inline /> - The namespace this policy resides within. (Added in Consul Enterprise 1.7.0)
177
178-> **Consul Enterprise Namespacing** - Roles may only link to policies defined in the same namespace as the role itself.
179
180### ACL Tokens
181
182ACL tokens are used to determine if the caller is authorized to perform an action. An ACL token is composed of the following
183elements:
184
185- **Accessor ID** - The token's public identifier.
186- **Secret ID** -The bearer token used when making requests to Consul.
187- **Description** - A human readable description of the token. (Optional)
188- **Policy Set** - The list of policies that are applicable for the token.
189- **Role Set** - The list of roles that are applicable for the token. (Added in Consul 1.5.0)
190- **Service Identity Set** - The list of service identities that are applicable for the token. (Added in Consul 1.5.0)
191- **Locality** - Indicates whether the token should be local to the datacenter it was created within or created in
192  the primary datacenter and globally replicated.
193- **Expiration Time** - The time at which this token is revoked. (Optional; Added in Consul 1.5.0)
194- **Namespace** <EnterpriseAlert inline /> - The namespace this policy resides within. (Added in Consul Enterprise 1.7.0)
195
196-> **Consul Enterprise Namespacing** - Tokens may only link to policies and roles defined in the same namespace as
197the token itself.
198
199#### Builtin Tokens
200
201During cluster bootstrapping when ACLs are enabled both the special `anonymous` and the `master` token will be
202injected.
203
204- **Anonymous Token** - The anonymous token is used when a request is made to Consul without specifying a bearer token.
205  The anonymous token's description and policies may be updated but Consul will prevent this token's deletion. When created,
206  it will be assigned `00000000-0000-0000-0000-000000000002` for its Accessor ID and `anonymous` for its Secret ID.
207
208- **Master Token** - When a master token is present within the Consul configuration, it is created and will be linked
209  With the builtin Global Management policy giving it unrestricted privileges. The master token is created with the Secret ID
210  set to the value of the configuration entry.
211
212#### Authorization
213
214The token Secret ID is passed along with each RPC request to the servers. Consul's
215[HTTP endpoints](/api) can accept tokens via the `token`
216query string parameter, the `X-Consul-Token` request header, or an
217[RFC6750](https://tools.ietf.org/html/rfc6750) authorization bearer token. Consul's
218[CLI commands](/docs/commands) can accept tokens via the
219`token` argument, or the `CONSUL_HTTP_TOKEN` environment variable. The CLI
220commands can also accept token values stored in files with the `token-file`
221argument, or the `CONSUL_HTTP_TOKEN_FILE` environment variable.
222
223If no token is provided for an HTTP request then Consul will use the default ACL token
224if it has been configured. If no default ACL token was configured then the anonymous
225token will be used.
226
227#### ACL Rules and Scope
228
229The rules from all policies, roles, and service identities linked with a token are combined to form that token's
230effective rule set. Policy rules can be defined in either an allowlist or denylist
231mode depending on the configuration of [`acl_default_policy`](/docs/agent/options#acl_default_policy).
232If the default policy is to "deny" access to all resources, then policy rules can be set to
233allowlist access to specific resources. Conversely, if the default policy is “allow” then policy rules can
234be used to explicitly deny access to resources.
235
236The following table summarizes the ACL resources that are available for constructing
237rules:
238
239| Resource                                            | Scope                                                                                                                                                                                                 |
240| --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
241| [`acl`](/docs/acl/acl-rules#acl-resource-rules)     | Operations for managing the ACL system [ACL API](/api/acl/acl)                                                                                                                                        |
242| [`agent`](/docs/acl/acl-rules#agent-rules)          | Utility operations in the [Agent API](/api/agent), other than service and check registration                                                                                                          |
243| [`event`](/docs/acl/acl-rules#event-rules)          | Listing and firing events in the [Event API](/api/event)                                                                                                                                              |
244| [`key`](/docs/acl/acl-rules#key-value-rules)        | Key/value store operations in the [KV Store API](/api/kv)                                                                                                                                             |
245| [`keyring`](/docs/acl/acl-rules#keyring-rules)      | Keyring operations in the [Keyring API](/api/operator/keyring)                                                                                                                                        |
246| [`node`](/docs/acl/acl-rules#node-rules)            | Node-level catalog operations in the [Catalog API](/api/catalog), [Health API](/api/health), [Prepared Query API](/api/query), [Network Coordinate API](/api/coordinate), and [Agent API](/api/agent) |
247| [`operator`](/docs/acl/acl-rules#operator-rules)    | Cluster-level operations in the [Operator API](/api/operator), other than the [Keyring API](/api/operator/keyring)                                                                                    |
248| [`query`](/docs/acl/acl-rules#prepared-query-rules) | Prepared query operations in the [Prepared Query API](/api/query)                                                                                                                                     |
249| [`service`](/docs/acl/acl-rules#service-rules)      | Service-level catalog operations in the [Catalog API](/api/catalog), [Health API](/api/health), [Intentions API](/api/connect/intentions), [Prepared Query API](/api/query), and [Agent API](/api/agent)                                         |
250| [`session`](/docs/acl/acl-rules#session-rules)      | Session operations in the [Session API](/api/session)                                                                                                                                                 |
251
252Since Consul snapshots actually contain ACL tokens, the [Snapshot API](/api/snapshot)
253requires a token with "write" privileges for the ACL system.
254
255The following resources are not covered by ACL policies:
256
2571. The [Status API](/api/status) is used by servers when bootstrapping and exposes
258   basic IP and port information about the servers, and does not allow modification
259   of any state.
260
2612. The datacenter listing operation of the
262   [Catalog API](/api/catalog#list-datacenters) similarly exposes the names of known
263   Consul datacenters, and does not allow modification of any state.
264
2653. The [connect CA roots endpoint](/api/connect/ca#list-ca-root-certificates) exposes just the public TLS certificate which other systems can use to verify the TLS connection with Consul.
266
267Constructing rules from these policies is covered in detail on the
268[ACL Rules](/docs/acl/acl-rules) page.
269
270-> **Consul Enterprise Namespacing** - In addition to directly linked policies, roles and service identities, Consul Enterprise
271will include the ACL policies and roles defined in the [Namespaces definition](/docs/enterprise/namespaces#namespace-definition). (Added in Consul Enterprise 1.7.0)
272
273## Configuring ACLs
274
275ACLs are configured using several different configuration options. These are marked
276as to whether they are set on servers, clients, or both.
277
278| Configuration Option                                           | Servers    | Clients    | Purpose                                                                |
279| -------------------------------------------------------------- | ---------- | ---------- | ---------------------------------------------------------------------- |
280| [`acl.enabled`](/docs/agent/options#acl_enabled)               | `REQUIRED` | `REQUIRED` | Controls whether ACLs are enabled                                      |
281| [`acl.default_policy`](/docs/agent/options#acl_default_policy) | `OPTIONAL` | `N/A`      | Determines allowlist or denylist mode                                  |
282| [`acl.down_policy`](/docs/agent/options#acl_down_policy)       | `OPTIONAL` | `OPTIONAL` | Determines what to do when the remote token or policy resolution fails |
283| [`acl.role_ttl`](/docs/agent/options#acl_role_ttl)             | `OPTIONAL` | `OPTIONAL` | Determines time-to-live for cached ACL Roles                           |
284| [`acl.policy_ttl`](/docs/agent/options#acl_policy_ttl)         | `OPTIONAL` | `OPTIONAL` | Determines time-to-live for cached ACL Policies                        |
285| [`acl.token_ttl`](/docs/agent/options#acl_token_ttl)           | `OPTIONAL` | `OPTIONAL` | Determines time-to-live for cached ACL Tokens                          |
286
287A number of special tokens can also be configured which allow for bootstrapping the ACL
288system, or accessing Consul in special situations:
289
290| Special Token                                                            | Servers    | Clients    | Purpose                                                                                                                                                                                                                                                               |
291| ------------------------------------------------------------------------ | ---------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
292| [`acl.tokens.agent_master`](/docs/agent/options#acl_tokens_agent_master) | `OPTIONAL` | `OPTIONAL` | Special token that can be used to access [Agent API](/api/agent) when remote bearer token resolution fails; used for setting up the cluster such as doing initial join operations, see the [ACL Agent Master Token](#acl-agent-master-token) section for more details |
293| [`acl.tokens.agent`](/docs/agent/options#acl_tokens_agent)               | `OPTIONAL` | `OPTIONAL` | Special token that is used for an agent's internal operations, see the [ACL Agent Token](#acl-agent-token) section for more details                                                                                                                                   |
294| [`acl.tokens.master`](/docs/agent/options#acl_tokens_master)             | `OPTIONAL` | `N/A`      | Special token used to bootstrap the ACL system, check the [Bootstrapping ACLs](https://learn.hashicorp.com/tutorials/consul/access-control-setup-production) tutorial for more details                                                                                |
295| [`acl.tokens.default`](/docs/agent/options#acl_tokens_default)           | `OPTIONAL` | `OPTIONAL` | Default token to use for client requests where no token is supplied; this is often configured with read-only access to services to enable DNS service discovery on agents                                                                                             |
296
297All of these tokens except the `master` token can all be introduced or updated via the [/v1/agent/token API](/api/agent#update-acl-tokens).
298
299#### ACL Agent Master Token
300
301Since the [`acl.tokens.agent_master`](/docs/agent/options#acl_tokens_agent_master) is designed to be used when the Consul servers are not available, its policy is managed locally on the agent and does not need to have a token defined on the Consul servers via the ACL API. Once set, it implicitly has the following policy associated with it
302
303```hcl
304agent "<node name of agent>" {
305  policy = "write"
306}
307node_prefix "" {
308  policy = "read"
309}
310```
311
312#### ACL Agent Token
313
314The [`acl.tokens.agent`](/docs/agent/options#acl_tokens_agent) is a special token that is used for an agent's internal operations. It isn't used directly for any user-initiated operations like the [`acl.tokens.default`](/docs/agent/options#acl_tokens_default), though if the `acl.tokens.agent` isn't configured the `acl.tokens.default` will be used. The ACL agent token is used for the following operations by the agent:
315
3161. Updating the agent's node entry using the [Catalog API](/api/catalog), including updating its node metadata, tagged addresses, and network coordinates
3172. Performing [anti-entropy](/docs/internals/anti-entropy) syncing, in particular reading the node metadata and services registered with the catalog
3183. Reading and writing the special `_rexec` section of the KV store when executing [`consul exec`](/commands/exec) commands
319
320Here's an example policy sufficient to accomplish the above for a node called `mynode`:
321
322```hcl
323node "mynode" {
324  policy = "write"
325}
326service_prefix "" {
327  policy = "read"
328}
329key_prefix "_rexec" {
330  policy = "write"
331}
332```
333
334The `service_prefix` policy needs read access for any services that can be registered on the agent. If [remote exec is disabled](/docs/agent/options#disable_remote_exec), the default, then the `key_prefix` policy can be omitted.
335
336## Next Steps
337
338Setup ACLs with the [Bootstrapping the ACL System tutorial](https://learn.hashicorp.com/tutorials/consul/access-control-setup-production?utm_source=consul.io&utm_medium=docs) or continue reading about
339[ACL rules](/docs/acl/acl-rules).
340