Secure your API Gateway with Amazon Cognito User Pools | Step by Step AWS Tutorial

Поділитися
Вставка
  • Опубліковано 14 лип 2024
  • Amazon Cognito is a powerful AWS service that enables user logins and federated identities. Cognito can be leveraged as an authentication and authorization mechanism for your APIs built through AWS API Gateway. In this video, I show you how to create an Amazon Cognito User Pool and attach it as an authentication handler to your API Gateway REST api.
    Looking to get hands on experience building on AWS with a REAL project? Check out my course - The AWS Learning Accelerator! courses.beabetterdev.com/cour...
    Interested in authentication using Lambda instead? Check out • Secure your API Gatewa...
    📚 MY RECOMMENDED READING LIST FOR SOFTWARE DEVELOPERS📚
    Clean Code - amzn.to/37T7xdP
    Clean Architecture - amzn.to/3sCEGCe
    Head First Design Patterns - amzn.to/37WXAMy
    Domain Driver Design - amzn.to/3aWSW2W
    Code Complete - amzn.to/3ksQDrB
    The Pragmatic Programmer - amzn.to/3uH4kaQ
    Algorithms - amzn.to/3syvyP5
    Working Effectively with Legacy Code - amzn.to/3kvMza7
    Refactoring - amzn.to/3r6FQ8U
    🎙 MY RECORDING EQUIPMENT 🎙
    Shure SM58 Microphone - amzn.to/3r5Hrf9
    Behringer UM2 Audio Interface - amzn.to/2MuEllM
    XLR Cable - amzn.to/3uGyZFx
    Acoustic Sound Absorbing Foam Panels - amzn.to/3ktIrY6
    Desk Microphone Mount - amzn.to/3qXMVIO
    Logitech C920s Webcam - amzn.to/303zGu9
    Fujilm XS10 Camera - amzn.to/3uGa30E
    Fujifilm XF 35mm F2 Lens - amzn.to/3rentPe
    Neewer 2 Piece Studio Lights - amzn.to/3uyoa8p
    💻 MY DESKTOP EQUIPMENT 💻
    Dell 34 inch Ultrawide Monitor - amzn.to/2NJwph6
    Autonomous ErgoChair 2 - bit.ly/2YzomEm
    Autonomous SmartDesk 2 Standing Desk - bit.ly/2YzomEm
    MX Master 3 Productivity Mouse - amzn.to/3aYwKVZ
    Das Keyboard Prime 13 MX Brown Mechanical- amzn.to/3uH6VBF
    Veikk A15 Drawing Tablet - amzn.to/3uBRWsN
    🌎 Find me here:
    Twitter - / beabetterdevv
    Instagram - / beabetterdevv
    Patreon - Donations help fund additional content - / beabetterdev
    #AWS
    #Cognito

