Amazon Cognito Token Authentication in ASP.NET Core With JWT

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ย. 2024

ความคิดเห็น • 50

  • @MilanJovanovicTech
    @MilanJovanovicTech  5 หลายเดือนก่อน +12

    Get the source code for this video for FREE → the-dotnet-weekly.ck.page/cognito
    Want to master Clean Architecture? Go here: bit.ly/3PupkOJ
    Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt

  • @antonmartyniuk
    @antonmartyniuk 5 หลายเดือนก่อน +7

    Awesome that AWS finally reached out to Milan so he can create AWS videos

  • @Kron0s19
    @Kron0s19 5 หลายเดือนก่อน +4

    Great video!.
    I have a specific question regarding the customization of token authentication. How can one push a "custom claim" to the identity provider in this setup? Custom claims are crucial for fine-grained access control and personalizing the user experience.
    For a follow-up video, I think it would be incredibly beneficial to explore how to migrate an existing application that uses Entity Framework Identity to this new authentication mechanism. Many of us work on legacy systems or projects that aren't starting from scratch, and the challenge of migrating to a more modern authentication solution like Amazon Cognito, especially concerning handling passwords and user data securely, is a significant hurdle. A detailed guide on this migration process, including best practices for handling sensitive data like passwords during the transition, would be invaluable to developers.

    • @MilanJovanovicTech
      @MilanJovanovicTech  5 หลายเดือนก่อน

      You can give this a try: docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html
      I usually run Authorization checks on the backend, based on the User ID, and then cache the result for a short period

  • @michajabonski8152
    @michajabonski8152 19 วันที่ผ่านมา

    Excellent tutorial. Just one little correction: you need to use /.well-known/openid-configuration in your MetadataAddress in appsettings.json. If you only paste your Authority, the whole thing doesn't work. BTW, I hadn no problems with UseHttpsRedirection();

    • @MilanJovanovicTech
      @MilanJovanovicTech  19 วันที่ผ่านมา

      Doesn't it end up being the same though? Authority (the setting) is part of /.well-known/openid-configuration
      Edit: I see now what you mean. I started off with the correct setup, but ended up copy-pasting the Authority twice. Although this is most likely fixed at runtime, since the end solution ends up working.

    • @michajabonski8152
      @michajabonski8152 19 วันที่ผ่านมา

      @@MilanJovanovicTech yeah must be fixed. But I got a bit confused figuring this out myself.

  • @farzinfaghirnavaz1027
    @farzinfaghirnavaz1027 22 วันที่ผ่านมา

    eagerly waiting for the next video

    • @MilanJovanovicTech
      @MilanJovanovicTech  22 วันที่ผ่านมา

      Thanks. Did you check the Keycloak videos?

  • @thiagomatu
    @thiagomatu 5 หลายเดือนก่อน +1

    Thanks for this video Milan.
    Have you already recorded the Azure approach?

    • @MilanJovanovicTech
      @MilanJovanovicTech  5 หลายเดือนก่อน +1

      What would be the Azure approach you have in mind?

  • @rodjenihm
    @rodjenihm 5 หลายเดือนก่อน +1

    Why does https causes the problem? From what I remember I have used https with other Identity Providers locally without any issue.

    • @MilanJovanovicTech
      @MilanJovanovicTech  5 หลายเดือนก่อน

      Not a Cognito issue - it's a problem with UseHttpsRedirection middleware. More info here: learn.microsoft.com/en-us/aspnet/core/security/enforcing-ssl

  • @joshuagabal9444
    @joshuagabal9444 5 หลายเดือนก่อน

    Thanks for the Video Milan. What can you do if you have 2 different kinds of users? For example a organizerUser and a customerUser. The organizerUser has different rights and only he can access specific endpoints that the customerUser can not reach. How to model that with AWS Cognito?

    • @MilanJovanovicTech
      @MilanJovanovicTech  5 หลายเดือนก่อน

      You can add custom claims, and use those to authorize the user

  • @emanuelcordovamontiel1017
    @emanuelcordovamontiel1017 5 หลายเดือนก่อน

    Now, you're showing AWS Tech, Could you show us how to implement Clean Architecture with AWS Lambda Functions in a .NET project? Can't wait!

    • @MilanJovanovicTech
      @MilanJovanovicTech  5 หลายเดือนก่อน +3

      AWS Lambda? Writing that down, could be an idea for a next project.

  • @andy301086
    @andy301086 2 หลายเดือนก่อน

    Cool video, thank you. Do you have any video for KeyCloack and OpenIdDict?

    • @MilanJovanovicTech
      @MilanJovanovicTech  2 หลายเดือนก่อน +1

      Haven't made one for Keycloak yet (other than in my courses 😅). I'm planning to make an intro video on Keycloak at some point

    • @andy301086
      @andy301086 2 หลายเดือนก่อน

      @@MilanJovanovicTech I am just trying to to take a look at some open source free solutions for identity and figure out that there are a couple of them😂 no silver bullet😂😂

  • @shauncs
    @shauncs 3 หลายเดือนก่อน

    Any thoughts on using Cognito for Blazor WASM applications?

  • @PelFox
    @PelFox 5 หลายเดือนก่อน

    Is it possible to keep an existing user database on-prem without moving users to AWS? We dont want to force all users to change password or create new accounts.

    • @MilanJovanovicTech
      @MilanJovanovicTech  5 หลายเดือนก่อน

      I haven't tried it, but I expect there is a feature for user import. Let me do some digging 🤔

  • @kembridzkembridzowski5397
    @kembridzkembridzowski5397 5 หลายเดือนก่อน

    I use gateway for authentication when working with cloud providers. What are possible usecases / benefits of authentication in the code?

    • @MilanJovanovicTech
      @MilanJovanovicTech  5 หลายเดือนก่อน

      The gateway does the same thing as demonstrated here

  • @gilbertsenyonjo963
    @gilbertsenyonjo963 4 หลายเดือนก่อน +1

    Man. You really know dotnet. What I dont understand is why you're using AWS instead of Azure. Isnt that a clash of tech-stacks?

    • @MilanJovanovicTech
      @MilanJovanovicTech  4 หลายเดือนก่อน

      If all you have is a hammer..

    • @rsgilbert6152
      @rsgilbert6152 4 หลายเดือนก่อน +1

      ​@@MilanJovanovicTechI am not getting the metaphor. What's the hammer? Is it Microsoft? Is it dotnet? And what are the nails?
      I think Microsoft offers first class support for dotnet. This is not the case with AWS. You'll find that for the serverless stack like AWS Lambda, they use JavaScript in their developer documentation, which means that they are mostly trying to capture the JavaScript developer market. Python is a close second.
      In Azure documentation, C# is used in almost all code examples.

    • @MilanJovanovicTech
      @MilanJovanovicTech  4 หลายเดือนก่อน +1

      @@rsgilbert6152 I just think we shouldn't be confined to any cloud provider. Learn all of them. Learn how to deploy things yourself. An API and DB Server aren't too complicated. And if you're at scale, find people who are really good at managing that kind of infrastructure.

    • @michajabonski8152
      @michajabonski8152 24 วันที่ผ่านมา +1

      Cognito equivalent on Azure is Azure AD B2C and that is really painful to work with.

  • @LucasHenriquedeBrito
    @LucasHenriquedeBrito 5 หลายเดือนก่อน

    Is there any video with the same goal but using Azure resources (Azure AD B2C)?

  • @carlosportillo6915
    @carlosportillo6915 5 หลายเดือนก่อน +1

    Great video, thanks for sharing

  • @TilanBethmage-q9g
    @TilanBethmage-q9g หลายเดือนก่อน

    Can we implement RBAC using Cognito?

    • @MilanJovanovicTech
      @MilanJovanovicTech  หลายเดือนก่อน

      Yes: docs.aws.amazon.com/cognito/latest/developerguide/role-based-access-control.html

  • @Short-CastClips
    @Short-CastClips 5 หลายเดือนก่อน

    Why is there issue with https? how can we overcome it because I would want my app to be on https

    • @MilanJovanovicTech
      @MilanJovanovicTech  5 หลายเดือนก่อน

      It's unrelated with Cognito. But you can check this out: learn.microsoft.com/en-us/aspnet/core/security/enforcing-ssl

  • @iq4u213
    @iq4u213 5 หลายเดือนก่อน

    you are awesome just like your videos :)
    i hope you make a video about adding google authentication to asp net core web api not mvc and also it should be worked if i you already have jwt authentication using email and password using asp net identity.

    • @MilanJovanovicTech
      @MilanJovanovicTech  5 หลายเดือนก่อน +1

      That's a great suggestion

    • @iq4u213
      @iq4u213 5 หลายเดือนก่อน

      Спасибо 🥰☺
      @@MilanJovanovicTech

  • @emanuelcordovamontiel1017
    @emanuelcordovamontiel1017 5 หลายเดือนก่อน

    OMG. This is amazing!. 😛

    • @MilanJovanovicTech
      @MilanJovanovicTech  5 หลายเดือนก่อน +1

      Hey, thanks. I'm glad you liked it :) It's a bit slow, but it should help people starting out with Cognito.