From 0efa9113950d0a128eea823b2dbc559ff6b0d4a0 Mon Sep 17 00:00:00 2001 From: Izabela <82568642+izabelapawlik@users.noreply.github.com> Date: Thu, 14 Dec 2023 08:29:00 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Update=20Blog=20=E2=80=9Caws-cdk-cognito-go?= =?UTF-8?q?ogle-sign-in-nest-js=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/blog/aws-cdk-cognito-google-sign-in-nest-js.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/blog/aws-cdk-cognito-google-sign-in-nest-js.md b/content/blog/aws-cdk-cognito-google-sign-in-nest-js.md index 9b5199fe59..3c988d876a 100644 --- a/content/blog/aws-cdk-cognito-google-sign-in-nest-js.md +++ b/content/blog/aws-cdk-cognito-google-sign-in-nest-js.md @@ -5,7 +5,7 @@ tags: - aws-cdk date: 2023-12-13T07:17:46.598Z meaningfullyUpdatedAt: 2023-12-13T07:17:46.598Z -title: Google sign in with Cognito and Nest.js +title: Google Sign In with Cognito and Nest.js layout: post image: /images/openid-connect-logo.png hidden: false From ba89be41fdd1c4e7f877934534a5b0a23bfefe97 Mon Sep 17 00:00:00 2001 From: Izabela <82568642+izabelapawlik@users.noreply.github.com> Date: Thu, 14 Dec 2023 08:31:49 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Update=20Blog=20=E2=80=9Caws-cdk-cognito-go?= =?UTF-8?q?ogle-sign-in-nest-js=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aws-cdk-cognito-google-sign-in-nest-js.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/content/blog/aws-cdk-cognito-google-sign-in-nest-js.md b/content/blog/aws-cdk-cognito-google-sign-in-nest-js.md index 3c988d876a..1dc8895d9b 100644 --- a/content/blog/aws-cdk-cognito-google-sign-in-nest-js.md +++ b/content/blog/aws-cdk-cognito-google-sign-in-nest-js.md @@ -13,7 +13,6 @@ comments: true published: true language: en --- - If you want to implement Google sign-in, also called Google federation, and combine it with using AWS Cognito this blog post if for you. We'll use aws-cdk combined with Nest.js to achieve that. @@ -23,13 +22,13 @@ We'll use aws-cdk combined with Nest.js to achieve that. At Bright, we often keep infrastructure code next to application code. Thus let's start with creating: -- Nest.js backend project +* Nest.js backend project ```shell nest new backend ``` -- aws-cdk infrastructure project +* aws-cdk infrastructure project ```shell mkdir infrastrucutre @@ -189,9 +188,9 @@ export class AuthController { At the end of the sign-in flow our application we have `IdToken`, `AccessToken` and `RefreshToken`. What we do at this stage depends on our needs. For example, we can: -- start a cookie-based session -- return `AccessToken` to frontend -- init user account configuration that do not fit into AWS Cognito +* start a cookie-based session +* return `AccessToken` to frontend +* init user account configuration that do not fit into AWS Cognito ## Combine Cognito with Passport Nest.js @@ -233,7 +232,7 @@ export class NestPassportOAuthStrategy extends PassportStrategy(OAuth2Strategy) ## Provide users with login URL With AWS Cognito we can use hosted pages. However, we often need to have a full control over the UI of our -application. +application.\ In such a case, we can craft a special URL that will trigger the sign in flow. Here's how to create the URL that will trigger login with Google flow: @@ -259,7 +258,7 @@ API credentials. ## ECS Task Definition -I'll spare you the details on how to run the Nest.js application in ECS. That's a topic for a separate blog post. +I'll spare you the details on how to run the Nest.js application in ECS. That's a topic for a separate blog post.\ However, there are a couple of important configuration options that you need to provide for the above snippets to work: ```typescript @@ -288,3 +287,5 @@ The full code of the above setup is available in [GitHub](https://github.com/bri In our example, AWS Cognito performs OpenID Connect exchange with Google. Our Nest.js application code only receives information from Cognito. We can easily integrate new identity providers e.g. Facebook and our backend application code would still work. + + \ No newline at end of file