Cross-domain SSO with Google into AWS Console using SAML

17 / Dec / 2015 by Navjot Singh 3 comments

Recently, I worked on a task wherein the users had to be authenticated based on existing Google credentials to get access of AWS Management Console. It took more time than expected to make it work as the documentation provided by Google is not complete. Let’s start by setting this up step by step.

finl

Scenario:

Provide access of AWS Management console to already existing Google users. Let’s say the users belong to “singhnavjot.com” domain.

We will use SAML 2.0 protocol to pass information of Google user to Amazon’s AWS. Here, Google is our SAML Authority or Identity Provider and Amazon’s AWS is SAML consumer or Service Provider.

Let’s configure it to provide access to a user whose email id is “navjot@singhnavjot.com”.

  1. Login into the Google’s admin console with the admin user. Once the below screen appears, click on “Apps”:AdminConsole1
  2. Click on “SAML apps”:
    appstab
  3. Click on “Add a service/App to your domain”:
    1
  4. Select “Amazon Web Services” from the list and click next:
    2
  5. Download the “IDP metadata” file. We need to upload this file in AWS console while creating Identity provider. Click next:
    3
  6. AWS Management console’s settings: Login into AWS management console, go to IAM console and click “Identity Providers” present on the left pane:
    AWS1
  7. Click on “Create Provider” and choose provider type as “SAML” from the drop down list:
    AWS2
  8. Two fields will appear on the screen upon selecting “SAML”: “Provider Name” and “Metadata Document”:
    Provide any name in the “Provider Name” field (say GoogleApp).
    Upload the document downloaded in step 5 in the “Metadata Document”
    AWS3
  9. Click “Next Step” present at the bottom right corner. Details verification page will appear. Save the “Provider ARN” as we will use it later. Save the Verify the information and click “Create” present at the bottom right corner:
    AWS4
  10. We have created the Identity provider successfully. Now, we need to a define access permission for this Identity provider. This can be done creating “Role” in AWS.
  11. Go to “Roles” in IAM console and click “Create Role”:
    AWS5
  12. Provide any name to the role (say GoogleAppRole) and click “Next Step” at the bottom right corner:
    AWS6
  13. Select “Role for Identity Provider Access” and then click “Select against “Grant Web Single Sign-On (WebSSO) access to SAML providers”:
    AWS7
  14. Select “SAML Provider” which we have created in step 9 from the drop-down list and click “Next Step”:
    AWS8
  15. “Policy Document” will appear. Change it as per the requirement otherwise, this would work for us. Click “Next Step”.
  16. Select the policy from the list. We are selecting “ReadOnlyAccess” to provide our users who will use google credentials to login into AWS console a read-only access. Click “Next Step” to move to the verification page. Save the “Role ARN” as we will use it later.
  17. Click “Create Role” at the bottom right corner.
    We have completed our AWS configuration.
  18. We will now move back to the Google Admin Console which we have left in step 5 where we have downloaded the IDP metadata. Click next.
  19. Provide any name to your SAML application (say AWS) and any description in the description box. A logo can be uploaded. It is optional. Click next:
    4
  20. Keep the ACS URL and Entity URL field intact. Keep the “Start URL” empty and “Signed Response” check box unchecked. In the “Name ID” field, select “Basic Information” and “Primary email” from the drop down list and click next:
    5
  21. In next step, we have two fields: “https://aws.amazon.com/SAML/Attributes/RoleSessionName” and “https://aws.amazon.com/SAML/Attributes/Role”. Choose anything against the fields present against them as we have to update it later. Click finish:
    6
  22. We have not told google about the role and Identity provider ARN that it will use. For this, we need to add a custom field using google SDK API and API explorer in the Google App which would take Role and Identity Provider ARN. Google App will use these details to communicate with AWS.
  23. We will add one user into the app and provide it the access to use the AWS console using the provided AWS role.
  24. First we need to get the customer id using directory.users.get API.
  25. Go to API explorer and click on the “directory.users.get” API in API explorer and fill your email id in the field “userKey” as shown below. Keep the other fields empty and click authorize and execute. Make sure we have admin permission:
    7
  26. We will get 200 OK response with some information in the response. We can get “customerId” from the response.
  27. Now, go to API “directory.schemas.insert and fill the customerId against the “customerId” field. Add the request body as shown below and hit execute and we will get 200 OK response. We have added a custom schema in our google app so that app can interpret the information that we will provide in the next step:
    8
    9
  28. Now, we are adding the AWS-related information in the fields using API directory.users.update.
  29. Go to the API and fill your email id again “userKey” filed and role ARN and identity provider ARN as shown below and hit execute which should return 200 OK response. We are adding user and specifying Provider and Role ARNs which we have saved while working on AWS console. So, for every user, we can use either same or different Provider and Role ARN. The ARN specified below are comma separated:
    10
  30. Now, we have added new custom schema and populated the fields. If we have only a few users then these steps can be repeated for all users.
  31. Now, go back to the google samSAMLl app and edit attribute mapping as follows and hit save:                    AWS10
  32. Now, we need to enable this app for users as follows:
  33. That’s all we need to do configure in the Google admin console.
  34. We can launch the app from the highlighted icons present at the top right side of the screen:
    14

Upon launching the App we will be redirected to the AWS management console having ReadOnlyAccess. Similarly, different access permission can to granted to different users by assigning separate to the users.

FOUND THIS USEFUL? SHARE IT

comments (3)

    1. aureli

      On step 29, you can add as my accounts and roles as you want per user by adding:
      ,{
      “value”: “arn:aws:iam::RootAccountNumber:role/gAwsRole,rn:aws:iam::RootAccountNumber:saml-provider/ProviderName”,
      “customType”: “RoleDescription”
      }

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *