ACL Binding Rule HTTP API
1.5.0+: The binding rule APIs are available in Consul versions 1.5.0 and newer.
The /acl/binding-rule
endpoints create,
read, update,
list and delete ACL binding
rules in Consul.
For more information on how to setup ACLs, refer to the following resources:
Create a Binding Rule
This endpoint creates a new ACL binding rule.
Method | Path | Produces |
---|---|---|
PUT | /acl/binding-rule | 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 | acl:write |
The corresponding CLI command is consul acl binding-rule create
.
Query Parameters
ns
(string: "")
Enterprise - Specifies the namespace of the binding rule you create. You can also specify the namespace through other methods.
JSON Request Body Schema
Description
(string: "")
- Free form human readable description of the binding rule.AuthMethod
(string: <required>)
- The name of the auth method that this rule applies to. This field is immutable.Selector
(string: "")
- Specifies the expression used to match this rule against valid identities returned from an auth method validation. If empty this binding rule matches all valid identities returned from the auth method. For example:BindType
(string: <required>)
- Specifies the way the binding rule affects a token created at login. You can specify one of the following:service
- The computed bind name value is used as anACLServiceIdentity.ServiceName
field in the token that is created.Equivalent payload for Consul token API endpointnode
- The computed bind name value is used as anACLNodeIdentity.NodeName
field in the token that is created.Equivalent payload for Consul token API endpointrole
- The computed bind name value is used as aRoleLink.Name
field in the token that is created. This binding rule will only apply if a role with the given name exists at login-time. If it does not then this rule is ignored.Equivalent payload for Consul token API endpointtemplated-policy
- The bind name value is used as anACLTemplatedPolicy.TemplateName
field in the token that is created. The computedBindVars
values are used in theACLTemplatedPolicy.TemplateVariables
field.Equivalent payload for Consul token API endpoint
BindName
(string: <required>)
- The name to bind to a token at login-time. What it binds to can be adjusted with different values of theBindType
field. This can either be a plain string or lightly templated using HIL syntax to interpolate the same values that are usable by theSelector
syntax. For example:BindVars
(<ACLTemplatedPolicyVariables>)
- Specifies the templated policy variables whenBindType
field is set totemplated-policy
. Consul populates theTemplatedPolicies.TemplateVariables
field with the computedBindVars
values in the token it creates. You can specify either a plain text string or templated string using HIL syntax. Consul interpolates templated strings with values that are usable by theSelector
syntax. For example:Namespace
(string: "")
Enterprise - Specifies the namespace of the binding rule you create. This field takes precedence over thens
query parameter, one of several other methods to specify the namespace.
Sample Payload
Sample Request
Sample Response
Read a Binding Rule
This endpoint reads an ACL binding rule with the given ID. If no binding rule exists with the given ID, a 404 is returned instead of a 200 response.
Method | Path | Produces |
---|---|---|
GET | /acl/binding-rule/:id | 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 |
---|---|---|---|
YES | all | none | acl:read |
The corresponding CLI command is consul acl binding-rule read
.
Path Parameters
id
(string: <required>)
- Specifies the UUID of the ACL binding rule to read.
Query Parameters
ns
(string: "")
Enterprise - Specifies the namespace of the binding rule you lookup. You can also specify the namespace through other methods.
Sample Request
Sample Response
Update a Binding Rule
This endpoint updates an existing ACL binding rule.
Method | Path | Produces |
---|---|---|
PUT | /acl/binding-rule/:id | 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 | acl:write |
The corresponding CLI command is consul acl binding-rule update
.
Path Parameters
id
(string: <required>)
- Specifies the UUID of the ACL binding rule you update.
Query Parameters
ns
(string: "")
Enterprise - Specifies the namespace of the binding rule you update. You can also specify the namespace through other methods.
JSON Request Body Schema
ID
(string: <optional>)
- If specified, this field must be an exact match with theid
path parameter.Description
(string: "")
- Free form human readable description of the binding rule.AuthMethod
(string: <required>)
- Specifies the name of the auth method that this rule applies to. 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.Selector
(string: "")
- Specifies the expression used to match this rule against valid identities returned from an auth method validation. If empty this binding rule matches all valid identities returned from the auth method. For example:BindType
(string: <required>)
- Specifies the way the binding rule affects a token created at login. You can specify one of the following:service
- The computed bind name value is used as anACLServiceIdentity.ServiceName
field in the token that is created.Equivalent payload for Consul token API endpointnode
- The computed bind name value is used as anACLNodeIdentity.NodeName
field in the token that is created.Equivalent payload for Consul token API endpointrole
- The computed bind name value is used as aRoleLink.Name
field in the token that is created. This binding rule will only apply if a role with the given name exists at login-time. If it does not then this rule is ignored.Equivalent payload for Consul token API endpointtemplated-policy
- Consul populates theTemplatedPolicies.TemplateName
with the value specified in theBindName
field in the token that is created. Consul also populates theTemplatedPolicies.TemplateVariables
field with the computedBindVars
values.Equivalent payload for Consul token API endpoint
BindName
(string: <required>)
- The name to bind to a token at login-time. What it binds to can be adjusted with different values of theBindType
field. This can either be a plain string or lightly templated using HIL syntax to interpolate the same values that are usable by theSelector
syntax. For example:BindVars
(<ACLTemplatedPolicyVariables>)
- Specifies the templated policy variables when theBindType
field is set totemplated-policy
. Consul populates theTemplatedPolicies.TemplateVariables
field with the computedBindVars
values in the token it creates. You can specify either a plain text string or templated string using HIL syntax. Consul interpolates templated strings with values that are usable by theSelector
syntax. For example:Namespace
(string: "")
Enterprise - Specifies the namespace of the binding rule you update. This field takes precedence over thens
query parameter, one of several other methods to specify the namespace.
Sample Payload
Sample Request
Sample Response
Delete a Binding Rule
This endpoint deletes an ACL binding rule.
Method | Path | Produces |
---|---|---|
DELETE | /acl/binding-rule/:id | application/json |
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 blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
NO | none | none | acl:write |
The corresponding CLI command is consul acl binding-rule delete
.
Path Parameters
id
(string: <required>)
- Specifies the UUID of the binding rule you delete.
Query Parameters
ns
(string: "")
Enterprise - Specifies the namespace of the binding rule you delete. You can also specify the namespace through other methods.
Sample Request
Sample Response
List Binding Rules
This endpoint lists all the ACL binding rules.
Method | Path | Produces |
---|---|---|
GET | /acl/binding-rules | 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 |
---|---|---|---|
YES | all | none | acl:read |
The corresponding CLI command is consul acl binding-rule list
.
Query Parameters
authmethod
(string: "")
- Filters the binding rule list to those binding rules that are linked with the specific named auth method.ns
(string: "")
Enterprise - Return only the binding rules 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.
Sample Request
Sample Response
Methods to specify namespace Enterprise
Binding rule create, read, update, and delete endpoints support several methods for specifying the namespace of the auth method resource with the following order of precedence:
Namespace
field of the JSON request body - only applies to create and update endpointsns
query parameterX-Consul-Namespace
request header- Namespace is inherited from the namespace of the request's ACL token (if any)
- The
default
namespace