Consul Logout
Command: consul logout
Corresponding HTTP API Endpoint: [POST] /v1/acl/logout
The logout command will destroy the provided token if it was created from
consul login.
If you created the token with consul login -type=oidc and identity provider
logout is available, the command also prints the identity provider logout URL
so that you can end the provider session. The command reads the URL from the
.oidc-logout file that consul login saves next to the token sink file, so
pass that token file with the -token-file flag or the CONSUL_HTTP_TOKEN_FILE
environment variable. If you pass the token with the -token flag or only the
CONSUL_HTTP_TOKEN environment variable, the command destroys the token but
does not print the URL. The URL contains your ID token, so treat the command
output, and any logs that capture it, as sensitive. Refer to
OIDC logout for details.
Identity provider logout is available in Consul 1.21.19 and later.
The table below shows this command's required ACLs. Configuration of blocking queries and agent caching are not supported from commands, but may be from the corresponding HTTP endpoint.
| ACL Required |
|---|
none |
Usage
Usage: consul logout [options]
The token to delete should be specified with the -token argument, the
CONSUL_HTTP_TOKEN environment variable, the -token-file argument, or the
CONSUL_HTTP_TOKEN_FILE environment variable.
Command Options
-open-browser- Also open the identity provider logout URL in your default browser. Applies only to tokens created byconsul login -type=oidcwhen identity provider logout is available. Consul prints the URL whether or not you set this option. Do not use this option in non-interactive environments, such as CI pipelines. You can also set this option with theCONSUL_LOGOUT_OPEN_BROWSERenvironment variable. The flag takes precedence over the environment variable. Defaults tofalse. Added in v1.21.19.
API Options
-ca-file=<value>- Path to a CA file to use for TLS when communicating with Consul. This can also be specified via theCONSUL_CACERTenvironment variable.-ca-path=<value>- Path to a directory of CA certificates to use for TLS when communicating with Consul. This can also be specified via theCONSUL_CAPATHenvironment variable.-client-cert=<value>- Path to a client cert file to use for TLS whenverify_incomingis enabled. This can also be specified via theCONSUL_CLIENT_CERTenvironment variable.-client-key=<value>- Path to a client key file to use for TLS whenverify_incomingis enabled. This can also be specified via theCONSUL_CLIENT_KEYenvironment variable.-http-addr=<addr>- Address of the Consul agent with the port. This can be an IP address or DNS address, but it must include the port. This can also be specified via theCONSUL_HTTP_ADDRenvironment variable. In Consul 0.8 and later, the default value is http://127.0.0.1:8500, and https can optionally be used instead. The scheme can also be set to HTTPS by setting the environment variableCONSUL_HTTP_SSL=true. This may be a unix domain socket usingunix:///path/to/socketif the agent is configured to listen that way.-tls-server-name=<value>- The server name to use as the SNI host when connecting via TLS. This can also be specified via theCONSUL_TLS_SERVER_NAMEenvironment variable.-token=<value>- ACL token to use in the request. This can also be specified via theCONSUL_HTTP_TOKENenvironment variable. If unspecified, the query will default to the token of the Consul agent at the HTTP address.-token-file=<value>- File containing the ACL token to use in the request instead of one specified via the-tokenargument orCONSUL_HTTP_TOKENenvironment variable. This can also be specified via theCONSUL_HTTP_TOKEN_FILEenvironment variable.
Examples
Logout and delete a login token.
$ consul logout -token-file 'consul.token'
Log out, delete a login token created with an OIDC auth method, and open the identity provider logout URL in your default browser:
$ consul logout -token-file 'consul.token' -open-browser