Search code examples
amazon-web-servicesamazon-cognitofederated-identity

Sign-in page for AWS federated login


I volunteer at a small local school that teaches data science and I'm trying to understand the procedure behind federated logins, but the Amazon documentation isn't helping and their forums don't seem interested.

We'd like for the students to be able to sign in to our AWS environment using either Facebook, Google, or Amazon.com, instead of manually trying to create a user for everyone who signs up.

The main thing that's unclear is how the students should sign in. Do we need to create a custom webpage using the provided javascript or .net code? We would have to contact our web developer if so. Or do we use the provided domain name? (in this case, https://weclouddata.auth.us-east-1.amazoncognito.com) This comes from the Cognito user pools though, and doesn't seem like it would apply. Besides, when I use it in conjunction with the Google client ID, I get an "invalid request" error.


Solution

  • You can create a custom app "Identity Broker" to create a URL that lets users sign in with Facebook/Google credentials and securely access the AWS Management Console. The broker would perform the following steps:

    1. Verify that the user is authenticated by identity system(Facebook or Google) or use AWS Congnito.
    2. Call the AWS Security Token Service (AWS STS) API operations to obtain temporary security credentials for the user.
    3. Construct a URL for the console that includes the token and redirects the user to the URL on the user's behalf.

    Amazon Cognito lets you to easily create customizable UI to sign in users and provides built-in federation with Facebook, Google, Login with Amazon. So you don't have worry about authentication and concentrate building your actual logic(above steps)

    Here is a sample app from AWS that shows how to implement a single sign-on solution with C# and windows AD.

    Python Code: Here is the python code on how to construct the console login URL. I have used the sample python code from AWS and 'Hello world' flask app. When you hit the URL it should redirect to the console login, you can set permission using IAM role.