-
Notifications
You must be signed in to change notification settings - Fork 67
ACL
Subcommand | Synopsis |
---|---|
clone | Create a new token from an existing one |
create | Create an ACL. Requires a management token |
destroy | Destroy an ACL |
info | Query information about an ACL token |
list | List all active ACL tokens |
update | Update an ACL. Will be created if it doesn't exist |
Create a new ACL token from an existing token. The request is automatically forwarded to the authoritative ACL datacenter so the --datacenter
command line option not present.
Usage: consul-cli acl clone [options] token
$ ./consul-cli acl clone d414c3e6-c498-64fa-5a2e-1a942425a410
9c0ac7d1-9a90-f5be-3b21-bf21e1c2c9b7
Create a new ACL token with the given policy. A management token must be supplied in CONSUL_HTTP_TOKEN
or via --token
.
consul-cli acl create [options]
-
--management
When true, create a token that can manage ACLs. Default isfalse
-
--name
Opaque to Consul, this should be a meaningful indicator of the ACL's purpose -
--rule
Policy rules for the ACL token. See Consul ACL System for details on ACL rules. The rule is of the formtype:path:policy
wheretype
is one ofkey
orservice
. Thepath
can be blank which then affects all services or all keys.policy
is one ofread
,write
ordeny
.
--rule='key:test/node:read'
Gives the token read access to the /v1/kv/test/node/ tree
--rule='service:secure-:read'
Gives the token read access to all services prefixed with secure-
$ ./consul-cli acl create --name='test acl' --rule='key:test/node:deny'
d414c3e6-c498-64fa-5a2e-1a942425a410
$ ./consul-cli kv write --token=d414c3e6-c498-64fa-5a2e-1a942425a410 test/node Testing
Unexpected response code: 403 (Permission denied)
Destroys the given token. A management token must be provided via CONSUL_HTTP_TOKEN
or --token
Usage: consul-cli acl destroy [options] token
$ ./consul-cli acl destroy d414c3e6-c498-64fa-5a2e-1a942425a410
$
Queries the policy of a given token. A management token must be provided via CONSUL_HTTP_TOKEN
or --token
Usage: consul-cli acl info [options] token
$ ./consul-cli acl info d414c3e6-c498-64fa-5a2e-1a942425a410
{
"CreateIndex": 98,
"ModifyIndex": 98,
"ID": "d414c3e6-c498-64fa-5a2e-1a942425a410",
"Name": "test acl",
"Type": "client",
"Rules": "{\"key\":{\"test/node\":{\"Policy\":\"deny\"}}}"
}
List all of the active tokens. A management token must be provided via CONSUL_HTTP_TOKEN
or --token
Usage: consul-cli acl list [options]
$ ./consul-cli acl list --token=ccc67226-2462-4804-b944-4d728c7bad03
[
{
"CreateIndex": 112,
"ModifyIndex": 112,
"ID": "9c0ac7d1-9a90-f5be-3b21-bf21e1c2c9b7",
"Name": "test acl",
"Type": "client",
"Rules": "{\"key\":{\"test/node\":{\"Policy\":\"deny\"}}}"
},
{
"CreateIndex": 3,
"ModifyIndex": 3,
"ID": "anonymous",
"Name": "Anonymous Token",
"Type": "client",
"Rules": ""
},
{
"CreateIndex": 98,
"ModifyIndex": 98,
"ID": "d414c3e6-c498-64fa-5a2e-1a942425a410",
"Name": "test acl",
"Type": "client",
"Rules": "{\"key\":{\"test/node\":{\"Policy\":\"deny\"}}}"
}
]
Updates the policy of a token. A management token must be provided via CONSUL_HTTP_TOKEN
or --token
Usage: consul-cli acl update [options] token
-
--management
When true, create a token that can manage ACLs. Default isfalse
-
--name
Opaque to Consul, this should be a meaningful indicator of the ACL's purpose -
--rule
Policy rules for the ACL token. See Consul ACL System for details on ACL rules. The rule is of the formtype:path:policy
wheretype
is one ofkey
orservice
. Thepath
can be blank which then affects all services or all keys.policy
is one ofread
,write
ordeny
.
--rule='key:test/node:read'
Gives the token read access to the /v1/kv/test/node/ tree
--rule='service:secure-:read'
Gives the token read access to all services prefixed with secure-
$ ./consul-cli acl update --rule='key:test/node:deny' \
--rule='key:test/node/insecure:write' 9c0ac7d1-9a90-f5be-3b21-bf21e1c2c9b7
$ ./consul-cli kv write --token=9c0ac7d1-9a90-f5be-3b21-bf21e1c2c9b7 test/node/insecure Testing
$ ./consul-cli kv read --token=9c0ac7d1-9a90-f5be-3b21-bf21e1c2c9b7 test/node/insecure
Testing