КОМЕНТАРІ • 260

  • @mogomotsiseiphemo1681
    @mogomotsiseiphemo1681 10 місяців тому +17

    Great video!
    At this point 23:45, to avoid having to manually change from "code" to "token" in the redirect, you just have to select "Implicit grant" only when setting the OAuth 2.0 Auth Flow at 7:20!

  • @davyboy951
    @davyboy951 Рік тому +35

    love that you don’t scrub the mistakes out of your videos. thats how real life goes, and i feel it’s important for those new to the industry to see their seniors working through mistakes. great video.

    • @BeABetterDev
      @BeABetterDev  Рік тому +11

      Mistakes happen in real life! Its important to see the whole process :D

  • @TheTruthNotControl
    @TheTruthNotControl 3 роки тому +4

    This was a brilliant tutorial. I have watched many videos from various people on youtube, udemy and you name it, I have been on the sites. Yet you talked in such a, lets get this done and ill show you manner instead of lots of talking but spoke about a process when needed was just great. I learned alot from this, thank you. I subbed and liked this video.

    • @BeABetterDev
      @BeABetterDev  3 роки тому +2

      Thank you so much for your kind words Daryl. I always try to present my content in a relatable way that synthesizes the complexity of a topic into an easy to understand presentation. I'm glad you found this useful - and thank you for the kind words!
      Daniel

  • @Ryuugaminechan
    @Ryuugaminechan 3 роки тому +3

    Was stuck with this for a couple of hours now. Didn't realize that you need to deploy the API after making changes. This video really helped me. Thanks!

  • @fatihersoy7559
    @fatihersoy7559 Рік тому

    This video made me subscribe to your channel immediately. It's impressing how easy to understand from you, especially after spending hours on understanding nothing about the topic.

  • @jeromeeusebius
    @jeromeeusebius 2 роки тому +1

    BeABetterDev: Thanks for putting this video together. I followed the API Gateway Lambda one and this version with Cognito. The option is Cognito is much richer and I will be exploring it with my app. It is good that the video is also an actual workthrough with details and it was easy and nice to follow and I was able to replicate the results.

  • @meysammahmoudi5712
    @meysammahmoudi5712 2 роки тому +1

    This is a really great video, simple and straightforward. thanks a lot

  • @ChardsonX
    @ChardsonX 2 роки тому +3

    I want to thank you! This lesson was really helpful and straightforward. Congratulations!

    • @BeABetterDev
      @BeABetterDev  2 роки тому

      You're very welcome Ricardo! Thanks for the kind words!

  • @bboyBoomgaarden
    @bboyBoomgaarden 2 роки тому +3

    THANK YOU!!! I spent my entire day trying to figure out why I wasn't getting the id_token returned and it was because the URL i was using didn't have openid added to the URL!!!! I read every doc and stack overflow article I could find, thank you for making this video!! You got yourself another subscriber :D

    • @BeABetterDev
      @BeABetterDev  2 роки тому +1

      Hi Jake,
      Super glad I was able to help you out. Thanks so much for the kind words and welcome to the channel!
      Daniel

  • @INMYMIND1221
    @INMYMIND1221 Рік тому

    This is amazing, this helps me a lot in building side projects user authentication!!

  • @radu2329
    @radu2329 3 роки тому +1

    Amazing job,man. THANK YOU SO MUCH

  • @pms123ms
    @pms123ms 2 роки тому

    amazing video, just right speed and right contents for api security with AWS

  • @arpankhetani7818
    @arpankhetani7818 Рік тому

    Thank you for the well explaination of the Cognito and the demo.. It worked smoothly for me following the steps you mentioned..

  • @arkadiyshuvaev
    @arkadiyshuvaev 2 роки тому +1

    Great work! I have learnt a lot from your video. Thank you and all the best :)

  • @rohitghali609
    @rohitghali609 2 роки тому +3

    Mind blown... Was looking for exactly this. Fantastic.

  • @eugenevedensky6071
    @eugenevedensky6071 2 роки тому +14

    This video along with your RDS lambda integration video is pretty much all you need to get a robust web app going super quickly. Great content.
    EDIT: In case you ever read this, do you have any insight how you might apply RBAC with this strategy?

  • @sebastiencrepel5032
    @sebastiencrepel5032 2 роки тому +1

    Hello. Thank you so much. This step by step video is a gold mine !

  • @Umerfarooqai
    @Umerfarooqai 3 роки тому +1

    Who were those with 5 downvotes?
    Perhaps this was one of the best and easiest tutorials to understand the concepts.

    • @jasoncampbell1464
      @jasoncampbell1464 4 місяці тому

      Plot twist, you don't see the number of downvotes unless you downvoted yourself

  • @ryanl8119
    @ryanl8119 Рік тому

    Dude, this video is gold. Thank you 🙏

  • @tonislavatanasov112
    @tonislavatanasov112 2 роки тому +1

    Exactly what I was looking for. Thanks! You just got yourself another sub

    • @BeABetterDev
      @BeABetterDev  2 роки тому +1

      Thanks Tonislav and welcome to the channel!

  • @craigmacritchie3087
    @craigmacritchie3087 3 роки тому +1

    This was great! awesome job Daniel!

  • @cachuelasaimonrobertl.455
    @cachuelasaimonrobertl.455 2 роки тому +1

    You're an absolute mad lad! saved me hours of reading docs lol

  • @ihorkonovalenko9389
    @ihorkonovalenko9389 2 роки тому +1

    Thanks for great practical explanation! Very useful video.

  • @cass4649
    @cass4649 2 роки тому +1

    Thank you for your videos. They are amazing, the notification is enabled in order to receive news content 😀

  • @chrisnuttle4302
    @chrisnuttle4302 Рік тому

    Actually practical thanks a lot. This has helped me a lot.

  • @dannevesdantas
    @dannevesdantas 4 місяці тому

    Excellent! Thanks so much!

  • @etseale
    @etseale 3 роки тому +1

    Nicely explained! Even I understand it. :) Thank You!

    • @BeABetterDev
      @BeABetterDev  3 роки тому +1

      Thanks etseale! Glad you enjoyed :)

  • @joaovitor12full
    @joaovitor12full Рік тому

    thank you very much, that's just what i needed

  • @scottjennings2165
    @scottjennings2165 Рік тому +1

    this just saved a ton of time. Forgot to deploy API and was using the test URL or some shit. Thanks bro

    • @BeABetterDev
      @BeABetterDev  Рік тому +1

      You're very welcome Scott! I've been bitten by that problem too many times.

  • @eiderantonioarangoamaya8475
    @eiderantonioarangoamaya8475 2 роки тому

    Thanks bro, nice video. Highly appreciate it.

  • @vk2875
    @vk2875 2 роки тому +1

    Thanks, this is just an excellent tutorial !!!

  • @user-sd8su3cb2y
    @user-sd8su3cb2y 4 місяці тому

    Great video its really helps me to secure apigateway with cognito userpool

  • @st3114rr
    @st3114rr 2 роки тому +1

    This was so helpful--thanks a ton!

  • @isharanka6020
    @isharanka6020 2 роки тому +1

    thank youuuu for this tutorial. Helped me a lot!!

  • @damoga55
    @damoga55 3 роки тому +1

    Thank you very much, this video helped me a lot.

  • @chandeepsingh4161
    @chandeepsingh4161 2 роки тому

    Bhai aapne balle balle karwa di!

  • @derangeer
    @derangeer 2 роки тому +1

    Cool! awesome demo and great explanation.

  • @nayanchoudhary4353
    @nayanchoudhary4353 3 роки тому +4

    Thanks for this, just what I needed. Next, can you show how to provide access to user to a subset of lambda functions or APIs, instead of access to all?

  • @jhonnySonnny
    @jhonnySonnny 3 роки тому +5

    I had clicked “like” even before watching this guy’s video.

    • @BeABetterDev
      @BeABetterDev  3 роки тому

      Thank you so much for your support!

    • @jonathanbecerra4819
      @jonathanbecerra4819 Рік тому

      I thumbs up your comment before liking and watching the video. This comments is all I needed to know 😂

  • @shaunmccullagh5116
    @shaunmccullagh5116 Рік тому

    Superb video, great stuff many thanks for posting

  • @surly_mel
    @surly_mel Рік тому

    Thanks for the great video! I'd gotten past the initial login step just fine but had no idea what to do with the tokens passed back. Got a bit of template work to do linking the Lambdas/Gateway/Cognito but it should be easy peasy thanks to your demo.

  • @ToreyLittlefield
    @ToreyLittlefield 2 роки тому +1

    Masterclass. Thank you 🙏🚀

  • @swaminathbera_a1
    @swaminathbera_a1 Рік тому

    Awesome Man, Thanks for the hard way tip!! 😇😇

  • @deecee2204
    @deecee2204 3 роки тому +2

    love this video, more on serverless architecture pls

  • @berkslv
    @berkslv 3 роки тому +1

    Thanks for great explanation !

  • @alexandromaldonado2182
    @alexandromaldonado2182 3 роки тому +1

    Awesome explanation

  • @sbnlalpnr
    @sbnlalpnr Рік тому

    Nice explanation. Thank you

  • @dekcode2824
    @dekcode2824 3 роки тому +1

    This is gold. Thanks man

  • @rsouza01
    @rsouza01 2 роки тому +1

    Freaking amazing video!! Kudos for u! Learned a lot!

  • @tasleemhussein5228
    @tasleemhussein5228 2 роки тому +1

    Awesome video, thanks bud!

  • @Ko0lHaNDLuKex
    @Ko0lHaNDLuKex 3 роки тому

    This was great! Thanks a lot.
    Now I just need to figure out how to IaC this with Terraform!

    • @BeABetterDev
      @BeABetterDev  3 роки тому +1

      You're very welcome! For IaC, check out CDK! It can compile down to Terraform!

  • @markthien
    @markthien Рік тому

    Very nice tutorial bro!

  • @blackDrk
    @blackDrk 2 роки тому

    Thanks bro you saved me!!!!!!!! great video

  • @rajapoudel5037
    @rajapoudel5037 Рік тому +1

    Thanks for making the tutorial video. This video helps me a lot.

  • @kmilo4307
    @kmilo4307 2 місяці тому +1

    Thanks. I was waiting to see at the end the web page with the fields requesting for username and pw

  • @branquitodemunze
    @branquitodemunze 2 роки тому +1

    Thanks a lot! Great explanation.

  • @kreeve6144
    @kreeve6144 8 місяців тому +1

    Love this video! The only thing I've found different in my scenario is that passing the Authorization header won't work with the access token. It only works with the id token for some reason

  • @The.Traveling.Nerddd
    @The.Traveling.Nerddd Рік тому

    Nicely explained

  • @caleyCodeLab
    @caleyCodeLab Рік тому

    you're a king

  • @BearVodkaAndValenki
    @BearVodkaAndValenki 9 місяців тому

    Thank you for the lesson)

  • @viswatejaforu
    @viswatejaforu 2 роки тому

    Thanks a lot, you saved my day

  • @longdo6858
    @longdo6858 2 роки тому +1

    thanks u! I get stuck until get your video!

  • @jasusig8946
    @jasusig8946 2 роки тому +1

    You are the best bro, thanks.

  • @mohammadrezabagheri8336
    @mohammadrezabagheri8336 2 роки тому +1

    Thanks, awesome job!

  • @fahimfahad7026
    @fahimfahad7026 2 роки тому +1

    Excellent video

  • @amarnatha1614
    @amarnatha1614 5 місяців тому

    So nice & useful...

  • @karthiksakthivel7108
    @karthiksakthivel7108 Рік тому

    Simple and super video...

  • @user-qj4hd7ks5z
    @user-qj4hd7ks5z 2 роки тому +1

    Thank you very much

  • @JoshPeak
    @JoshPeak 3 роки тому +1

    Currently running into issues trying to adapt this to the "HTTP API" on API Gateway to use Cognito User Pools as an authorizer but stumbling on the step about JWT as a source. I'll fumble my way through it and I wanted to say that I am grateful your content getting me this far. Authorizing the new HTTP API Gateway could be another idea for content if that's something to add to your list of content ideas. Thanks for the high quality content though ^_^

    • @BeABetterDev
      @BeABetterDev  3 роки тому +1

      Hey josh,
      Have you tried taking a look at my video on HTTP APIs in API Gateway? I think you can possibly combine the content from this video and the one below.
      ua-cam.com/video/M91vXdjve7A/v-deo.html
      Hope this helps.
      Daniel

    • @JoshPeak
      @JoshPeak 3 роки тому +1

      @@BeABetterDev thanks for the reply. I managed to fumble my way through it with this video ua-cam.com/video/o7OHogUcRmI/v-deo.html
      The one you just linked me, filled in some gaps for me about logging and cloud watch. 👏
      Thanks again for all of your content. I’ve smashed the like 👍 button on all the videos that I have watched (to feed the algorithm).

    • @BeABetterDev
      @BeABetterDev  3 роки тому

      Thanks so much Josh! I'm glad you were able to work through it and appreciate the support! Thanks again and stay safe :)

  • @linfrank4215
    @linfrank4215 Рік тому

    helpful video, thanks.

  • @vasudeva1408
    @vasudeva1408 11 місяців тому

    Good demo

  • @moisesfloresestay7158
    @moisesfloresestay7158 2 роки тому +1

    Muy agradecido! Gracias!

  • @NurseDaveBSMSON
    @NurseDaveBSMSON 2 роки тому

    Excellent

  • @shubhampahurkar298
    @shubhampahurkar298 2 роки тому +1

    very helpful. Thanks a lot

  • @dacao9240
    @dacao9240 2 роки тому

    Thanks!

  • @inacomic
    @inacomic 2 роки тому +1

    Top man! Thank you for creating this - and including the fail! lol

    • @BeABetterDev
      @BeABetterDev  2 роки тому +1

      You're very welcome! The fails just adds to the realism :P
      Cheers

    • @inacomic
      @inacomic Рік тому

      @@BeABetterDev Hi 👋 Do you have a video walking through adding a cognito user to a dynamodb?

  • @Diegoefectivo
    @Diegoefectivo 2 роки тому +1

    Thank you so much

  • @AhumadaMauricio
    @AhumadaMauricio Рік тому +1

    Great video. I think there's a little change in the way the authorization token is validated in the api gateway, in order to send a request using postman make sure you send the token using the Authorization tab and selecting "Bearer " on the dropdownlist. Do not include the token on the URL as this will not be correctly authorized by api gateway.

  • @FundaDuval-eb8qj
    @FundaDuval-eb8qj 2 місяці тому +1

    Hi I love the pace & no fluff! I have 2 questions: 1) Can you use user pool authorizers with federated ID integration (like with AzureAD)? User will be using SSO. and 2) does this remove the need/use-case for Lambda@Edge?

  • @freeworldtour
    @freeworldtour 3 роки тому +1

    OMG...yes i need this useful video...

  • @zanelesibanyoni7951
    @zanelesibanyoni7951 3 роки тому +1

    thank you for this video

  • @sanooosai
    @sanooosai Рік тому

    thank you

  • @fasiltadesse2687
    @fasiltadesse2687 2 роки тому

    Thank you, sir

  • @theethicalh3707
    @theethicalh3707 2 роки тому +1

    thank you very much bro i want to like that video 100000000 time

  • @TheGuroguro12
    @TheGuroguro12 2 роки тому

    Thanks.

  • @Darknightzs
    @Darknightzs 2 роки тому

    ¡Gracias!

    • @Darknightzs
      @Darknightzs 2 роки тому

      Thanks a lot men, great video. If you know somehting about using cognito trigers to save users statistics with lambdas, you will be mi hero haha

  • @oy_oy
    @oy_oy 2 роки тому

    genius, brilliant

  • @saveplatypus
    @saveplatypus 3 роки тому +1

    Thank you sir. Very helpful. You should ask for a raise. :)

  • @jonathanfalcone3437
    @jonathanfalcone3437 2 роки тому +10

    This video is amazing! Very generous of you to take time and publish this for public viewing. Just out of curiosity is it possible for a user to login via the HostedUI and then have access to api gateway via the browser? If you don't have tech savy customers they likely don't want to access the API via Postman but would prefer to just login and have access, any chance if you know this is possible ? Thanks so much again :)

    • @BeABetterDev
      @BeABetterDev  2 роки тому +1

      Hi Jonathan,
      Hm, I don't think this is possible using any out of the box tools unfortunately. Sorry to share the bad news. I think it wouldn't be too much work to create a simple React app with a couple input boxes / text areas to call the corresponding UI once logged in.
      Thanks so much for the kind words!
      Daniel

    • @SilviasBrainery
      @SilviasBrainery Рік тому

      @@BeABetterDev i guess this answers my question.....

  • @hbladeh
    @hbladeh Рік тому

    If I understand correctly what you did is basically by writing token into the URL you switched from "Authorization code" grant to "Implicit" grant type. If you're using a URL that's outside of AWS and travels through the web use code instead and use the Token endpoint of the identity provider (in this case Cognito), to get a token in the Body, and post it as a header in the HTTP Request, not as the part of the URL itself.

  • @anacondong
    @anacondong 3 роки тому +1

    perfect!!!

  • @ComupXChinx
    @ComupXChinx Рік тому +1

    Could your make a Identity Pool video of how to set different users have different API permissions

  • @pratappadhy2005
    @pratappadhy2005 Рік тому

    Awesome

  • @kishanlal676
    @kishanlal676 2 роки тому +7

    23:49 I guess you don't have to do that manually if you allow only the 'Implicit grant' when you check the 'Allowed OAuth Flows' section at 7:25 which would set the response_type to token automatically. But, this is not suggested unless you're using a Single Page App without any backend

  • @ppgg997
    @ppgg997 Рік тому +4

    Great explanations!! One question, on authorizer test , you used Token id but calling the api path from Postman you put in header the access token instead. Whats the difference and why each one needed in the corresponding scenario?

  • @Ronaldograxa
    @Ronaldograxa 4 місяці тому

    thanks for that.. Hard to find someone going through custom domain in cognito..

  • @ferhatkorkmaz11
    @ferhatkorkmaz11 2 роки тому +1

    you are a god.

  • @valirjonathan2161
    @valirjonathan2161 3 роки тому

    Great. Please do how to secure API Gateway with Firebase Auth. Much thanks.

  • @markfiala3652
    @markfiala3652 2 роки тому +1

    Fantastic video, I really appreciate it. In my case though, I’d like to use Cognito in kind of a stateless situation, I would prefer to enter the login and password in the header ( or base64 version of it with basic authentication) instead of logging in to get it token first. Reason being I’m connecting it from the output of other web services that do something and there isn’t really the mechanism to get a temporary token. Any ideas how to do that?

  • @imagesxpertmedia5105
    @imagesxpertmedia5105 2 роки тому

    Great job. Please do you offer mentorship program. I need to lean more on AWS infrastructure projects