Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Application Loadbalancer and Cognito user pools, redirect_mismatch

I have a traditional web app (as in a hobby project I made 15 years ago) that I am moving to AWS. It is deployed in ECS with Fargate, behind an Application Loadbalancer. Now, I want to add authentication with FB and Google. I have managed to configure both FB and Google so that I get authenticated, but I am having troubles with the authenticate rule in ALB. At the end of a successful authentication, I get "redirect_mismatch". If I try to set my redirect_uri to an external site (such as www.google.com) and add that site to my whitelist, it works fine. As far as I can see, there are no typos.

Listener rules app client settings

Attempting to browse to https://myapp.domain.se/ will redirect to the login flow, and when done land in a redirect_mismatch error. https://myapp.auth.eu-west-1.amazoncognito.com/login?response_type=code&client_id=2b88s...&redirect_uri=https://www.google.com otoh works fine.

What am I missing. How can I get a more verbose error message?

like image 303
simon Avatar asked Aug 10 '18 13:08

simon


People also ask

Can Load Balancer do authentication?

You can configure an Application Load Balancer to securely authenticate users as they access your applications. This enables you to offload the work of authenticating users to your load balancer so that your applications can focus on their business logic.

What is the function of Amazon Cognito user pools?

A user pool is a user directory in Amazon Cognito. With a user pool, your users can sign in to your web or mobile app through Amazon Cognito. Your users can also sign in through social identity providers like Google, Facebook, Amazon, or Apple, and through SAML identity providers.

Which AWS service is an alternative for Amazon Cognito Sync for syncing of application related user data and user profile data?

If you're new to Amazon Cognito Sync, use AWS AppSync . Like Amazon Cognito Sync, AWS AppSync is a service for synchronizing application data across devices. It enables user data like app preferences or game state to be synchronized.

What are the two main components of Amazon Cognito?

The two main components of Amazon Cognito are user pools and identity pools. User pools are user directories that provide sign-up and sign-in options for your app users. Identity pools enable you to grant your users access to other AWS services. You can use identity pools and user pools separately or together.


1 Answers

The callback URL values are a bit complicated and not intuitive without reading the documentation for Application Load Balancer use case.

The short version is that you will need to add three values to your callback urls:

  1. https://{your-load-balancer-domain}/oauth2/idpresponse
  2. https://myapp.domain.se/oauth2/idpresponse <-- your application
  3. https://myapp.auth.eu-west-1.amazoncognito.com/saml2/idpresponse

See: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/listener-authenticate-users.html

like image 51
jesh Avatar answered Sep 20 '22 11:09

jesh