Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Cognito User Pools and OpenId

I am playing around with Amazon Cognito and after reading some of the docs and creating a user pool I am running into some issues. I believe that a cognito user pool can be used with OpenId to redirect the user to a hosted UI for user authentication (without federating out to another provider). I have tried to use the authentication options in DotNetCore 2 to do this as this is something I have done previous with other providers.

I have the following:

services.AddAuthentication(options =>
{
    options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
    options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
    options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie()
.AddOpenIdConnect(options =>
{
    options.ResponseType = "code";
    options.MetadataAddress = $"https://cognito-idp.{authOptions.AwsRegion}.amazonaws.com/{authOptions.PoolId}/.well-known/openid-configuration";
    options.ClientId = authOptions.ClientId;
    options.ClientSecret = authOptions.ClientSecret;
});

but everytime I try it always returns

{"code":"BadRequest","message":"The server did not understand the operation that was requested.","type":"client"}

Just wondering if anyone had any experience with this please? I have tried to create the user pool in different regions just to make sure that it is not only supported in certain regions but always get the same.

like image 351
Niall Gray Avatar asked May 28 '18 15:05

Niall Gray


People also ask

Does AWS Cognito support OpenID Connect?

OpenID Connect is an open standard for authentication that a number of login providers support. Amazon Cognito supports you to link identities with OpenID Connect providers that you configure through AWS Identity and Access Management .

What is the main difference between Cognito user pool and Cognito identity pool?

With a user pool, your app users can sign in through the user pool or federate through a third-party identity provider (IdP). Identity pools are for authorization (access control). You can use identity pools to create unique identities for users and give them access to other AWS services.

Is Cognito user pool ID sensitive?

In summary "userPoolId" is your sensitive info and should not be exposed in your Client.

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.


1 Answers

I used to have the same problem. Configured my pool and code according to this tutorial. The crucial part was

Another configuration that may be important is the App integration > Domain name. It allows us to configure what will be the domain of the sign-in and sign-up pages.

After I configured domian name everything worked fine.

like image 78
EgurnovD Avatar answered Sep 28 '22 06:09

EgurnovD