ACL HTTP API
The /acl
endpoints are used to manage ACL tokens and policies in Consul, bootstrap the ACL system and check ACL replication status. There are additional pages for managing tokens and policies with the /acl
endpoints.
For more information on how to setup ACLs, refer to the following resources:
Bootstrap ACLs
This endpoint does a special one-time bootstrap of the ACL system, making the first
management token if the acl.tokens.initial_management
configuration entry is not specified in the Consul server configuration and if the
cluster has not been bootstrapped previously. An operator created token can be provided in the body of the request to
bootstrap the cluster if required. The provided token should be presented in a UUID format.
This provides a mechanism to bootstrap ACLs without having any secrets present in Consul's configuration files.
Method | Path | Produces |
---|---|---|
PUT | /acl/bootstrap | application/json |
The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
NO | none | none | none |
The corresponding CLI command is consul acl bootstrap
.
Sample Request
Sample Response
Sample Request with provided token
You can detect if something has interfered with the ACL bootstrapping process by checking the response code. A 200 response means that the bootstrap was a success, and a 403 means that the cluster has already been bootstrapped, at which point you should consider the cluster in a potentially compromised state.
The returned token will have unrestricted privileges to manage all details of the system. It can then be used to further configure the ACL system. Please check the ACL tutorial for more details.
Check ACL Replication
This endpoint returns the status of the ACL replication processes in the datacenter. This is intended to be used by operators or by automation checking to discover the health of ACL replication.
Please check the ACL Replication tutorial for more details.
Method | Path | Produces |
---|---|---|
GET | /acl/replication | application/json |
The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
NO | consistent | none | none |
Query Parameters
dc
(string: "")
- Specifies the datacenter to query. This will default to the datacenter of the agent being queried.
Sample Request
Sample Response
Enabled
- Reports whether ACL replication is enabled for the datacenter.Running
- Reports whether the ACL replication process is running. The process may take approximately 60 seconds to begin running after a leader election occurs.SourceDatacenter
- The authoritative ACL datacenter that ACLs are being replicated from and will match theprimary_datacenter
configuration.ReplicationType
- The type of replication that is currently in use.ReplicatedIndex
- The last index that was successfully replicated. Which data the replicated index refers to depends on the replication type. When in eithertokens
orpolicies
mode, this index can be compared with the value of theX-Consul-Index
header returned by the/v1/acl/policies
endpoint to determine if the policy replication process has gotten all available ACL policies. Note that ACL replication is rate limited so the indexes may lag behind the primary datacenter.ReplicatedTokenIndex
- The last token index that was successfully replicated. This index can be compared with the value of theX-Consul-Index
header returned by the/v1/acl/tokens
endpoint to determine if the replication process has gotten all available ACL tokens. Note that ACL replication is rate limited so the indexes may lag behind the primary datacenter.LastSuccess
- The UTC time of the last successful sync operation. Since ACL replication is done with a blocking query, this may not update for up to 5 minutes if there have been no ACL changes to replicate. A zero value of "0001-01-01T00:00:00Z" will be present if no sync has been successful.LastError
- The UTC time of the last error encountered during a sync operation. If this time is later thanLastSuccess
, you can assume the replication process is not in a good state. A zero value of "0001-01-01T00:00:00Z" will be present if no sync has resulted in an error.LastErrorMessage
- The last error message produced at the time ofLastError
. An empty string indicates that no sync has resulted in an error.
Login to Auth Method
This endpoint was added in Consul 1.5.0 and is used to exchange an auth method bearer token for a newly-created Consul ACL token.
Method | Path | Produces |
---|---|---|
POST | /acl/login | application/json |
The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
NO | none | none | none |
Note - To use the login process to create tokens in any connected secondary datacenter, ACL replication must be enabled. Login requires the ability to create local tokens which is restricted to the primary datacenter and any secondary datacenters with ACL token replication enabled.
The corresponding CLI command is consul login
.
Query Parameters
ns
(string: "")
Enterprise - Specifies the namespace of the auth method you use to login. You can also specify the namespace through other methods.
JSON Request Body Schema
AuthMethod
(string: <required>)
- The name of the auth method to use for login.BearerToken
(string: <required>)
- The bearer token to present to the auth method during login for authentication purposes. For the Kubernetes auth method this is a Service Account Token (JWT).Meta
(map<string|string>: nil)
- Specifies arbitrary KV metadata linked to the token. Can be useful to track origins.Namespace
(string: "")
Enterprise - Specifies the namespace of the auth method you use to login. This field takes precedence over thens
query parameter, one of several other methods to specify the namespace.
Sample Payload
Sample Request
Sample Response
Logout from Auth Method
This endpoint was added in Consul 1.5.0 and is used to destroy a token created
via the login endpoint. The token deleted is specified
with the X-Consul-Token
header or the token
query parameter.
Method | Path | Produces |
---|---|---|
POST | /acl/logout | application/json |
The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
NO | none | none | none |
Note - This endpoint requires no specific privileges as it is just deleting a token for which you already must possess its secret.
The corresponding CLI command is consul logout
.
Sample Request
OIDC Authorization URL Request
This is an enterprise only endpoint.
This endpoint was added in Consul 1.8.0 and is used to obtain an authorization URL from Consul to start an OIDC login flow.
Method | Path | Produces |
---|---|---|
POST | /acl/oidc/auth-url | application/json |
The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
NO | none | none | none |
Note - To use the login process to create tokens in any connected secondary datacenter, ACL replication must be enabled. Login requires the ability to create local tokens which is restricted to the primary datacenter and any secondary datacenters with ACL token replication enabled.
Query Parameters
ns
(string: "")
Enterprise - Specifies the namespace of the auth method you use to login. You can also specify the namespace through other methods.
JSON Request Body Schema
AuthMethod
(string: <required>)
- The name of the auth method to use for login. This must be of typeoidc
.RedirectURI
(string: <required>)
- See Redirect URIs for more information.ClientNonce
(string: "")
- Optional client-provided nonce that must match during callback, if present.Meta
(map<string|string>: nil)
- Specifies arbitrary KV metadata linked to the token. Can be useful to track origins.Namespace
(string: "")
Enterprise - Specifies the namespace of the auth method you use to login. This field takes precedence over thens
query parameter, one of several other methods to specify the namespace.This must match the namespace provided on the OIDC Callback.
Sample Payload
Sample Request
Sample Response
OIDC Callback
This is an enterprise only endpoint.
This endpoint was added in Consul 1.8.0 and is used to exchange an OIDC authorization code for an OIDC ID Token. The ID token will in turn be exchanged for a newly-created Consul ACL token.
Method | Path | Produces |
---|---|---|
POST | /acl/oidc/callback | application/json |
The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
NO | none | none | none |
Note - To use the login process to create tokens in any connected secondary datacenter, ACL replication must be enabled. Login requires the ability to create local tokens which is restricted to the primary datacenter and any secondary datacenters with ACL token replication enabled.
Query Parameters
ns
(string: "")
Enterprise - Specifies the namespace of the auth method you use to login. You can also specify the namespace through other methods.
JSON Request Body Schema
AuthMethod
(string: <required>)
- The name of the auth method to use for login. This must be of typeoidc
.State
(string: <required>)
- Opaque state ID that is part of the Authorization URL and will be included in the redirect following successful authentication on the provider.Code
(string: <required>)
- Provider-generated authorization code that Consul will exchange for an ID token.ClientNonce
(string: "")
- Optional client-provided nonce that must match the one provided in the auth url request, if present.Meta
(map<string|string>: nil)
- Specifies arbitrary KV metadata linked to the token. Can be useful to track origins.Namespace
(string: "")
Enterprise - Specifies the namespace of the auth method you use to login. This field takes precedence over thens
query parameter, one of several other methods to specify the namespace.
Sample Payload
Sample Request
Sample Response
Methods to specify namespace Enterprise
Some ACL endpoints support several methods for specifying the namespace of the resource with the following order of precedence:
- Namespace` field of the JSON request body - only applies to endpoints that accept an JSON request body
- ns` query parameter
- X-Consul-Namespace` request header
- Namespace is inherited from the namespace of the request's ACL token (if any)
- The
default
namespace