Skip to content

How to pre-fill email address in external IdP login page (eg. Microsoft Entra ID) when Users Authenticate via AWS Cognito

0

Hello AWS Community,

I’m integrating AWS Cognito with an external SAML Identity Provider (IdP), specifically Microsoft Entra ID (Azure AD).

My goal is to pre-fill the email address in the Microsoft login page when users authenticate via Cognito.

What I Have Tried

I attempted to pass login_hint and email_address as query parameters in the Cognito login request, as shown below:

https://your-domain.auth.<region>.amazoncognito.com/login
    ?client_id=<your-app-client-id>
    &response_type=code
    &scope=openid
    &redirect_uri=https://your-app.com/callback
    &identity_provider=<SAML-IdP-Name>
    &login_hint=user-email-address
    &email_address=user-email-address

However, AWS Cognito does not modify the SAML request to include these parameters. When I inspect the SAML HTTP redirect request generated by Cognito, it does not contain login_hint or email_address, which prevents Microsoft Entra ID from pre-filling the email field.

Observed Behavior

Here’s an example of the SAML request Cognito generates (without login_hint or email_address):

https://login.microsoftonline.com/1ecf169d-7912-428e123/saml2?
SAMLRequest=<encoded_data>
&RelayState=<encoded_data>
&SigAlg=<signature_algorithm>
&Signature=<signature>

However, when I manually add login_hint in the SAML request, Microsoft Entra ID correctly pre-fills the email field:

https://login.microsoftonline.com/1ecf169d-7912-428e123/saml2?
SAMLRequest=<encoded_data>
&RelayState=<encoded_data>
&login_hint=user-email-address
&email_address=user-email-address
&SigAlg=<signature_algorithm>
&Signature=<signature>

Questions

Is there any way where I can pre-fill the email address in the Microsoft login page when users authenticate via Cognito.?

How can I ensure AWS Cognito includes login_hint in the SAML request sent to Microsoft Entra ID so that the email field is pre-filled?

Does AWS Cognito support modifying the SAML request to include custom parameters?

Thanks in advance

asked 2 years ago499 views

1 Answer
0

Unfortunately, AWS Cognito does not currently support passing custom parameters like login_hint or email_address to external SAML Identity Providers such as Microsoft Entra ID (Azure AD) in a way that would pre-fill the email address on the external login page.

While Cognito does support the login_hint parameter for its own managed login interface and for some OIDC providers, this functionality is not extended to SAML providers. When Cognito generates the SAML request to the external IdP, it does not modify the request to include additional parameters like login_hint or email_address.

There are a few things to note:

  1. The login_hint parameter, when used with Cognito's authorization endpoint, only affects Cognito's managed login interface. It doesn't get forwarded to SAML IdPs.

  2. Cognito doesn't currently allow customization of the SAML request it sends to external IdPs. This means you can't add custom parameters to the request that Cognito generates.

  3. While some IdPs (like Microsoft Entra ID) support pre-filling email addresses using parameters like login_hint, Cognito doesn't provide a built-in way to leverage this feature when using SAML federation.

As a workaround, you might consider implementing a custom solution where you first redirect users to your own intermediate page. This page could collect the email address and then redirect to the appropriate IdP with the necessary parameters. However, this approach would bypass Cognito's built-in SAML flow and require additional development and maintenance.

For now, the best practice is to implement service-provider-initiated (SP-initiated) sign-in to your user pool, where Amazon Cognito initiates the user's session and redirects them to your IdP. While this doesn't solve the pre-filling issue, it gives you the most control over the sign-in process.

If this feature is crucial for your use case, you may want to submit a feature request to AWS. They do take customer feedback into account for future developments, although there's no guarantee when or if a particular feature will be implemented.
Sources
SAML identity provider names and identifiers - Amazon Cognito
Cognito - Customize federated authentication request | AWS re:Post
SAML session initiation in Amazon Cognito user pools - Amazon Cognito
How authentication works with Amazon Cognito - Amazon Cognito

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.