github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/api-docs/acl-tokens.mdx (about) 1 --- 2 layout: api 3 page_title: ACL Tokens - HTTP API 4 sidebar_title: ACL Tokens 5 description: The /acl/token/ endpoints are used to configure and manage ACL tokens. 6 --- 7 8 # ACL Tokens HTTP API 9 10 The `/acl/bootstrap`, `/acl/tokens`, and `/acl/token/` endpoints are used to manage ACL tokens. 11 For more details about ACLs, please see the [ACL Guide](https://learn.hashicorp.com/nomad?track=acls#operations-and-development). 12 13 ## Bootstrap Token 14 15 This endpoint is used to bootstrap the ACL system and provide the initial management token. 16 This request is always forwarded to the authoritative region. It can only be invoked once 17 until a [bootstrap reset](https://learn.hashicorp.com/nomad?track=acls#acls) is performed. 18 19 | Method | Path | Produces | 20 | ------ | ---------------- | ------------------ | 21 | `POST` | `/acl/bootstrap` | `application/json` | 22 23 The table below shows this endpoint's support for 24 [blocking queries](/api-docs#blocking-queries) and 25 [required ACLs](/api-docs#acls). 26 27 | Blocking Queries | ACL Required | 28 | ---------------- | ------------ | 29 | `NO` | `none` | 30 31 ### Sample Request 32 33 ```shell-session 34 $ curl \ 35 --request POST \ 36 https://localhost:4646/v1/acl/bootstrap 37 ``` 38 39 ### Sample Response 40 41 ```json 42 { 43 "AccessorID": "b780e702-98ce-521f-2e5f-c6b87de05b24", 44 "SecretID": "3f4a0fcd-7c42-773c-25db-2d31ba0c05fe", 45 "Name": "Bootstrap Token", 46 "Type": "management", 47 "Policies": null, 48 "Global": true, 49 "CreateTime": "2017-08-23T22:47:14.695408057Z", 50 "CreateIndex": 7, 51 "ModifyIndex": 7 52 } 53 ``` 54 55 ## List Tokens 56 57 This endpoint lists all ACL tokens. This lists the local tokens and the global 58 tokens which have been replicated to the region, and may lag behind the authoritative region. 59 60 | Method | Path | Produces | 61 | ------ | ------------- | ------------------ | 62 | `GET` | `/acl/tokens` | `application/json` | 63 64 The table below shows this endpoint's support for 65 [blocking queries](/api-docs#blocking-queries), [consistency modes](/api-docs#consistency-modes) and 66 [required ACLs](/api-docs#acls). 67 68 | Blocking Queries | Consistency Modes | ACL Required | 69 | ---------------- | ----------------- | ------------ | 70 | `YES` | `all` | `management` | 71 72 ### Parameters 73 74 - `prefix` `(string: "")` - Specifies a string to filter ACL tokens based on an 75 accessor ID prefix. Because the value is decoded to bytes, the prefix must 76 have an even number of hexadecimal characters (0-9a-f). This is specified as 77 a query string parameter. 78 79 ### Sample Request 80 81 ```shell-session 82 $ curl \ 83 https://localhost:4646/v1/acl/tokens 84 ``` 85 86 ```shell-session 87 $ curl \ 88 --request POST \ 89 https://localhost:4646/v1/acl/tokens?prefix=3da2ed52 90 ``` 91 92 ### Sample Response 93 94 ```json 95 [ 96 { 97 "AccessorID": "b780e702-98ce-521f-2e5f-c6b87de05b24", 98 "Name": "Bootstrap Token", 99 "Type": "management", 100 "Policies": null, 101 "Global": true, 102 "CreateTime": "2017-08-23T22:47:14.695408057Z", 103 "CreateIndex": 7, 104 "ModifyIndex": 7 105 } 106 ] 107 ``` 108 109 ## Create Token 110 111 This endpoint creates an ACL Token. If the token is a global token, the request 112 is forwarded to the authoritative region. 113 114 | Method | Path | Produces | 115 | ------ | ------------ | ------------------ | 116 | `POST` | `/acl/token` | `application/json` | 117 118 The table below shows this endpoint's support for 119 [blocking queries](/api-docs#blocking-queries) and 120 [required ACLs](/api-docs#acls). 121 122 | Blocking Queries | ACL Required | 123 | ---------------- | ------------ | 124 | `NO` | `management` | 125 126 ### Parameters 127 128 - `Name` `(string: <optional>)` - Specifies the human readable name of the token. 129 130 - `Type` `(string: <required>)` - Specifies the type of token. Must be either `client` or `management`. 131 132 - `Policies` `(array<string>: <required>)` - Must be null or blank for `management` type tokens, otherwise must specify at least one policy for `client` type tokens. 133 134 - `Global` `(bool: <optional>)` - If true, indicates this token should be replicated globally to all regions. Otherwise, this token is created local to the target region. 135 136 ### Sample Payload 137 138 ```json 139 { 140 "Name": "Readonly token", 141 "Type": "client", 142 "Policies": ["readonly"], 143 "Global": false 144 } 145 ``` 146 147 ### Sample Request 148 149 ```shell-session 150 $ curl \ 151 --request POST \ 152 --data @payload.json \ 153 https://localhost:4646/v1/acl/token 154 ``` 155 156 ### Sample Response 157 158 ```json 159 { 160 "AccessorID": "aa534e09-6a07-0a45-2295-a7f77063d429", 161 "SecretID": "8176afd3-772d-0b71-8f85-7fa5d903e9d4", 162 "Name": "Readonly token", 163 "Type": "client", 164 "Policies": ["readonly"], 165 "Global": false, 166 "CreateTime": "2017-08-23T23:25:41.429154233Z", 167 "CreateIndex": 52, 168 "ModifyIndex": 52 169 } 170 ``` 171 172 ## Update Token 173 174 This endpoint updates an existing ACL Token. If the token is a global token, the request 175 is forwarded to the authoritative region. Note that a token cannot be switched from global 176 to local or visa versa. 177 178 | Method | Path | Produces | 179 | ------ | ------------------------- | ------------------ | 180 | `POST` | `/acl/token/:accessor_id` | `application/json` | 181 182 The table below shows this endpoint's support for 183 [blocking queries](/api-docs#blocking-queries) and 184 [required ACLs](/api-docs#acls). 185 186 | Blocking Queries | ACL Required | 187 | ---------------- | ------------ | 188 | `NO` | `management` | 189 190 ### Parameters 191 192 - `AccessorID` `(string: <required>)` - Specifies the token (by accessor) that is being updated. Must match payload body and request path. 193 194 - `Name` `(string: <optional>)` - Specifies the human readable name of the token. 195 196 - `Type` `(string: <required>)` - Specifies the type of token. Must be either `client` or `management`. 197 198 - `Policies` `(array<string>: <required>)` - Must be null or blank for `management` type tokens, otherwise must specify at least one policy for `client` type tokens. 199 200 ### Sample Payload 201 202 ```json 203 { 204 "AccessorID": "aa534e09-6a07-0a45-2295-a7f77063d429", 205 "Name": "Read-write token", 206 "Type": "client", 207 "Policies": ["readwrite"] 208 } 209 ``` 210 211 ### Sample Request 212 213 ```shell-session 214 $ curl \ 215 --request POST \ 216 --data @payload.json \ 217 https://localhost:4646/v1/acl/token/aa534e09-6a07-0a45-2295-a7f77063d429 218 ``` 219 220 ### Sample Response 221 222 ```json 223 { 224 "AccessorID": "aa534e09-6a07-0a45-2295-a7f77063d429", 225 "SecretID": "8176afd3-772d-0b71-8f85-7fa5d903e9d4", 226 "Name": "Read-write token", 227 "Type": "client", 228 "Policies": ["readwrite"], 229 "Global": false, 230 "CreateTime": "2017-08-23T23:25:41.429154233Z", 231 "CreateIndex": 52, 232 "ModifyIndex": 64 233 } 234 ``` 235 236 ## Read Token 237 238 This endpoint reads an ACL token with the given accessor. If the token is a global token 239 which has been replicated to the region it may lag behind the authoritative region. 240 241 | Method | Path | Produces | 242 | ------ | ------------------------- | ------------------ | 243 | `GET` | `/acl/token/:accessor_id` | `application/json` | 244 245 The table below shows this endpoint's support for 246 [blocking queries](/api-docs#blocking-queries), [consistency modes](/api-docs#consistency-modes) and 247 [required ACLs](/api-docs#acls). 248 249 | Blocking Queries | Consistency Modes | ACL Required | 250 | ---------------- | ----------------- | -------------------------------------------------- | 251 | `YES` | `all` | `management` or a SecretID matching the AccessorID | 252 253 ### Sample Request 254 255 ```shell-session 256 $ curl \ 257 https://localhost:4646/v1/acl/token/aa534e09-6a07-0a45-2295-a7f77063d429 258 ``` 259 260 ### Sample Response 261 262 ```json 263 { 264 "AccessorID": "aa534e09-6a07-0a45-2295-a7f77063d429", 265 "SecretID": "8176afd3-772d-0b71-8f85-7fa5d903e9d4", 266 "Name": "Read-write token", 267 "Type": "client", 268 "Policies": ["readwrite"], 269 "Global": false, 270 "CreateTime": "2017-08-23T23:25:41.429154233Z", 271 "CreateIndex": 52, 272 "ModifyIndex": 64 273 } 274 ``` 275 276 ## Read Self Token 277 278 This endpoint reads the ACL token given by the passed SecretID. If the token is a global token 279 which has been replicated to the region it may lag behind the authoritative region. 280 281 | Method | Path | Produces | 282 | ------ | ----------------- | ------------------ | 283 | `GET` | `/acl/token/self` | `application/json` | 284 285 The table below shows this endpoint's support for 286 [blocking queries](/api-docs#blocking-queries), [consistency modes](/api-docs#consistency-modes) and 287 [required ACLs](/api-docs#acls). 288 289 | Blocking Queries | Consistency Modes | ACL Required | 290 | ---------------- | ----------------- | ------------------- | 291 | `YES` | `all` | Any valid ACL token | 292 293 ### Sample Request 294 295 ```shell-session 296 $ curl \ 297 --header "X-Nomad-Token: 8176afd3-772d-0b71-8f85-7fa5d903e9d4" \ 298 https://localhost:4646/v1/acl/token/self 299 ``` 300 301 ### Sample Response 302 303 ```json 304 { 305 "AccessorID": "aa534e09-6a07-0a45-2295-a7f77063d429", 306 "SecretID": "8176afd3-772d-0b71-8f85-7fa5d903e9d4", 307 "Name": "Read-write token", 308 "Type": "client", 309 "Policies": ["readwrite"], 310 "Global": false, 311 "CreateTime": "2017-08-23T23:25:41.429154233Z", 312 "CreateIndex": 52, 313 "ModifyIndex": 64 314 } 315 ``` 316 317 ## Delete Token 318 319 This endpoint deletes the ACL token by accessor. This request is forwarded to the 320 authoritative region for global tokens. 321 322 | Method | Path | Produces | 323 | -------- | ------------------------- | -------------- | 324 | `DELETE` | `/acl/token/:accessor_id` | `(empty body)` | 325 326 The table below shows this endpoint's support for 327 [blocking queries](/api-docs#blocking-queries) and 328 [required ACLs](/api-docs#acls). 329 330 | Blocking Queries | ACL Required | 331 | ---------------- | ------------ | 332 | `NO` | `management` | 333 334 ### Parameters 335 336 - `accessor_id` `(string: <required>)` - Specifies the ACL token accessor ID. 337 338 ### Sample Request 339 340 ```shell-session 341 $ curl \ 342 --request DELETE \ 343 https://localhost:4646/v1/acl/token/aa534e09-6a07-0a45-2295-a7f77063d429 344 ```