Ep4: Using Cognito for API Authentication | Cognito, CloudFormation, Lambda | Serverless Series

Поделиться
HTML-код
  • Опубликовано: 24 авг 2024
  • In this video, we will provision Cognito resources as part of Cloud formation and then define Cognito Authorizer and attach it to our lambda function for Authentication.
    Github Source: github.com/imd...
    #cloudformation #cognito #authentication #restapi #aws #serverless #developers #tutorial #learn #upskill

Комментарии • 11

  • @dileepnagendra8199
    @dileepnagendra8199 3 месяца назад

    Thanks for your video.

  • @buckyrobert6570
    @buckyrobert6570 Год назад

    Hi Durgadas . I can see that you have created the cognito user pool using cloud formation but when you are trying to form the URL to request token you are reading the client ID from UI , what is the use of creating the pool using cloud formation if we have to manually read the client_id from UI.
    When we deploy the changes it will have both the code to use the cognito APIs which requires client-id and user-pool-id how can we reference the client-id and pool-id at run time of the pool which get created using cloudformation.

    • @durgadaskamath
      @durgadaskamath  Год назад

      Cloudformation scripts creates all the necessary components related to cognito like the domain, pool, client creation. One can have multiple clients created for a given configuration like Web, Mobile etc which would have an associated client_id.
      So when you want to trigger a authentication flow, you need to indicate which client you want to use.
      Basically when you have an UI, the client_id will be one of the env variable that would be then used by the UI to initiate the auth flow and get the JWT.

  • @kevinhutabarat6433
    @kevinhutabarat6433 Год назад

    hi Durgadas, how to use for existing cognito for new project serverless?

    • @durgadaskamath
      @durgadaskamath  Год назад

      If you already have existing Cognito that is created in your account, you can skip the resources creation we did through the Cloud formation templates. You can remove the lines 91-93 here : github.com/imdurgadas/tasks-api-serverless/blob/main/serverless.yml#L91
      and in github.com/imdurgadas/tasks-api-serverless/blob/main/serverless.yml#L28
      jwtCognitoAuthorizer - you will have to provide the values wherever its referencing the output of cloud formation template.

  • @harlleybastos
    @harlleybastos Год назад

    Thank you for the great content here ! I follow along all the videos and it really works well !
    I have a question for you.. How can I integrate that login and signup on a Next.js application ? I mean I know that I need to create the UI but my questions is about the data .. I simply create a singup form sending to amazon coginito ?

    • @durgadaskamath
      @durgadaskamath  Год назад +1

      Glad that the content is helpful !
      For integrating Auth with NextJS or any Frontend framework, that's correct you could send it to the cognito url which would initiate the flow.
      However, the recommended way is to use the `client-cognito-identity-provider` npm package from aws which abstracts and provides all the necessary stuff without having to reinvent.
      docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-cognito-identity-provider/
      Blog that could help: dev.to/kelvinvmwinuka/basic-authentication-with-aws-cognito-nextjs-4dal

    • @harlleybastos
      @harlleybastos Год назад

      @@durgadaskamath I tried to use that as a support and did not work well..
      I usually work better with AWS Amplify, I just set up and It starts to work in parts here..
      I have a question, for example, if I have a table of "Customer" and If I want to register that costumer on my system but not only with password and email I would like more information like for example, fullName, CEP...
      To do that I needed to use AWS DynamoDB + AWS Cognito?

    • @durgadaskamath
      @durgadaskamath  Год назад

      @@harlleybastos You mean capture additional details during the registration flow? If yes, while you configure Cognito, there are attributes that you can add /define.

    • @harlleybastos
      @harlleybastos Год назад +1

      @@durgadaskamath That's it ! Thanks, I'll try do add some on my cognito. And the only difference is that when I do my register I will pass more data, right ?

    • @durgadaskamath
      @durgadaskamath  Год назад

      @@harlleybastos That;s correct.