Create a UI token
This topic describes how to create a token that you can use to view resources in the Consul UI.
Introduction
To navigate the Consul UI when ACLs are enabled, log into the UI with a token linked to policies that grant an appropriate set of permissions. The UI is unable to display resources that the token does not have permission to access.
Requirements
Core ACL functionality is available in all versions of Consul.
Authentication
You must provide an ACL token linked to a policy with acl:write
permissions to create and modify ACL tokens and policies using the CLI or API.
You can provide the token manually using the -token
option on the command line, but we recommend setting the CONSUL_HTTP_TOKEN
environment variable to simplify your workflow:
The Consul CLI automatically reads the CONSUL_HTTP_TOKEN
environment variable so that you do not have to pass the token to every Consul CLI command.
To authenticate calls to the Consul HTTP API, you must provide the token in the X-Consul-Token
header for each call:
To learn about alternative ways to authenticate, refer to the following documentation:
View catalog in Consul CE
This section describes how to create a token that grants read-only access to the catalog. This token allows users to view the catalog without the ability to make changes. To create the ACL token, define a policy, create the policy, and then link the policy to a token.
Define a policy
You can send policy definitions as command line or API arguments or define them in an external HCL or JSON file. Refer to ACL Rules for details about all of the rules you can use in your policies.
The following example policy is defined in a file. The policy allows users that login with the token to view all services and nodes in the catalog.
Register the policy with Consul
After defining the policies, you can register them with Consul using the command line or API endpoint.
Run the consul acl policy create
command and specify the policy rules to create a policy. The following example registers a policy defined in ui-view-catalog.hcl
.
Refer to Consul ACL Policy Create for details about the consul acl policy create
command.
Link the policy to a token
After registering the policies into Consul, you can create and link tokens using the Consul command line or API endpoint. You can also enable Consul to dynamically create tokens from trusted external systems using an auth method.
Run the consul acl token create
command and specify the policy name or ID to create a token linked to the policy. Refer to Consul ACL Token Create for details about the consul acl token create
command.
The following command creates the ACL token linked to the policy ui-view-catalog
.
View catalog in Consul Enterprise
This section describes how to create a token that grants read-only access to the catalog. This token allows users to view the catalog without the ability to make changes. To create the ACL token, define a policy, create the policy, and then link the policy to a token.
Define a policy
You can send policy definitions as command line or API arguments or define them in an external HCL or JSON file. Refer to ACL Rules for details about all of the rules you can use in your policies.
The following example policy is defined in a file. The following policy allows users that log in with the token to view services and nodes in the catalog in any partition and in any namespace. The operator:read
permission is needed to list partitions. Without this permission, you can still view resources within a partition but cannot easily navigate to other partitions in the Consul UI.
Register the policy with Consul
After defining the policies, you can register them with Consul using the command line or API endpoint.
Run the consul acl policy create
command and specify the policy rules to create a policy. The following example registers a policy defined in ui-view-catalog.hcl
.
You can specify an admin partition and namespace when registering policies in Consul Enterprise. Policies are only valid in the scopes specified during registration, but you can grant tokens registered in the default
partition permission to access resources in a different partition than where the token was registered. Refer to the admin partition documentation for additional information.
The following example registers the policy in the default
partition and the default
namespace because the policy grants cross-partition and cross-namespace access.
Refer to Consul ACL Policy Create for details about the consul acl policy create
command.
Link the policy to a token
After registering the policies into Consul, you can create and link tokens using the Consul command line or API endpoint. You can also enable Consul to dynamically create tokens from trusted external systems using an auth method.
Run the consul acl token create
command and specify the policy name or ID to create a token linked to the policy. Refer to Consul ACL Token Create for details about the consul acl token create
command.
View all resources in Consul CE
This section describes how to create a token with read-only access to all resources in the Consul UI. This token allows users to view any resources without the ability to make changes. To create the ACL token, define a policy, create the policy, and then link the policy to a token.
Define a policy
You can send policy definitions as command line or API arguments or define them in an external HCL or JSON file. Refer to ACL Rules for details about all of the rules you can use in your policies.
The following example policy is defined in a file. The policy allows users that log in with the token to view all services and nodes in the catalog, all objects in the key/value store, all intentions, and all ACL resources. The acl:read
permission does not allow viewing the token secret ids.
Register the policy with Consul
After defining the policies, you can register them with Consul using the command line or API endpoint.
Run the consul acl policy create
command and specify the policy rules to create a policy. The following example registers a policy defined in ui-view-all.hcl
.
Refer to Consul ACL Policy Create for details about the consul acl policy create
command.
Link the policy to a token
After registering the policies into Consul, you can create and link tokens using the Consul command line or API endpoint. You can also enable Consul to dynamically create tokens from trusted external systems using an auth method.
Run the consul acl token create
command and specify the policy name or ID to create a token linked to the policy. Refer to Consul ACL Token Create for details about the consul acl token create
command.
The following command creates the ACL token linked to the policy ui-view-all
.
View all resources in Consul Enterprise
This section describes how to create a token with read-only access to all resources in the Consul UI. This token allows users to view any resources without the ability to make changes. To create the ACL token, define a policy, create the policy, and then link the policy to a token.
Define a policy
You can send policy definitions as command line or API arguments or define them in an external HCL or JSON file. Refer to ACL Rules for details about all of the rules you can use in your policies.
The following example policy is defined in a file. The policy allows users that log in with the token to view all services and nodes in the catalog, all objects in the key-value store, all intentions, and all ACL resources in any namespace and any partition. The acl:read
permission does not allow viewing the token secret ids.
Register the policy with Consul
After defining the policies, you can register them with Consul using the command line or API endpoint.
Run the consul acl policy create
command and specify the policy rules to create a policy. The following example registers a policy defined in ui-view-all.hcl
.
You can specify an admin partition and namespace when creating policies in Consul Enterprise. The policy is only valid in the specified scopes. Because the policy grants cross-partition and cross-namespace access, the policy must be created in the default
partition and the default
namespace.
Refer to Consul ACL Policy Create for details about the consul acl policy create
command.
Link the policy to a token
After registering the policies into Consul, you can create and link tokens using the Consul command line or API endpoint. You can also enable Consul to dynamically create tokens from trusted external systems using an auth method.
Run the consul acl token create
command and specify the policy name or ID to create a token linked to the policy. Refer to Consul ACL Token Create for details about the consul acl token create
command.