Tutorial: How to add security to a REST API using JWT Authorizers and Amazon Cognito | JWT Token

Поделиться
HTML-код
  • Опубликовано: 13 окт 2022
  • A quick tutorial on how to secure your AWS REST APIs using AWS Cognito, JWT Tokens, and JWT Authorizers. We will have the API Gateway setup with JWT Authorizers that will verify each api request has a valid JWT Token. These tokens will be generated from AWS Cognito for an authenticated user.
    Topics covered:
    1) Simple Lambda Creation using Nodejs
    2) Cognito User Pool Creation
    3) API Gateway Authorizer - JWT Authorizer

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

  • @kouroshbaghaei382
    @kouroshbaghaei382 4 месяца назад +1

    Thanks a lot! Very concise and to the point! 👌

  • @jumboliah13
    @jumboliah13 8 месяцев назад +1

    Great video. Great content and well executed and straightforward. Well done.

  • @saatwikmehta2916
    @saatwikmehta2916 7 месяцев назад +2

    Straightforward and awesome video

    • @letsfindsolutions
      @letsfindsolutions  7 месяцев назад

      I am glad you found it helpful. I do plan on making more, just need to find the time.

  • @PrashantZombade
    @PrashantZombade Год назад +3

    Great content, very helpful video. Thanks for your efforts.

  • @nareshgujjari
    @nareshgujjari Год назад +2

    Very useful. Thank you.

  • @joshuac9142
    @joshuac9142 6 месяцев назад +1

    Top quality stuff!

  • @kirtipahwa
    @kirtipahwa 3 месяца назад +1

    Keep it up. Informative video👍

  • @randall.chamberlain
    @randall.chamberlain 6 месяцев назад +1

    Nice and to the point

  • @Not0rious7
    @Not0rious7 8 месяцев назад +1

    You saved the day! I had t use oauth 2.0 in postman and not the bearer token dropdown

  • @TPDene
    @TPDene Месяц назад +1

    Thanks a lot! That's exactly what we need. We want to use Amazon S3 with an existing Keycloak instance and use JWT Token authentification

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

    Thank you so much!!

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

      I am glad you found the vudeo helpful...I plan to make more...just haven't had time lately. Hopefully soon.

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

      I really appreciate it. Yesterday spend whole day and the authorization was not working. So after watching your video, I fixed it 15 minutes!!

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

    Great video! So how does it all work on the front end? using JaveScript how does one use the host UI and retrieve the token and store and use it?

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

      The hosted UI was more for Demo. How I have implemented this in production is to have the server side code of the website call cognito to grab a token and pass this to my front-end UI to use in an AJAX call to the service. Doing this won't expose the username/password. This way the UI has a token ready to call the api as needed. I have used the hosted UI in my projects to offer QA a way to manually grab tokens in case they wanted to test the web service calls directly without any UI.

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

    I have implemented Cognito authentication for my .net web api / react app. It's in .net 4.8 framework and hosted in iis localhost. Also using IIS Url rewrite to configure IIS that react router handlea the app navigations after authentication is completed.
    Issue is when we make Cognito logout api endpoint get request, it throws CORs error stating Allow Content Header Origin is not present.
    I have the proper app domain, client id and redirect uri.
    So what needs to be done in this situation for logout to work.
    Cognito login works perfectly

  • @ManishJindalmanisism
    @ManishJindalmanisism 4 месяца назад

    How can i use this token further in aws lambda to get the email id or username to do some dynamic processing? Are there any cognito sdk or library available to scrap that Information in aws lambda ?

    • @letsfindsolutions
      @letsfindsolutions  4 месяца назад

      I believe you can get the user id or group id of the user from the token. From their you can have a dynamo db table to do mapping and dynamic logic based on your custom lookup.

    • @joshuaokoro9447
      @joshuaokoro9447 4 месяца назад

      Seems like you can get it from event.requestContext.authorizer

  • @gunyung0089
    @gunyung0089 5 месяцев назад

    7:53 When you change the password the second time, it says 'localhost has refused to connect'.
    How can I solve this?
    8:44 I tried it on Postman, but I couldn't get the token's value and it came out the same way

    • @letsfindsolutions
      @letsfindsolutions  5 месяцев назад

      Not really sure of the issue...just make sure you are using the id token and not the access token. Postman finally updated the ability to use the id token...so maybe try again.

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

    how can i use access token here instead of ID token to authenticate our API?

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

      I have only ever had this work with the ID Token, but I think if you want to use the Access Token, you may have look into writing your own custom authorizer lambda, and then have it validate the access token.

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

    why implicit grant rather than Authorization code grant? Aws doesn't recommend using Implicit Grant

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

      We are using jwt tokens. In not sure on the question.

  • @anandbabu01
    @anandbabu01 8 месяцев назад

    AWS UI changed now. Cognito UI looks entirely new and unable to get published the user login page.😥

    • @letsfindsolutions
      @letsfindsolutions  8 месяцев назад

      See if you see the option for classic mode...if so you xan switch back to that view maybe

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

    The AWS Cognito interface has changed, the setup is very different from what's shown in this video.

    • @letsfindsolutions
      @letsfindsolutions  3 месяца назад +1

      Agreed, the screens have changed...but the concept is essentially the same. When i have time i will do an updated video.

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

    I'm a little lost... perhaps I've jumped in too deep before reading up more, but in essence how or what would you give a third party that you wanted to allow to access your API?

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

      You would create a user for them within Amazon Cognito. They would then use these credentials to call and authenticate against Amazon Cognito (via various methods - AWS SDK, Postman like in the video) to get back the ID_TOKEN. Then they would call the API using the public API Gateway address passing the token which gets validated with the custom authorizer. Maybe start again at the beginning of the video and take it one step at a time....hope that helps :)

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

      @@letsfindsolutions hello thanks for the quick and detailed reply. That makes sense I think. So to confirm though, all I would provide them is the username/password but they could then get the ID_TOKEN in code rather than manually copy and paste as you showed.

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

      @@AthelstanEngland correct...they can call cognito using aws sdk...provide username and password...and it will return the api tokens.

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

      @@letsfindsolutions super, thanks very much for taking the time to reply.

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

      Glad to help out.