> For the complete documentation index, see [llms.txt](https://hawkins.gitbook.io/consoleme/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hawkins.gitbook.io/consoleme/configuration/cli-authentication.md).

# CLI Authentication

ConsoleMe's CLI ([Weep](https://github.com/Netflix/weep)) authenticates to the ConsoleMe backend through one of two methods: Mutual TLS (This is currently not supported in the open source code), or standalone challenge authentication response.

The challenge authentication flow is as follows:

1. Client sends a GET request to ConsoleMe's unauthenticated challenge endpoint. The server generates and stores a temporary token for the authentication request. A token is scoped to the username sent in the request and expires after a couple of minutes. ConsoleMe tells the client where the user should authenticate it in their browser (`challenge_url`), and where to poll (`polling_url`).
2. Client starts polling the unauthenticated **polling\_url** every couple of seconds until the token expires after a couple of minutes.
3. The user is redirected to the **Challenge Validator** endpoint, which will authenticate them. After they've been successfully authenticated, the ConsoleMe backend will mark the user's request as successful in its cache.
4. After the user has authenticated, the client (which is polling the `challenge_poller` endpoint every couple of seconds) should receive a success status with the super secret encoded JWT that it can use to authenticate the user for credential requests to ConsoleMe.

## Challenge Generator

<mark style="color:blue;">`GET`</mark> `https://consoleme.example.com/noauth/v1/challenge:generator/:userName`

Client requests a challenge URL to authenticate a user.

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | string |             |

{% tabs %}
{% tab title="200 " %}

```
{
  "challenge_url": "https://consoleme.example.com/challenge_validator/f82e6492-36a3-477d-9dab-98df1a0753a3",
  "polling_url": "https://consoleme.example.com/noauth/v1/challenge_poller/f82e6492-36a3-477d-9dab-98df1a0753a3"
}
```

{% endtab %}
{% endtabs %}

## Challenge Poller

<mark style="color:blue;">`GET`</mark> `https://consoleme.example.com/noauth/v1/challenge:poller/:challengeToken`

Endpoint that the CLI polls every few seconds to determine if the user has successfully authenticated. While the challenge is pending, `status` is the only attribute returned in the response. Once the user has successfully authenticated to the Challenge Validator endpoint, `status` will be updated, and the rest of the attributes will be returned in the next response.

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | string |             |

{% tabs %}
{% tab title="200 " %}

```
{
    "status": "pending|success",
    "cookie_name": "consoleme_auth",
    "expiration": 1604524944,
    "encoded_jwt": "eyJ0eXAi....",
    "user": "user@example.com"
}
```

{% endtab %}
{% endtabs %}

## Challenge Validator

<mark style="color:blue;">`GET`</mark> `https://consoleme.example.com/challenge:validator/:challengeToken`

Endpoint that user visits in their browser to authenticate to ConsoleMe through SSO.

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | string |             |

{% tabs %}
{% tab title="200 " %}

```
You've successfully authenticated to ConsoleMe and may now close this page.
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hawkins.gitbook.io/consoleme/configuration/cli-authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
