Strapi with AWS Cognito Provider Login

Strapi with AWS Cognito Provider Login

·

2 min read

AWS Cognito could allow you mange user sign-in, sign-up and its management with ease and Strapi is one of the headless CMS with good support on customize own API and allow different OAuth login. And Strapi is able to authenticate with the Cognito service by its Cognito provider.

Setting Up AWS Cognito User Pool

Search Cognito after login aws account. Select "Manage User Pools".

Untitled.png

Create a new user pool and select "Review defaults".

Untitled 1.png

The default setting is filled. For this example we will use simple email-password login. You may also select the config to fit your usage. Scroll down you will have a app client session. Select "Add app client" and create a new app client.

Untitled 2.png

After the app client is created, you may now access the app client id and client secret by clicking the show details which will be using later when setting in Strapi.

Untitled 3.png

On the left hand side menu, select "App client settings" below the app integration. Click the app client just created and config with the following setting.

Untitled 4.png

Goto Domain name below the App integration section and select a domain name. And the subdomain will also be used to setting in Strapi later.

Untitled 5.png

After that, go back to the App client settings, you should see the Launch UI option.

Untitled 6.png

Setting Up Strapi Protal

Goto Settings and select Providers.

Untitled 7.png

Click Cognito and set with the following config.

Untitled 8.png

Test Result

Goto browser with the link "localhost:1337/connect/cognito". It should redirect you to the cognito login page. You may sign up a new account or sign in.

Untitled 9.png

After the login is success, it will redirect you to the page like the following.

Untitled 10.png

id_token is the JWT that AWS Cognito returned, which you may use to access AWS's service if neccessary.

The returned json is from Strapi, the jwt inside may use to access Strapi service.