Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cookie auth to C8 REST API #4455

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,30 @@ A successful response includes [information about the cluster](/apis-tools/camun
## Token expiration

Access tokens expire according to the `expires_in` property of a successful authentication response. After this duration, in seconds, you must request a new access token.

## Authentication via cookie (Self-Managed only)

:::note
When authenticating via cookie, note that Cross-Site Request Forgery (CSRF) protection must be disabled to allow this method of authentication. In a Camunda Self-Managed cluster, set the following configuration properties:

```sh
CAMUNDA_REST_QUERY_ENABLED=true
CAMUNDA_OPERATE_CSRFPREVENTIONENABLED=false
CAMUNDA_TASKLIST_CSRFPREVENTIONENABLED=false
```

:::

Another way to access the Camunda 8 REST API in a Self-Managed cluster is to send cookie headers in each request. The cookie can be obtained by using the API endpoint `/api/login`. Take the following steps:

1. Log in as user 'demo' and store the cookie in the file `cookie.txt`:

```shell
curl -c cookie.txt -X POST 'http://localhost:8080/api/login?username=demo&password=demo'
```

2. Send the cookie (as a header) in each API request. In this case, request all process definitions:

```shell
curl -b cookie.txt -X POST 'http://localhost:8080/v2/user-task/search' -H 'Content-Type: application/json' -d '{}'
```
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,30 @@ A successful response includes [information about the cluster](/apis-tools/camun
## Token expiration

Access tokens expire according to the `expires_in` property of a successful authentication response. After this duration, in seconds, you must request a new access token.

## Authentication via cookie (Self-Managed only)

:::note
When authenticating via cookie, note that Cross-Site Request Forgery (CSRF) protection must be disabled to allow this method of authentication. In a Camunda Self-Managed cluster, set the following configuration properties:

```sh
CAMUNDA_REST_QUERY_ENABLED=true
CAMUNDA_OPERATE_CSRFPREVENTIONENABLED=false
CAMUNDA_TASKLIST_CSRFPREVENTIONENABLED=false
```

:::

Another way to access the Camunda 8 REST API in a Self-Managed cluster is to send cookie headers in each request. The cookie can be obtained by using the API endpoint `/api/login`. Take the following steps:

1. Log in as user 'demo' and store the cookie in the file `cookie.txt`:

```shell
curl -c cookie.txt -X POST 'http://localhost:8080/api/login?username=demo&password=demo'
```

2. Send the cookie (as a header) in each API request. In this case, request all process definitions:

```shell
curl -b cookie.txt -X POST 'http://localhost:8080/v2/user-task/search' -H 'Content-Type: application/json' -d '{}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could replace it with the topology endpoint - to use non-alpha endpoint

```
Loading