Google SSO Integration
This page teaches you how to integrate Google Workspace (SAML 2.0) into your Amazon Cognito User Pool.
Google Workspace SSO Integration
Follow the information and steps below to let your Google Workspace users sign in to the CSS Console with SSO.
Set up Cognito
Capture the Cognito User Pool ID
In the AWS Console, navigate to the User Pool created by your application. It'll generally look like "CloudStorageSecUserPool-{appid}".
Copy the User Pool ID.

Create a Cognito Domain
In the User Pool, navigate to Domain and select 'Create Cognito Domain'.

Create the domain of your choice and copy the full domain (it should end in ...auth.{region}.amazoncognito.com).

Google: Create a custom SAML app
Add a new app
In the Google Admin console, navigate to Apps > Web and mobile apps. Select 'Add app' and then 'Add custom SAML app'.

Enter the app details
Enter an app name of your choice (for example, "CloudStorageSec Console"). Upload an app icon if you would like. Select 'Continue'.

Download the Google IdP metadata
On the 'Google Identity Provider details' page, select 'Download metadata' to download the GoogleIDPMetadata.xml file. You will upload this file to Cognito later. Select 'Continue'.

Enter the service provider details
Here's a chart for the items that must be entered in. After these values, select 'Continue'.
ACS URL
enter 'https://{cognito_domain_prefix}.auth.{your_region}.amazoncognito.com/saml2/idpresponse'. Refer back to the domain created in the 'Create a Cognito Domain' step.
https://css-demo.auth.us-west-2.amazoncognito.com/saml2/idpresponse
Entity ID
enter 'urn:amazon:cognito:sp:{userpoolid}'
urn:amazon:cognito:sp:us-west-2_abcd123
Name ID format
Name ID
Basic Information > Primary email
Basic Information > Primary email
Leave 'Start URL' empty and leave 'Signed response' unchecked.

Add the attribute mapping
On the 'Attribute mapping' page, select 'Add mapping' and enter the following:
Primary email
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress
Select 'Finish'.
Google: Turn on the app for your users
New custom SAML apps are turned OFF for everyone by default. Users will not be able to sign in until the app is turned on for them.
In Apps > Web and mobile apps, select the app you just created.
Select the 'User access' panel.
Select 'ON for everyone', or select the organizational unit or group that should have access and set the service status to 'ON'.
Select 'Save'.
AWS: Add Google as an Identity Provider
In the AWS Console:
Navigate back to your Cognito User Pool and select 'Social and external providers'.
Select 'Add identity provider' and select 'SAML'.

Enter a provider name, for example
GoogleWorkspace. Do not add spaces. This name is shown on the CSS Console sign-in button.

Under 'Metadata document source', select 'Upload metadata document' and upload the
GoogleIDPMetadata.xmlfile you downloaded from Google.Under 'Map attributes between your SAML provider and your user pool', add the following:
User pool attribute: email
SAML attribute: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress
Select 'Add identity provider'.

AWS: Configure the Cognito App Client
In Cognito, navigate to App Clients -> {your app client} and select 'Login pages'.

Select the 'Edit' button and enter in the following:
Allowed callback URLs: CSS Console URL
Allowed sign-out URLs: CSS Console URL
Identity Providers: the Google identity provider you just created and 'Cognito user pool'

OAuth 2.0 grant types: 'Authorization code grant', 'Implicit grant'
OpenID Connect scopes: 'OpenID', 'Email', 'Profile'
Select 'Save changes'.

CSS Console: Verify Changes
In the CSS Console:
View the sign-in page and note that a 'Sign In With GoogleWorkspace' button (or the provider name you chose) now appears.

CSS Console: Set SSO Defaults (Optional)
New users who sign in with SSO for the first time are automatically assigned a default role and group.
Log in as a user that has Admin permissions.
Go to Configuration -> Console Settings and scroll to 'SSO Defaults'.
Select the 'Default Role' and 'Default Group' for new SSO users and select 'Save'.

CSS Console: Set Up User
Click on the 'Sign In With GoogleWorkspace' button and sign in with your Google account. This will create the user in Cognito.
Log in as a user that has Admin permissions.
Go to Access Management -> Manage Users. There will be a new user created with the format {provider_name}_{google_user_email} in the Manage Users page.
(Optional) Click the 3 buttons next to the Status and choose 'Change Groups' to assign the user to a different group.
If the user is disabled, enable the user by clicking the button with 3 dots on the rightmost column and selecting 'Enable User'.
(Optional) Click the 3 buttons next to the Status and choose 'Change Role'. The user gets the default role from 'SSO Defaults' and can be adjusted to another role if needed.
Your user is now set up! Log out and click the SSO button. You are now logged in as the SSO user!
Troubleshooting
Google shows 'app_not_configured_for_user'
The app is not turned ON for this user. Review the 'Google: Turn on the app for your users' step, and allow time for the change to take effect.
Google shows 'Invalid ACS URL' or 'Invalid Entity ID'
The ACS URL or Entity ID in Google does not match Cognito. Confirm the Cognito domain and User Pool ID were entered exactly.
Cognito shows 'redirect_mismatch' after signing in
The Allowed callback URL in the Cognito App Client does not exactly match the CSS Console URL.
The user is created without an email
The 'Primary email' attribute mapping is missing in Google, or the email attribute mapping is missing in Cognito.
Last updated