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

Update documentation for social authentication with Amazon Cognito #8557

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
65 changes: 47 additions & 18 deletions site/content/en/docs/enterprise/social-accounts-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,32 +106,61 @@ There are 2 basic steps to enable GitHub account authentication.
> but don't forget to add required permissions.
> <br>In the **Permission** > **Account permissions** > **Email addresses** must be set to **read-only**.

## Enable authentication with an Amazon Cognito

To enable authentication, do the following:

1. Create a user pool. For more information,
see [Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html)
2. Fill in the name field, set the homepage URL (for example: `https://localhost:8080`),
and authentication callback URL (for example: `https://localhost:8080/api/auth/social/amazon-cognito/login/callback/`).
3. Create conпiguration file in CVAT:

1. Create the `auth_config.yml` file with the following content:
## Enable Authentication with Amazon Cognito
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
## Enable Authentication with Amazon Cognito
## Enable authentication with Amazon Cognito

The other headings don't use title case.


To enable authentication with Amazon Cognito for your CVAT instance, you need to complete two main steps:

1. **Create and configure an [Amazon Cognito user pool](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html)**.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this is really the right approach here.

I would assume a sizable fraction of users who want to configure authentication via Cognito already have a pool there. The whole point of Cognito is to share users between multiple apps, so unless you're only starting to set up SSO and CVAT happens to be your first app, you would already have a pool.

Given this, perhaps it would be better to focus this section on configuring an existing pool, and add an optional extra step in front that tells people to create a new pool if they don't have one.

Follow these detailed steps to set up the user pool:
- Create a user pool. For example, you might use settings like those shown in the image below:
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to start in the middle. I would assume the first step would be "go to the AWS Management Console", then "click XXX to go to Cognito settings"...

Also, the steps should be in a numbered list, since they are sequential.

![](/images/cognito_pool_1.png)

- Configure a new app on the step `Integrate your app`:
- Select the `Confidential client` type, as CVAT securely stores
client secrets on the server side.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
client secrets on the server side.
client secrets on the server side.

(_Note_: the `Public client` type is also supported.)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why add this note? CVAT is a confidential client, Cognito supports confidential clients... there's no reason to configure it as a public client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CVAT is a confidential client, Cognito supports confidential clients...

I know, but there was such a situation when the customer configured a public client instead of a confidential one. I decided to mention that, but okay, I'll delete this mention.

- Enter a name for your app client.
- Choose the `Generate a client secret` option.
![](/images/cognito_pool_2.png)

- Once your pool is configured, go to the `App integration` tab
on the pool details page and then to the `Domain` section.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
on the pool details page and then to the `Domain` section.
on the pool details page and then to the `Domain` section.

Create either a custom domain or Cognito domain (e.g., `https://cvat.auth.us-east-1.amazoncognito.com`).
Copy link
Contributor

Choose a reason for hiding this comment

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

cvat is probably not the best suggestion here, as a) we shouldn't assume the pool is just for CVAT (if it is, why use Cognito at all?), and b) the name has to be unique within the region, so different organizations would need to use different names. I would replace cvat with a placeholder like <my_org>. Or just stick with custom-cognito-prefix, like in the config below.

Copy this domain as you'll need it later when configuring the `auth_config.yml` file for CVAT.

- Scroll down to the `App client list` section, find the app you created, and open its settings.
Edit the `Hosted UI` settings:
- `Allowed callback URLs`: add a callback URL (`<http|https>://<cvat_domain>/api/auth/social/amazon-cognito/login/callback/`)
- `Identity providers`: select `Cognito user pool`
- `OAuth 2.0 grant types`: select `Authorization code grant`
- `OpenID Connect scopes`: select the following scopes: `OpenID`, `Profile`, `Email`
![](/images/cognito_pool_3.png)

2. **Configure social authentication in CVAT**:
- Create the `auth_config.yml` file in CVAT with the following content:

```yaml
---
social_account:
enabled: true
amazon_cognito:
client_id: <some_client_id>
client_secret: <some_client_secret>
domain: https://<domain-prefix>.auth.us-east-1.amazoncognito.com
client_id: <client_id>
client_secret: <client_secret>
domain: <custom-domain> or
https://<custom-cognito-prefix>.auth.us-east-1.amazoncognito.com
```
The client_id and client_secret can be found on the app details page,
while the domain value can be found on the pool details page.

2. Set `AUTH_CONFIG_PATH="<path_to_auth_config>` environment variable.

3. In a terminal, run the following command:
- Set the required environment variables:

```bash
docker compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.override.yml up -d --build
export AUTH_CONFIG_PATH="<path_to_auth_config>"
export CVAT_HOST="<cvat_host>"
# schema: http|https, CVAT_PORT is optional
export CVAT_BASE_URL="<SCHEMA>://${CVAT_HOST}:<CVAT_PORT>"
Comment on lines +160 to +161
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# schema: http|https, CVAT_PORT is optional
export CVAT_BASE_URL="<SCHEMA>://${CVAT_HOST}:<CVAT_PORT>"
# cvat_port is optional
export CVAT_BASE_URL="<http|https>://${CVAT_HOST}:<cvat_port>"

The other placeholders are lowercase, so cvat_port ought to be too.

```

Start the CVAT enterprise instance as usual.
That's it! On the CVAT login page, you should now see the option `Continue with Amazon Cognito`.
![](/images/login_page_with_amazon_cognito.png)
Binary file added site/content/en/images/cognito_pool_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added site/content/en/images/cognito_pool_2.png
Copy link
Contributor

Choose a reason for hiding this comment

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

"CVAT" would make more sense as the client name.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added site/content/en/images/cognito_pool_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading