2018-10-31 22:11:51 +00:00
|
|
|
---
|
|
|
|
layout: api
|
2019-05-01 21:11:23 +00:00
|
|
|
page_title: ACL Tokens - HTTP API
|
2020-04-07 18:55:19 +00:00
|
|
|
description: The /acl/token endpoints manage Consul's ACL Tokens.
|
2018-10-31 22:11:51 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# ACL Token HTTP API
|
|
|
|
|
|
|
|
The `/acl/token` endpoints [create](#create-a-token), [read](#read-a-token),
|
2020-02-03 08:41:54 +00:00
|
|
|
[update](#update-a-token), [list](#list-tokens), [clone](#clone-a-token) and [delete](#delete-a-token) ACL tokens in Consul.
|
2018-10-31 22:11:51 +00:00
|
|
|
|
2020-08-17 16:20:02 +00:00
|
|
|
For more information on how to setup ACLs, please check
|
2023-01-25 16:52:43 +00:00
|
|
|
the [ACL tutorial](/consul/tutorials/security/access-control-setup-production).
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
## Create a Token
|
|
|
|
|
|
|
|
This endpoint creates a new ACL token.
|
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Method | Path | Produces |
|
|
|
|
| ------ | ------------ | ------------------ |
|
|
|
|
| `PUT` | `/acl/token` | `application/json` |
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2023-01-25 16:52:43 +00:00
|
|
|
[blocking queries](/consul/api-docs/features/blocking),
|
|
|
|
[consistency modes](/consul/api-docs/features/consistency),
|
|
|
|
[agent caching](/consul/api-docs/features/caching), and
|
|
|
|
[required ACLs](/consul/api-docs/api-structure#authentication).
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
|
|
|
|
| ---------------- | ----------------- | ------------- | ------------ |
|
|
|
|
| `NO` | `none` | `none` | `acl:write` |
|
|
|
|
|
2023-01-25 16:52:43 +00:00
|
|
|
The corresponding CLI command is [`consul acl token create`](/consul/commands/acl/token/create).
|
2022-01-10 19:21:32 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Query Parameters
|
|
|
|
|
|
|
|
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the token you create.
|
|
|
|
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
|
|
|
|
|
|
|
|
### JSON Request Body Schema
|
2018-10-31 22:11:51 +00:00
|
|
|
|
2019-04-30 15:45:36 +00:00
|
|
|
- `AccessorID` `(string: "")` - Specifies a UUID to use as the token's Accessor ID.
|
2020-04-06 20:27:35 +00:00
|
|
|
If not specified a UUID will be generated for this field. Added in v1.5.0.
|
2019-04-30 15:45:36 +00:00
|
|
|
|
|
|
|
- `SecretID` `(string: "")` - Specifies a UUID to use as the token's Secret ID.
|
2020-04-06 20:27:35 +00:00
|
|
|
If not specified a UUID will be generated for this field. Added in v1.5.0.
|
|
|
|
**Note**: The SecretID is used to authorize operations against Consul and should
|
|
|
|
be generated from an appropriate cryptographic source.
|
2019-04-30 15:45:36 +00:00
|
|
|
|
2018-10-31 22:11:51 +00:00
|
|
|
- `Description` `(string: "")` - Free form human readable description of the token.
|
|
|
|
|
2019-05-01 21:11:23 +00:00
|
|
|
- `Policies` `(array<PolicyLink>)` - The list of policies that should be
|
|
|
|
applied to the token. A PolicyLink is an object with an "ID" and/or "Name"
|
|
|
|
field to specify a policy. With the PolicyLink, tokens can be linked to
|
|
|
|
policies either by the policy name or by the policy ID. When policies are
|
|
|
|
linked by name they will be internally resolved to the policy ID. With
|
|
|
|
linking tokens internally by IDs, Consul enables policy renaming without
|
|
|
|
breaking tokens.
|
|
|
|
|
|
|
|
- `Roles` `(array<RoleLink>)` - The list of roles that should be applied to the
|
|
|
|
token. A RoleLink is an object with an "ID" and/or "Name" field to specify a
|
|
|
|
role. With the RoleLink, tokens can be linked to roles either by the role
|
|
|
|
name or by the role ID. When roles are linked by name they will be internally
|
|
|
|
resolved to the role ID. With linking tokens internally by IDs, Consul
|
|
|
|
enables role renaming without breaking tokens. Added in Consul 1.5.0.
|
|
|
|
|
|
|
|
- `ServiceIdentities` `(array<ServiceIdentity>)` - The list of [service
|
2023-01-25 16:52:43 +00:00
|
|
|
identities](/consul/docs/security/acl#service-identities) that should be
|
2020-04-06 20:27:35 +00:00
|
|
|
applied to the token. Added in Consul 1.5.0.
|
2019-05-01 21:11:23 +00:00
|
|
|
|
|
|
|
- `ServiceName` `(string: <required>)` - The name of the service. The name
|
|
|
|
must be no longer than 256 characters, must start and end with a lowercase
|
|
|
|
alphanumeric character, and can only contain lowercase alphanumeric
|
|
|
|
characters as well as `-` and `_`.
|
|
|
|
|
|
|
|
- `Datacenters` `(array<string>)` - Specifies the datacenters the effective
|
|
|
|
policy is valid within. When no datacenters are provided the effective
|
|
|
|
policy is valid in all datacenters including those which do not yet exist
|
|
|
|
but may in the future.
|
|
|
|
|
2020-06-16 16:54:27 +00:00
|
|
|
- `NodeIdentities` `(array<NodeIdentity>)` - The list of [node
|
2023-01-25 16:52:43 +00:00
|
|
|
identities](/consul/docs/security/acl#node-identities) that should be
|
2020-06-16 16:54:27 +00:00
|
|
|
applied to the token. Added in Consul 1.8.1.
|
|
|
|
|
|
|
|
- `NodeName` `(string: <required>)` - The name of the node. The name
|
|
|
|
must be no longer than 256 characters, must start and end with a lowercase
|
|
|
|
alphanumeric character, and can only contain lowercase alphanumeric
|
|
|
|
characters as well as `-` and `_`.
|
|
|
|
|
|
|
|
- `Datacenter` `(string: <required>)` - Specifies the nodes datacenter. This
|
|
|
|
will result in effective policy only being valid in that datacenter.
|
|
|
|
|
2019-05-01 21:11:23 +00:00
|
|
|
- `Local` `(bool: false)` - If true, indicates that the token should not be
|
|
|
|
replicated globally and instead be local to the current datacenter.
|
|
|
|
|
|
|
|
- `ExpirationTime` `(time: "")`- If set this represents the point after which a
|
|
|
|
token should be considered revoked and is eligible for destruction. The
|
|
|
|
default unset value represents NO expiration. This value must be between 1
|
|
|
|
minute and 24 hours in the future. Added in Consul 1.5.0.
|
|
|
|
|
|
|
|
- `ExpirationTTL` `(duration: 0s)` - This is a convenience field and if set
|
2020-04-06 20:27:35 +00:00
|
|
|
will initialize the `ExpirationTime` field to a value of `CreateTime + ExpirationTTL`. This field is not persisted beyond its initial use. Can be
|
2019-05-01 21:11:23 +00:00
|
|
|
specified in the form of `"60s"` or `"5m"` (i.e., 60 seconds or 5 minutes,
|
|
|
|
respectively). This value must be no smaller than 1 minute and no longer than
|
|
|
|
24 hours. Added in Consul 1.5.0.
|
2020-02-03 08:41:54 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `Namespace` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the token you create.
|
|
|
|
This field takes precedence over the `ns` query parameter,
|
|
|
|
one of several [other methods to specify the namespace](#methods-to-specify-namespace).
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
### Sample Payload
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2020-04-06 20:27:35 +00:00
|
|
|
"Description": "Agent token for 'node1'",
|
|
|
|
"Policies": [
|
|
|
|
{
|
|
|
|
"ID": "165d4317-e379-f732-ce70-86278c4558f7"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "node-read"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Local": false
|
2018-10-31 22:11:51 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2022-01-12 23:05:01 +00:00
|
|
|
$ curl --request PUT \
|
2018-10-31 22:11:51 +00:00
|
|
|
--data @payload.json \
|
|
|
|
http://127.0.0.1:8500/v1/acl/token
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2020-04-06 20:27:35 +00:00
|
|
|
"AccessorID": "6a1253d2-1785-24fd-91c2-f8e78c745511",
|
|
|
|
"SecretID": "45a3bd52-07c7-47a4-52fd-0745e0cfe967",
|
|
|
|
"Description": "Agent token for 'node1'",
|
|
|
|
"Policies": [
|
|
|
|
{
|
|
|
|
"ID": "165d4317-e379-f732-ce70-86278c4558f7",
|
|
|
|
"Name": "node1-write"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"ID": "e359bd81-baca-903e-7e64-1ccd9fdc78f5",
|
|
|
|
"Name": "node-read"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Local": false,
|
|
|
|
"CreateTime": "2018-10-24T12:25:06.921933-04:00",
|
|
|
|
"Hash": "UuiRkOQPRCvoRZHRtUxxbrmwZ5crYrOdZ0Z1FTFbTbA=",
|
|
|
|
"CreateIndex": 59,
|
|
|
|
"ModifyIndex": 59
|
2018-10-31 22:11:51 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Read a Token
|
|
|
|
|
|
|
|
This endpoint reads an ACL token with the given Accessor ID.
|
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Method | Path | Produces |
|
|
|
|
| ------ | ------------------------ | ------------------ |
|
|
|
|
| `GET` | `/acl/token/:AccessorID` | `application/json` |
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2023-01-25 16:52:43 +00:00
|
|
|
[blocking queries](/consul/api-docs/features/blocking),
|
|
|
|
[consistency modes](/consul/api-docs/features/consistency),
|
|
|
|
[agent caching](/consul/api-docs/features/caching), and
|
|
|
|
[required ACLs](/consul/api-docs/api-structure#authentication).
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
|
|
|
|
| ---------------- | ----------------- | ------------- | ------------ |
|
|
|
|
| `YES` | `all` | `none` | `acl:read` |
|
|
|
|
|
2023-01-25 16:52:43 +00:00
|
|
|
The corresponding CLI command is [`consul acl token read`](/consul/commands/acl/token/read).
|
2022-01-10 19:21:32 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Path Parameters
|
|
|
|
|
|
|
|
- `AccessorID` `(string: <required>)` - Specifies the accessor ID of the token you lookup.
|
2018-10-31 22:11:51 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Query Parameters
|
2020-02-03 08:41:54 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the token you lookup.
|
|
|
|
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
|
2018-10-31 22:11:51 +00:00
|
|
|
|
2022-03-31 22:03:41 +00:00
|
|
|
- `expanded` `(bool: false)` - If this field is set, the contents of all policies and
|
|
|
|
roles affecting the token will also be returned.
|
|
|
|
|
2018-10-31 22:11:51 +00:00
|
|
|
### Sample Request
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2022-01-12 23:05:01 +00:00
|
|
|
$ curl --request GET http://127.0.0.1:8500/v1/acl/token/6a1253d2-1785-24fd-91c2-f8e78c745511
|
2018-10-31 22:11:51 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
-> **Note** If the token used for accessing the API has `acl:write` permissions,
|
|
|
|
then the `SecretID` will contain the tokens real value. Only when accessed with
|
|
|
|
a token with only `acl:read` permissions will the `SecretID` be redacted. This
|
|
|
|
is to prevent privilege escalation whereby having `acl:read` privileges allows
|
|
|
|
for reading other secrets which given even more permissions.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2020-04-06 20:27:35 +00:00
|
|
|
"AccessorID": "6a1253d2-1785-24fd-91c2-f8e78c745511",
|
|
|
|
"SecretID": "<hidden>",
|
|
|
|
"Description": "Agent token for 'node1'",
|
|
|
|
"Policies": [
|
|
|
|
{
|
|
|
|
"ID": "165d4317-e379-f732-ce70-86278c4558f7",
|
|
|
|
"Name": "node1-write"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"ID": "e359bd81-baca-903e-7e64-1ccd9fdc78f5",
|
|
|
|
"Name": "node-read"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Local": false,
|
|
|
|
"CreateTime": "2018-10-24T12:25:06.921933-04:00",
|
|
|
|
"Hash": "UuiRkOQPRCvoRZHRtUxxbrmwZ5crYrOdZ0Z1FTFbTbA=",
|
|
|
|
"CreateIndex": 59,
|
|
|
|
"ModifyIndex": 59
|
2018-10-31 22:11:51 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2022-03-31 22:03:41 +00:00
|
|
|
Sample response when setting the `expanded` parameter:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"AccessorID": "fbd2447f-7479-4329-ad13-b021d74f86ba",
|
|
|
|
"SecretID": "869c6e91-4de9-4dab-b56e-87548435f9c6",
|
|
|
|
"Description": "test token",
|
|
|
|
"Policies": [
|
|
|
|
{
|
|
|
|
"ID": "beb04680-815b-4d7c-9e33-3d707c24672c",
|
|
|
|
"Name": "foo"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"ID": "18788457-584c-4812-80d3-23d403148a90",
|
|
|
|
"Name": "bar"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Local": false,
|
|
|
|
"CreateTime": "2020-05-22T18:52:31Z",
|
|
|
|
"Hash": "YWJjZGVmZ2g=",
|
|
|
|
"ExpandedPolicies": [
|
|
|
|
{
|
|
|
|
"ID": "beb04680-815b-4d7c-9e33-3d707c24672c",
|
|
|
|
"Name": "foo",
|
|
|
|
"Description": "user policy on token",
|
|
|
|
"Rules": "service_prefix \"\" {\n policy = \"read\"\n}",
|
|
|
|
"Datacenters": null,
|
|
|
|
"Hash": null,
|
|
|
|
"CreateIndex": 0,
|
|
|
|
"ModifyIndex": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"ID": "18788457-584c-4812-80d3-23d403148a90",
|
|
|
|
"Name": "bar",
|
|
|
|
"Description": "other user policy on token",
|
|
|
|
"Rules": "operator = \"read\"",
|
|
|
|
"Datacenters": null,
|
|
|
|
"Hash": null,
|
|
|
|
"CreateIndex": 0,
|
|
|
|
"ModifyIndex": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"ID": "6204f4cd-4709-441c-ac1b-cb029e940263",
|
|
|
|
"Name": "admin policy",
|
|
|
|
"Description": "policy for admin role",
|
|
|
|
"Rules": "operator = \"write\"",
|
|
|
|
"Datacenters": null,
|
|
|
|
"Hash": null,
|
|
|
|
"CreateIndex": 0,
|
|
|
|
"ModifyIndex": 0
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"ExpandedRoles": [
|
|
|
|
{
|
|
|
|
"ID": "3b0a78fe-b9c3-40de-b8ea-7d4d6674b366",
|
|
|
|
"Name": "admin",
|
|
|
|
"Description": "admin role",
|
|
|
|
"Policies": [
|
|
|
|
{
|
|
|
|
"ID": "6204f4cd-4709-441c-ac1b-cb029e940263",
|
|
|
|
"Name": "admin policy"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"ServiceIdentities": [
|
|
|
|
{
|
|
|
|
"ServiceName": "web",
|
|
|
|
"Datacenters": [
|
|
|
|
"southwest"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Hash": null,
|
|
|
|
"CreateIndex": 0,
|
|
|
|
"ModifyIndex": 0
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"NamespaceDefaultPolicies": null,
|
|
|
|
"NamespaceDefaultRoles": null,
|
|
|
|
"AgentACLDefaultPolicy": "allow",
|
|
|
|
"AgentACLDownPolicy": "deny",
|
|
|
|
"ResolvedByAgent": "server-1",
|
|
|
|
"CreateIndex": 42,
|
|
|
|
"ModifyIndex": 100
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2018-10-31 22:11:51 +00:00
|
|
|
## Read Self Token
|
|
|
|
|
|
|
|
This endpoint returns the ACL token details that matches the secret ID
|
|
|
|
specified with the `X-Consul-Token` header or the `token` query parameter.
|
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Method | Path | Produces |
|
|
|
|
| ------ | ----------------- | ------------------ |
|
|
|
|
| `GET` | `/acl/token/self` | `application/json` |
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2023-01-25 16:52:43 +00:00
|
|
|
[blocking queries](/consul/api-docs/features/blocking),
|
|
|
|
[consistency modes](/consul/api-docs/features/consistency),
|
|
|
|
[agent caching](/consul/api-docs/features/caching), and
|
|
|
|
[required ACLs](/consul/api-docs/api-structure#authentication).
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
|
|
|
|
| ---------------- | ----------------- | ------------- | ------------ |
|
|
|
|
| `YES` | `all` | `none` | `none` |
|
|
|
|
|
|
|
|
-> **Note** - This endpoint requires no specific privileges as it is just
|
|
|
|
retrieving the data for a token that you must already possess its secret.
|
|
|
|
|
2023-01-25 16:52:43 +00:00
|
|
|
The corresponding CLI command is [`consul acl token read -self`](/consul/commands/acl/token/read#self).
|
2022-01-10 19:21:32 +00:00
|
|
|
|
2018-10-31 22:11:51 +00:00
|
|
|
### Sample Request
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2022-01-12 23:05:01 +00:00
|
|
|
$ curl --header "X-Consul-Token: 6a1253d2-1785-24fd-91c2-f8e78c745511" \
|
2018-10-31 22:11:51 +00:00
|
|
|
http://127.0.0.1:8500/v1/acl/token/self
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2020-04-06 20:27:35 +00:00
|
|
|
"AccessorID": "6a1253d2-1785-24fd-91c2-f8e78c745511",
|
|
|
|
"SecretID": "45a3bd52-07c7-47a4-52fd-0745e0cfe967",
|
|
|
|
"Description": "Agent token for 'node1'",
|
|
|
|
"Policies": [
|
|
|
|
{
|
|
|
|
"ID": "165d4317-e379-f732-ce70-86278c4558f7",
|
|
|
|
"Name": "node1-write"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"ID": "e359bd81-baca-903e-7e64-1ccd9fdc78f5",
|
|
|
|
"Name": "node-read"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Local": false,
|
|
|
|
"CreateTime": "2018-10-24T12:25:06.921933-04:00",
|
|
|
|
"Hash": "UuiRkOQPRCvoRZHRtUxxbrmwZ5crYrOdZ0Z1FTFbTbA=",
|
|
|
|
"CreateIndex": 59,
|
|
|
|
"ModifyIndex": 59
|
2018-10-31 22:11:51 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Update a Token
|
|
|
|
|
|
|
|
This endpoint updates an existing ACL token.
|
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Method | Path | Produces |
|
|
|
|
| ------ | ------------------------ | ------------------ |
|
|
|
|
| `PUT` | `/acl/token/:AccessorID` | `application/json` |
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2023-01-25 16:52:43 +00:00
|
|
|
[blocking queries](/consul/api-docs/features/blocking),
|
|
|
|
[consistency modes](/consul/api-docs/features/consistency),
|
|
|
|
[agent caching](/consul/api-docs/features/caching), and
|
|
|
|
[required ACLs](/consul/api-docs/api-structure#authentication).
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
|
|
|
|
| ---------------- | ----------------- | ------------- | ------------ |
|
|
|
|
| `NO` | `none` | `none` | `acl:write` |
|
|
|
|
|
2023-01-25 16:52:43 +00:00
|
|
|
The corresponding CLI command is [`consul acl token update`](/consul/commands/acl/token/update).
|
2022-01-10 19:21:32 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Path Parameters
|
|
|
|
|
|
|
|
- `AccessorID` `(string: <required>)` - Specifies the accessor ID of the token you update.
|
|
|
|
|
|
|
|
### Query Parameters
|
|
|
|
|
|
|
|
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the token you update.
|
|
|
|
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
|
2018-10-31 22:11:51 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### JSON Request Body Schema
|
|
|
|
|
|
|
|
- `AccessorID` `(string: "")` - Specifies the accessor ID of the token being updated.
|
|
|
|
This field is required in the URL path but may also be specified in the JSON body.
|
|
|
|
If specified in both places then they must be an exact match.
|
|
|
|
This field is immutable. If not present in
|
2020-04-06 20:27:35 +00:00
|
|
|
the body and only in the URL then it will be filled in by Consul.
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
- `SecretID` `(string: "")` - Specifies the secret ID of the token being updated. This field is
|
2020-04-06 20:27:35 +00:00
|
|
|
immutable so if present in the body then it must match the existing value. If not present
|
|
|
|
then the value will be filled in by Consul.
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
- `Description` `(string: "")` - Free form human readable description of this token.
|
|
|
|
|
|
|
|
- `Policies` `(array<PolicyLink>)` - This is the list of policies that should
|
2019-05-01 21:11:23 +00:00
|
|
|
be applied to this token. A PolicyLink is an object with an "ID" and/or
|
|
|
|
"Name" field to specify a policy. With the PolicyLink tokens can be linked to policies
|
|
|
|
either by the policy name or by the policy ID. When policies are linked by
|
|
|
|
name they will internally be resolved to the policy ID. With linking tokens
|
|
|
|
internally by IDs, Consul enables policy renaming without breaking tokens.
|
|
|
|
|
|
|
|
- `Roles` `(array<RoleLink>)` - The list of roles that should be applied to the
|
|
|
|
token. A RoleLink is an object with an "ID" and/or "Name" field to specify a
|
|
|
|
role. With the RoleLink, tokens can be linked to roles either by the role
|
|
|
|
name or by the role ID. When roles are linked by name they will be internally
|
|
|
|
resolved to the role ID. With linking tokens internally by IDs, Consul
|
|
|
|
enables role renaming without breaking tokens.
|
|
|
|
|
|
|
|
- `ServiceIdentities` `(array<ServiceIdentity>)` - The list of [service
|
2023-01-25 16:52:43 +00:00
|
|
|
identities](/consul/docs/security/acl#service-identities) that should be
|
2019-05-01 21:11:23 +00:00
|
|
|
applied to the token. Added in Consul 1.5.0.
|
|
|
|
|
|
|
|
- `ServiceName` `(string: <required>)` - The name of the service. The name
|
|
|
|
must be no longer than 256 characters, must start and end with a lowercase
|
|
|
|
alphanumeric character, and can only contain lowercase alphanumeric
|
|
|
|
characters as well as `-` and `_`.
|
|
|
|
|
|
|
|
- `Datacenters` `(array<string>)` - Specifies the datacenters the effective
|
|
|
|
policy is valid within. When no datacenters are provided the effective
|
|
|
|
policy is valid in all datacenters including those which do not yet exist
|
|
|
|
but may in the future.
|
|
|
|
|
2020-06-16 16:54:27 +00:00
|
|
|
- `NodeIdentities` `(array<NodeIdentity>)` - The list of [node
|
2023-01-25 16:52:43 +00:00
|
|
|
identities](/consul/docs/security/acl#node-identities) that should be
|
2020-06-16 16:54:27 +00:00
|
|
|
applied to the token. Added in Consul 1.8.1.
|
|
|
|
|
|
|
|
- `NodeName` `(string: <required>)` - The name of the node. The name
|
|
|
|
must be no longer than 256 characters, must start and end with a lowercase
|
|
|
|
alphanumeric character, and can only contain lowercase alphanumeric
|
|
|
|
characters as well as `-` and `_`.
|
|
|
|
|
|
|
|
- `Datacenter` `(string: <required>)` - Specifies the nodes datacenter. This
|
|
|
|
will result in effective policy only being valid in that datacenter.
|
|
|
|
|
2019-05-01 21:11:23 +00:00
|
|
|
- `Local` `(bool: false)` - If true, indicates that this token should not be
|
|
|
|
replicated globally and instead be local to the current datacenter. This
|
|
|
|
value must match the existing value or the request will return an error.
|
|
|
|
|
|
|
|
- `AuthMethod` `(string: "")` - Specifies the name of the auth method that
|
|
|
|
created this token. This field is immutable so if present in the body then it
|
|
|
|
must match the existing value. If not present then the value will be filled
|
|
|
|
in by Consul.
|
|
|
|
|
|
|
|
- `ExpirationTime` `(time: "")` - Specifies the expiration time for the token
|
|
|
|
being updated. This field is immutable so if present in the body then it must
|
|
|
|
match the existing value. If not present then the value will be filled in by
|
|
|
|
Consul.
|
2018-10-31 22:11:51 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `Namespace` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the token you update.
|
|
|
|
This field takes precedence over the `ns` query parameter,
|
|
|
|
one of several [other methods to specify the namespace](#methods-to-specify-namespace).
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
### Sample Payload
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2020-04-06 20:27:35 +00:00
|
|
|
"Description": "Agent token for 'node1'",
|
|
|
|
"Policies": [
|
|
|
|
{
|
|
|
|
"ID": "165d4317-e379-f732-ce70-86278c4558f7"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "node-read"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "service-read"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Local": false
|
2018-10-31 22:11:51 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2022-01-12 23:05:01 +00:00
|
|
|
$ curl --request PUT \
|
2018-10-31 22:11:51 +00:00
|
|
|
--data @payload.json \
|
|
|
|
http://127.0.0.1:8500/v1/acl/token/6a1253d2-1785-24fd-91c2-f8e78c745511
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2020-04-06 20:27:35 +00:00
|
|
|
"AccessorID": "6a1253d2-1785-24fd-91c2-f8e78c745511",
|
|
|
|
"SecretID": "45a3bd52-07c7-47a4-52fd-0745e0cfe967",
|
|
|
|
"Description": "Agent token for 'node1'",
|
|
|
|
"Policies": [
|
|
|
|
{
|
|
|
|
"ID": "165d4317-e379-f732-ce70-86278c4558f7",
|
|
|
|
"Name": "node1-write"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"ID": "e359bd81-baca-903e-7e64-1ccd9fdc78f5",
|
|
|
|
"Name": "node-read"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"ID": "93d2226b-2046-4db1-993b-c0581b5d2391",
|
|
|
|
"Name": "service-read"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Local": false,
|
|
|
|
"CreateTime": "2018-10-24T12:25:06.921933-04:00",
|
|
|
|
"Hash": "UuiRkOQPRCvoRZHRtUxxbrmwZ5crYrOdZ0Z1FTFbTbA=",
|
|
|
|
"CreateIndex": 59,
|
|
|
|
"ModifyIndex": 100
|
2018-10-31 22:11:51 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Clone a Token
|
|
|
|
|
|
|
|
This endpoint clones an existing ACL token.
|
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Method | Path | Produces |
|
|
|
|
| ------ | ------------------------------ | ------------------ |
|
|
|
|
| `PUT` | `/acl/token/:AccessorID/clone` | `application/json` |
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2023-01-25 16:52:43 +00:00
|
|
|
[blocking queries](/consul/api-docs/features/blocking),
|
|
|
|
[consistency modes](/consul/api-docs/features/consistency),
|
|
|
|
[agent caching](/consul/api-docs/features/caching), and
|
|
|
|
[required ACLs](/consul/api-docs/api-structure#authentication).
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
|
|
|
|
| ---------------- | ----------------- | ------------- | ------------ |
|
|
|
|
| `NO` | `none` | `none` | `acl:write` |
|
|
|
|
|
2023-01-25 16:52:43 +00:00
|
|
|
The corresponding CLI command is [`consul acl token clone`](/consul/commands/acl/token/clone).
|
2022-01-10 19:21:32 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Path Parameters
|
|
|
|
|
|
|
|
- `AccessorID` `(string: <required>)` - The accessor ID of the token to clone.
|
|
|
|
|
|
|
|
### Query Parameters
|
2018-10-31 22:11:51 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the token you clone.
|
|
|
|
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
|
|
|
|
|
|
|
|
### JSON Request Body Schema
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
- `Description` `(string: "")` - Free form human readable description for the cloned token.
|
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `Namespace` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the token you clone.
|
|
|
|
This field takes precedence over the `ns` query parameter,
|
|
|
|
one of several [other methods to specify the namespace](#methods-to-specify-namespace).
|
2019-12-06 16:14:56 +00:00
|
|
|
|
2018-10-31 22:11:51 +00:00
|
|
|
### Sample Payload
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2020-04-06 20:27:35 +00:00
|
|
|
"Description": "Clone of Agent token for 'node1'"
|
2018-10-31 22:11:51 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2022-01-12 23:05:01 +00:00
|
|
|
$ curl --request PUT \
|
2018-10-31 22:11:51 +00:00
|
|
|
--data @payload.json \
|
|
|
|
http://127.0.0.1:8500/v1/acl/token/6a1253d2-1785-24fd-91c2-f8e78c745511/clone
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2020-04-06 20:27:35 +00:00
|
|
|
"AccessorID": "773efe2a-1f6f-451f-878c-71be10712bae",
|
|
|
|
"SecretID": "8b1247ef-d172-4f99-b050-4dbe5d3df0cb",
|
|
|
|
"Description": "Clone of Agent token for 'node1'",
|
|
|
|
"Policies": [
|
|
|
|
{
|
|
|
|
"ID": "165d4317-e379-f732-ce70-86278c4558f7",
|
|
|
|
"Name": "node1-write"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"ID": "e359bd81-baca-903e-7e64-1ccd9fdc78f5",
|
|
|
|
"Name": "node-read"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"ID": "93d2226b-2046-4db1-993b-c0581b5d2391",
|
|
|
|
"Name": "service-read"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Local": false,
|
|
|
|
"CreateTime": "2018-10-24T12:25:06.921933-04:00",
|
|
|
|
"Hash": "UuiRkOQPRCvoRZHRtUxxbrmwZ5crYrOdZ0Z1FTFbTbA=",
|
|
|
|
"CreateIndex": 128,
|
|
|
|
"ModifyIndex": 128
|
2018-10-31 22:11:51 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Delete a Token
|
|
|
|
|
|
|
|
This endpoint deletes an ACL token.
|
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Method | Path | Produces |
|
|
|
|
| -------- | ------------------------ | ------------------ |
|
|
|
|
| `DELETE` | `/acl/token/:AccessorID` | `application/json` |
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
Even though the return type is application/json, the value is either true or
|
|
|
|
false, indicating whether the delete succeeded.
|
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2023-01-25 16:52:43 +00:00
|
|
|
[blocking queries](/consul/api-docs/features/blocking),
|
|
|
|
[consistency modes](/consul/api-docs/features/consistency),
|
|
|
|
[agent caching](/consul/api-docs/features/caching), and
|
|
|
|
[required ACLs](/consul/api-docs/api-structure#authentication).
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
|
|
|
|
| ---------------- | ----------------- | ------------- | ------------ |
|
|
|
|
| `NO` | `none` | `none` | `acl:write` |
|
|
|
|
|
2023-01-25 16:52:43 +00:00
|
|
|
The corresponding CLI command is [`consul acl token delete`](/consul/commands/acl/token/delete).
|
2022-01-10 19:21:32 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Path Parameters
|
|
|
|
|
|
|
|
- `AccessorID` `(string: <required>)` - Specifies the accessor ID of the ACL token to delete.
|
2018-10-31 22:11:51 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Query Parameters
|
2020-02-03 08:41:54 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the token you delete.
|
|
|
|
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2022-01-12 23:05:01 +00:00
|
|
|
$ curl --request DELETE \
|
2018-10-31 22:11:51 +00:00
|
|
|
http://127.0.0.1:8500/v1/acl/token/8f246b77-f3e1-ff88-5b48-8ec93abf3e05
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Response
|
2020-04-06 20:27:35 +00:00
|
|
|
|
2018-10-31 22:11:51 +00:00
|
|
|
```json
|
|
|
|
true
|
|
|
|
```
|
|
|
|
|
|
|
|
## List Tokens
|
|
|
|
|
|
|
|
This endpoint lists all the ACL tokens.
|
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Method | Path | Produces |
|
|
|
|
| ------ | ------------- | ------------------ |
|
|
|
|
| `GET` | `/acl/tokens` | `application/json` |
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2023-01-25 16:52:43 +00:00
|
|
|
[blocking queries](/consul/api-docs/features/blocking),
|
|
|
|
[consistency modes](/consul/api-docs/features/consistency),
|
|
|
|
[agent caching](/consul/api-docs/features/caching), and
|
|
|
|
[required ACLs](/consul/api-docs/api-structure#authentication).
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
|
|
|
|
| ---------------- | ----------------- | ------------- | ------------ |
|
|
|
|
| `YES` | `all` | `none` | `acl:read` |
|
|
|
|
|
2023-01-25 16:52:43 +00:00
|
|
|
The corresponding CLI command is [`consul acl token list`](/consul/commands/acl/token/list).
|
2022-01-10 19:21:32 +00:00
|
|
|
|
2023-01-06 16:37:19 +00:00
|
|
|
### Query Parameters
|
2018-10-31 22:11:51 +00:00
|
|
|
|
2019-05-01 21:11:23 +00:00
|
|
|
- `policy` `(string: "")` - Filters the token list to those tokens that are
|
2022-05-10 15:51:11 +00:00
|
|
|
linked with this specific policy ID.
|
2019-05-01 21:11:23 +00:00
|
|
|
|
|
|
|
- `role` `(string: "")` - Filters the token list to those tokens that are
|
2022-05-10 15:51:11 +00:00
|
|
|
linked with this specific role ID.
|
2019-05-01 21:11:23 +00:00
|
|
|
|
|
|
|
- `authmethod` `(string: "")` - Filters the token list to those tokens that are
|
2022-05-10 15:51:11 +00:00
|
|
|
linked with this specific named auth method.
|
2020-02-03 08:41:54 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `authmethod-ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the
|
|
|
|
`authmethod` used for token lookup. If not provided, the namespace
|
|
|
|
provided by the `ns` parameter or [through other methods](#methods-to-specify-namespace) will be used.
|
2020-02-03 08:41:54 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `ns` `(string: "")` <EnterpriseAlert inline /> - Return only the tokens in the specified namespace.
|
|
|
|
The namespace may be specified as '\*' to return results for all namespaces.
|
|
|
|
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
|
2018-10-31 22:11:51 +00:00
|
|
|
|
2023-01-06 16:37:19 +00:00
|
|
|
### Sample Request
|
2018-10-31 22:11:51 +00:00
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2022-01-12 23:05:01 +00:00
|
|
|
$ curl --request GET http://127.0.0.1:8500/v1/acl/tokens
|
2018-10-31 22:11:51 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
2021-07-08 22:13:08 +00:00
|
|
|
-> **Note** If the token used for accessing the API has `acl:write` permissions,
|
|
|
|
then the `SecretID` will contain the tokens real value. Only when accessed with
|
|
|
|
a token with only `acl:read` permissions will the `SecretID` be redacted. This
|
|
|
|
is to prevent privilege escalation whereby having `acl:read` privileges allows
|
|
|
|
for reading other secrets which given even more permissions.
|
2018-10-31 22:11:51 +00:00
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
2020-04-06 20:27:35 +00:00
|
|
|
{
|
|
|
|
"AccessorID": "6a1253d2-1785-24fd-91c2-f8e78c745511",
|
2021-07-08 22:13:08 +00:00
|
|
|
"SecretID": "<hidden>",
|
2020-04-06 20:27:35 +00:00
|
|
|
"Description": "Agent token for 'my-agent'",
|
|
|
|
"Policies": [
|
|
|
|
{
|
|
|
|
"ID": "165d4317-e379-f732-ce70-86278c4558f7",
|
|
|
|
"Name": "node1-write"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"ID": "e359bd81-baca-903e-7e64-1ccd9fdc78f5",
|
|
|
|
"Name": "node-read"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Local": false,
|
|
|
|
"CreateTime": "2018-10-24T12:25:06.921933-04:00",
|
|
|
|
"Hash": "UuiRkOQPRCvoRZHRtUxxbrmwZ5crYrOdZ0Z1FTFbTbA=",
|
|
|
|
"CreateIndex": 59,
|
|
|
|
"ModifyIndex": 59
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"AccessorID": "00000000-0000-0000-0000-000000000002",
|
2021-07-08 22:13:08 +00:00
|
|
|
"SecretID": "<hidden>",
|
2020-04-06 20:27:35 +00:00
|
|
|
"Description": "Anonymous Token",
|
|
|
|
"Policies": null,
|
|
|
|
"Local": false,
|
|
|
|
"CreateTime": "0001-01-01T00:00:00Z",
|
|
|
|
"Hash": "RNVFSWnfd5DUOuB8vplp+imivlIna3fKQVnkUHh21cA=",
|
|
|
|
"CreateIndex": 5,
|
|
|
|
"ModifyIndex": 5
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"AccessorID": "3328f9a6-433c-02d0-6649-7d07268dfec7",
|
2021-07-08 22:13:08 +00:00
|
|
|
"SecretID": "<hidden>",
|
2020-04-06 20:27:35 +00:00
|
|
|
"Description": "Bootstrap Token (Global Management)",
|
|
|
|
"Policies": [
|
|
|
|
{
|
|
|
|
"ID": "00000000-0000-0000-0000-000000000001",
|
|
|
|
"Name": "global-management"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"Local": false,
|
|
|
|
"CreateTime": "2018-10-24T11:42:02.6427-04:00",
|
|
|
|
"Hash": "oyrov6+GFLjo/KZAfqgxF/X4J/3LX0435DOBy9V22I0=",
|
|
|
|
"CreateIndex": 12,
|
|
|
|
"ModifyIndex": 12
|
|
|
|
}
|
2018-10-31 22:11:51 +00:00
|
|
|
]
|
|
|
|
```
|
2022-05-10 15:51:11 +00:00
|
|
|
|
|
|
|
## Methods to Specify Namespace <EnterpriseAlert inline />
|
|
|
|
|
|
|
|
ACL token endpoints
|
|
|
|
support several methods for specifying the namespace of the ACL token resources
|
|
|
|
with the following order of precedence:
|
|
|
|
1. `Namespace` field of the JSON request body -
|
|
|
|
only applies to [create](#create-a-token) and [update](#update-a-token) endpoints
|
|
|
|
1. `ns` query parameter
|
|
|
|
1. `X-Consul-Namespace` request header
|
|
|
|
1. Namespace is inherited from the namespace of the request's ACL token (if any)
|
|
|
|
1. The `default` namespace
|