> For the complete documentation index, see [llms.txt](https://docs.rierino.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rierino.com/devops/api-event-and-process-flows/configuring-saga-steps/event-step/gateway-actions/authenticate.md).

# Authenticate

These actions provide ability to authenticate users and manage user access as part of gateway functionality.

## Authenticate Actions

### Register

Registers a user with provided credentials and returns the new user's id, if the handler allows user registration.

| Field          | Definition                                         | Example | Default |
| -------------- | -------------------------------------------------- | ------- | ------- |
| Input Element  | Json path for the input in event payload           | auth    | -       |
| Output Element | Json path for the output in response event payload | $.user  | -       |

Registration details can be provided in the payload input element or in request metadata auth.

<details>

<summary>Example</summary>

Input

```json
{
    "auth": {
        "username": "user",
        "password": "pass"
    }
}
```

Event Metadata

![](https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FCdeKh0wn0waEpRW3GzOA%2Fimage.png?alt=media\&token=7b698341-4d87-4850-b8ab-24a76c082480)

</details>

### Login

Logs in a user with credentials and returns tokens, and optionally user details.

| Field                     | Definition                                                          | Example            | Default                                              |
| ------------------------- | ------------------------------------------------------------------- | ------------------ | ---------------------------------------------------- |
| Input Element             | Json path for the input in event payload                            | auth               | -                                                    |
| Output Element            | Json path for the output in response event payload                  | $.token            | -                                                    |
| parameters.resolve        | Whether access token should be resolved to also return user details | true               | false                                                |
| parameters.resolvePattern | JMESPath expression for resolving token contents if resolve is true | {"access": access} | {"user": {"id": access.sub, "roles": access.roles} } |

<details>

<summary>Example</summary>

Input

```json
{
    "auth": {
        "username": "user",
        "password": "pass"
    }
}
```

Event Metadata

![](https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FWCSXrvvOyLdg0vocfYxe%2Fimage.png?alt=media\&token=23c873f1-8af2-4070-80cc-6380f68edc89)

</details>

### Validate

Validates and resolves a user with provided tokens and returns user details.

| Field                     | Definition                                                  | Example            | Default                                              |
| ------------------------- | ----------------------------------------------------------- | ------------------ | ---------------------------------------------------- |
| Input Element             | Json path for the input in event payload                    | auth               | -                                                    |
| Output Element            | Json path for the output in response event payload          | $.user             | -                                                    |
| parameters.resolvePattern | JMESPath expression for resolving token contents for output | {"access": access} | {"user": {"id": access.sub, "roles": access.roles} } |

### Resolve

Provides the same functionality and uses the same parameters as `Validate`.

### Refresh

Refreshes tokens with a provided refresh token and returns new tokens, and optionally user details.

| Field                     | Definition                                                               | Example            | Default                                              |
| ------------------------- | ------------------------------------------------------------------------ | ------------------ | ---------------------------------------------------- |
| Input Element             | Json path for the input in event payload                                 | auth               | -                                                    |
| Output Element            | Json path for the output in response event payload                       | $.user             | -                                                    |
| parameters.resolve        | Whether access token should be resolved to also return user id and roles | true               | false                                                |
| parameters.resolvePattern | JMESPath expression for resolving token contents if resolve is true      | {"access": access} | {"user": {"id": access.sub, "roles": access.roles} } |

### Logout

Logs out a user with the provided access token.

| Field         | Definition                               | Example | Default |
| ------------- | ---------------------------------------- | ------- | ------- |
| Input Element | Json path for the input in event payload | auth    | -       |

### ResolveKey

Resolves a given API key and returns resolved contents in output.

| Field                     | Definition                                                                            | Example                                        | Default                                                                      |
| ------------------------- | ------------------------------------------------------------------------------------- | ---------------------------------------------- | ---------------------------------------------------------------------------- |
| Input Element             | Json path for the `api_key` input in event payload, or can be passed in auth metadata | auth                                           | -                                                                            |
| Output                    | Json path for the output in response event payload                                    | $.user                                         | -                                                                            |
| parameters.resolvePattern | JMESPath pattern for converting `{user,key}` data in output                           | {"user": {"id": key.id, "roles": key.roles } } | {"user": {"id": key.id, "roles": intersect(user.access.roles, key.roles) } } |

### UserRegister

Registers a new user with given profile and credential details and returns the created user's id as `user_id`.

| Field         | Definition                               | Example | Default |
| ------------- | ---------------------------------------- | ------- | ------- |
| Input Element | Json path for the input in event payload | auth    | -       |

### UserList

Lists current users with profile and access details.

| Field            | Definition                                | Example         | Default |
| ---------------- | ----------------------------------------- | --------------- | ------- |
| Input Element    | Json path for the input in event payload  | parameters      | -       |
| Output Element   | Json path for the output in event payload | $.users         | -       |
| Output Pattern   | JMESPath pattern for list of users        | {userList:list} | -       |
| parameters.skip  | Number of records to skip                 | 10              | -       |
| parameters.limit | Max number of records to return           | 10              | -       |

### UserGet

Returns profile and access details of a user with the given id.

| Field          | Definition                                | Example  | Default |
| -------------- | ----------------------------------------- | -------- | ------- |
| Input Element  | Json path for the input in event payload  | user     | -       |
| Output Element | Json path for the output in event payload | $.result | -       |
| Output Pattern | JMESPath pattern for returned user        | {user:@} | -       |

### UserDelete

Deletes the user with the given id from records.

| Field         | Definition                                       | Example  | Default |
| ------------- | ------------------------------------------------ | -------- | ------- |
| Input Element | Json path for the input in event payload with id | user     | -       |
| idPath        | Json path for the id field in input element      | username | id      |

### UserLogout

Logs out the user with the given id.

| Field         | Definition                                       | Example  | Default |
| ------------- | ------------------------------------------------ | -------- | ------- |
| Input Element | Json path for the input in event payload with id | user     | -       |
| idPath        | Json path for the id field in input element      | username | id      |

### UserSetProfile

Sets profile details of a given user id.

| Field         | Definition                                               | Example                           | Default |
| ------------- | -------------------------------------------------------- | --------------------------------- | ------- |
| Input Element | Json path for the input in event payload                 | user                              | -       |
| Input Pattern | JMESPath pattern for converting input into a user record | {id:id, data: {profile: profile}} | -       |

### UserSetCredential

Sets credential details of a given user id.

| Field         | Definition                                               | Example                                 | Default |
| ------------- | -------------------------------------------------------- | --------------------------------------- | ------- |
| Input Element | Json path for the input in event payload                 | user                                    | -       |
| Input Pattern | JMESPath pattern for converting input into a user record | {id:id, data: {credential: credential}} | -       |

### UserSetAccess

Sets access details of a given user id.

| Field         | Definition                                               | Example                         | Default |
| ------------- | -------------------------------------------------------- | ------------------------------- | ------- |
| Input Element | Json path for the input in event payload                 | user                            | -       |
| Input Pattern | JMESPath pattern for converting input into a user record | {id:id, data: {access: access}} | -       |

### UserCreateKey

Creates an API key for the given user id with the given access details.

| Field         | Definition                                               | Example                         | Default |
| ------------- | -------------------------------------------------------- | ------------------------------- | ------- |
| Input Element | Json path for the input in event payload                 | user                            | -       |
| Input Pattern | JMESPath pattern for converting input into a user record | {id:id, data: {access: access}} | -       |


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rierino.com/devops/api-event-and-process-flows/configuring-saga-steps/event-step/gateway-actions/authenticate.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
