-
Notifications
You must be signed in to change notification settings - Fork 105
docs: Add Amazon Cognito as tested provider #414
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
48aeb9f
Add Amazon Cognito as tested provider
Foorack ed9e709
Update photos and Cognito docs
Foorack cac1646
Minor Cognito docs fixes
Foorack 6a22fb0
Merge branch 'main' into docs-cognito
EthanHeilman a176a2b
Merge branch 'main' into docs-cognito
EthanHeilman 5310f93
Restore azure.md
Foorack 12745e9
Update docs/providers/cognito.md
Foorack 6490808
Copilot's warning was too aggressive
Foorack eab3bca
Update README.md
Foorack dc43715
Update README.md
Foorack 55340e3
Merge branch 'main' into docs-cognito
Foorack a9db99f
Merge branch 'main' into docs-cognito
EthanHeilman ff3b71f
Update section regarding Groups
Foorack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| # Configuring Amazon Cognito for OPKSSH | ||
|
|
||
| Setting up Amazon Cognito with OPKSSH is simple and should not take more than 10 minutes. | ||
| To make this process as straightforward as possible we provide this guide. | ||
|
|
||
| **Something not working?** Open a new issue on <https://github.com/openpubkey/opkssh> | ||
|
|
||
| This guide is divided into two sections depending on if you have an existing Cognito User Pool or not. | ||
|
|
||
| - [**Setup without existing User Pool**](#setup-without-existing-user-pool) | ||
| - [**Setup with existing User Pool**](#setup-with-existing-user-pool) | ||
|
|
||
| Afterwards both sections converge at [**Modifying the App**](#modifying-the-app) where you will modify the app to add redirect URIs required by OPKSSH. | ||
|
|
||
| ## Setup without existing User Pool | ||
|
|
||
| ### 1. Create the User Pool | ||
|
|
||
| If you do not have an existing Cognito User Pool you can create one quickly by following these steps: | ||
|
|
||
| Start by going to [Amazon Cognito](https://us-east-1.console.aws.amazon.com/cognito/v2/idp/user-pools) and click `"Create user pool"`. | ||
|
|
||
| The name you specify will be the name of the Application, **not** the User Pool. Use a name like `"OPKSSH"`. | ||
|
|
||
| > [!WARNING] | ||
| > | ||
| > Make sure you select `"Single Page Application (SPA)"`, otherwise AWS will create a Client Secret. | ||
|
|
||
| > [!TIP] | ||
| > | ||
| > Check you are in the correct AWS region. | ||
|
|
||
|  | ||
|
|
||
| Decide options for sign-in identifiers and required attributes for signup, as they can never be changed later. We will setup return_uri's later. | ||
|
|
||
| Once ready click `"Create user directory"`. | ||
|
|
||
| ### 2. Navigate to the App | ||
|
|
||
| Once the User Pool is created you will be taken to a Success page. Go to the bottom and click `"Go to overview"`. At this point you should see something like this: | ||
|
|
||
|  | ||
|
|
||
| > [!TIP] | ||
| > | ||
| > At this point you should rename your User Pool to something more meaningful like `"Datacenter Team"`. | ||
|
|
||
| Jump to the section [**Modifying the App**](#modifying-the-app) to continue the setup. | ||
|
|
||
| ## Setup with existing User Pool | ||
|
|
||
| If you already have an existing User Pool, navigate to `"App clients"` section and click `"Create app client"`. | ||
|
|
||
| Enter a name of the application, like `"OPKSSH"`. **Remember to select `"Single Page Application (SPA)"`**. | ||
|
|
||
|  | ||
|
|
||
| We will setup return_uri's later. Once ready click `"Create app client"`. | ||
|
|
||
| > [!WARNING] | ||
| > | ||
| > Make sure you select `"Single Page Application (SPA)"`, otherwise AWS will create a Client Secret. | ||
|
|
||
| ## Modifying the App | ||
|
|
||
| Inside your User Pool, click on `"App clients"` in the left-hand menu. | ||
|
|
||
| You should see the App you created earlier. Click on the App name. | ||
|
|
||
|  | ||
|
|
||
| ### 1. Edit Login Info | ||
|
|
||
| In the navigation bar in the middle of the screen, click `"Login pages"` and then `"Edit"`. | ||
|
|
||
| Under `"Allowed callback URLs"` section, click the `"Add another URL"` button twice, and then make sure all 3 of the following URLs are present: | ||
|
|
||
| ``` | ||
| http://localhost:3000/login-callback | ||
| http://localhost:10001/login-callback | ||
| http://localhost:11110/login-callback | ||
| ``` | ||
|
|
||
|  | ||
|
|
||
| You also **MUST** edit the `"OpenID Connect Scopes"` section by removing **Phone** and adding **Profile**: | ||
|
|
||
| **OLD:** | ||
|
|
||
|  | ||
|
|
||
| **NEW:** | ||
|
|
||
|  | ||
|
|
||
| Click `"Save Changes"`. | ||
|
|
||
| ### 2. Add a Managed Login page | ||
|
|
||
| If you go to the App > `"Login pages"` > `"Managed login style"` section, you can see if the App has a managed login page or not. | ||
|
|
||
|  | ||
|
|
||
| If you only see a `"-"` under `"Managed login style"`, you need to create one. Go to `"Managed login"` on the left-hand sidebar, under `"Styles"` click `"Create a new style"`. Select your app and click `"Create"`. | ||
|
|
||
|  | ||
|
|
||
| Your app should now be ready. | ||
|
|
||
| ### Configure OPKSSH | ||
|
|
||
| For each server you have installed opkssh on, edit the file `/etc/opk/providers` and set the Cognito provider to the client ID and tenant ID you just registered. | ||
|
|
||
| > [!WARNING] | ||
| > | ||
| > **ATTENTION!** Do **NOT** specify your managed login domain if you have a custom domain. You must specify the IDP endpoint which is of the form: | ||
|
|
||
| ``` | ||
| https://cognito-idp.<aws-region>.amazonaws.com/<user-pool-id> <CLIENT-ID> 12h | ||
| ``` | ||
|
|
||
| To test run `opkssh login --provider="https://cognito-idp.us-east-1.amazonaws.com/us-east-1_xxxxxxxxx,<CLIENT-ID>"` with the User Pool ID and Client ID you registered. If this works then the App has been setup correctly. | ||
|
|
||
| On the client check to see if you have already created a config at `~/.opk/config.yml`. If no config if found, create a config by running `opkssh login --create-config`. | ||
|
|
||
| Then edit `~/.opk/config.yml` and add an entry for Cognito to use the User Pool and Client ID from the App Registration. | ||
|
|
||
| ```yaml | ||
| - alias: cognito | ||
| issuer: https://cognito-idp.<aws-region>.amazonaws.com/<user-pool-id> | ||
| client_id: <CLIENT-ID> | ||
| scopes: openid profile email | ||
| access_type: offline | ||
| prompt: consent | ||
| redirect_uris: | ||
| - http://localhost:3000/login-callback | ||
| - http://localhost:10001/login-callback | ||
| - http://localhost:11110/login-callback | ||
| ``` | ||
|
|
||
| For more information see: [opkssh configuration files](https://github.com/openpubkey/opkssh/blob/main/docs/config.md). | ||
|
|
||
| ### 3. Test | ||
|
|
||
| Then run `opkssh login` or `opkssh login cognito` on the client. | ||
| This should run without error. | ||
|
|
||
| ## Troubleshooting (Common Issues) | ||
|
|
||
| ### Error message: failed to exchange token: oauth2: "invalid_client" "invalid_client_secret" | ||
|
|
||
| This occurs if you (accidentally) created the App so that it has a Client Secret. There is no way to fix this. Go to `"App clients"` and delete the App. Then recreate it making sure to select `"Single Page Application (SPA)"`. Follow the [Setup with existing User Pool](#setup-with-existing-user-pool) section again. | ||
|
|
||
| ### Error message: 403 Forbidden: You don't have permission to access this resource | ||
|
|
||
| This can occur if you have a WAF which is enforcing the `"AWSManagedRulesCommonRuleSet"` rule group. Add an exception for `"EC2MetaDataSSRF_QUERYARGUMENTS"` to your WAF rules. | ||
|
|
||
| Terraform/OpenTofu example: | ||
|
|
||
| ```hcl | ||
| # Exclude EC2MetaDataSSRF_QUERYARGUMENTS for Cognito OAuth2 flows | ||
| rule_action_override { | ||
| name = "EC2MetaDataSSRF_QUERYARGUMENTS" | ||
| action_to_use { | ||
| count {} | ||
| } | ||
|
Foorack marked this conversation as resolved.
Outdated
|
||
| } | ||
| ``` | ||
|
|
||
| ### OPKSSH not seeing Cognito groups | ||
|
|
||
| This is completely untested. Please test and amend this section. | ||
|
Foorack marked this conversation as resolved.
Outdated
|
||
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
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
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
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.