Adding JWT Authentication In ASP.NET Core With Firebase

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ธ.ค. 2024

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

  • @MilanJovanovicTech
    @MilanJovanovicTech  ปีที่แล้ว +3

    Want to master Clean Architecture? Go here: bit.ly/3PupkOJ
    Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt

  • @Gio2k
    @Gio2k ปีที่แล้ว +3

    Awesome video, succint and to the point! Keep them coming!

  • @whatgoglikeno6120
    @whatgoglikeno6120 ปีที่แล้ว +8

    Very timely, im about to implement this in a new project soon.
    If you want to make a part 2, I'd be interested in multiple login providers as well as adding roles to the token. I think these 2 are pretty standard requirements for any real world application.
    Im not sure whether to use Identity package with that approach. Also not sure whether I can get the token (with roles) directly from firebase in my frontend or I need to send request to my own backend.

    • @drozdgabriel
      @drozdgabriel ปีที่แล้ว

      It would be so cool to see something like this! 😅

    • @jeancarlosreyesencarnacion
      @jeancarlosreyesencarnacion ปีที่แล้ว

      Yes man, Part 2 is required with different authorization method such as Google or Facebook. 🤩❤

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว +2

      For most of the social providers you would implement it on the client side, which is something I don't cover on YT
      Check out the docs for adding roles/custom claims to the token - I'm 99% sure there is support for that

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

    Thanks!

  • @tzurdo1
    @tzurdo1 ปีที่แล้ว +1

    Great content! As a relatively experienced developer I really enjoy your videos :)

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว +1

      Glad you like them! Any topics you'd like to see on my channel in the future?

  • @kodindoyannick5328
    @kodindoyannick5328 9 หลายเดือนก่อน +1

    Great video! You explain very very well. Thank you so much, Milan

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

    hello, i have this error when i check the JWT signed by Firebase at 23:47 => Authentication failed: IDX10500: Signature validation failed. No security keys were provided to validate the signature.
    Challenge: IDX10500: Signature validation failed. No security keys were provided to validate the signature.

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

      It should work if you set the Authority correctly

  • @mariomandzukic8676
    @mariomandzukic8676 ปีที่แล้ว +2

    Hi can you do for some of your future videos email confirmation method?

  • @salaheddinemaarouf1
    @salaheddinemaarouf1 ปีที่แล้ว +1

    Thank you very much for this high quality of videos and content. I wish you all the best ❤

  • @oneside5418
    @oneside5418 ปีที่แล้ว +1

    Thank you 😊 Milan🤩 great Explanation very helpful

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

    Shouldn't it be Access Token that's being sent to the backend? From my "reasearch", apparently Id token is for Client Side part of the application to identify the user, and Access Token is for authorization with the server side?

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

      Yes

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

      @@MilanJovanovicTech but Firebase doesnt provide a Access token like cognito does right? What is a good alternative in that case?

  • @deddykosasih387
    @deddykosasih387 ปีที่แล้ว +1

    Nice video. I see that you put the sensitive information on the wild (e.g. on screen, on appsettings), it might be obvious for experienced dev, but might not for some. Maybe it's good to mention briefly what's the good practise.

  • @francopioletti7043
    @francopioletti7043 ปีที่แล้ว +1

    Milan, at 8:17 the LoggingBackgroundJobSetup caught my attention, I wasnt in the quartz video you recently released, and I'm currently starting a proyect that uses quartz and could use that, did I missed it in another video?, can I see the code some where?

  • @danielacevedo1511
    @danielacevedo1511 ปีที่แล้ว +1

    Super useful, how do you parse de errors from the api? Wish I could download it

  • @jacopocaira5199
    @jacopocaira5199 ปีที่แล้ว +1

    Hey!
    It is possible to get the same result for Azure functions inside a Azure function App?

  • @Kylefuller002
    @Kylefuller002 11 หลายเดือนก่อน +1

    What would change if you were setting up a new project in .net 8. Can firebase hook into the new identity out of the box.

  • @MarcoDiScala
    @MarcoDiScala 11 หลายเดือนก่อน +1

    I'd like to ask if is possible to implements also External provider authentications, along to username and password.

  • @nicolasundiano8406
    @nicolasundiano8406 ปีที่แล้ว +1

    hi milan, i have a doubt: if you want to create roles and permissions, would you create them in your database or in firebase?

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว

      I'd probably store them in my own database, will be easier to manage

  • @dado.dzafic
    @dado.dzafic ปีที่แล้ว +1

    In microservice architecture, is it good practice to have this configuration just on Api Gateway or is better to have it on all services for security reasons? In the first scenario, how to add an authorize attribute on other services? In the second scenario it means that the request for a check token will duplicate, could that cause a problem?

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว +1

      I'm not sure if it's a "best practice" but my team and I used to also leave it on the individual services, just in case.

  • @matthewrossee
    @matthewrossee ปีที่แล้ว +1

    Hi Milan, what is the best way in your opinion to handle multiple user types in an application? Suppose we have Teacher, Student, etc... and each one of those has different properties. Is there a better way to do this than having IdentityUser that is used only to sign in, and aggregate roots in domain layer contain property IdentityId to reference the IdentityUser? The issue I have is that by design IdentityUser can be in multiple roles, but in my application the user can't have more than one role. Also what if an error occurred after creating IdentityUser, but before creating Teacher? It feels a little bit clunky to have an enum in IdentityUser like UserType, then doing _teacherRepository.GetByIdentityId(identityId); because there is no constraint at the database level that forbids creating Student aggregate for UserType.Teacher. What do you think? I can't find any article that says something about this.

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว

      You can nullable columns, inheritance. I would probably not mix any Identity concepts in my domain at all.

    • @matthewrossee
      @matthewrossee ปีที่แล้ว

      @@MilanJovanovicTech To me the solution with nullable columns seems cumbersome. It's strange that there's literally nothing in the Internet on this topic, because everyone just shows a simple example with "AppUser", but in real life applications there are multiple user types that need its own properties, so there must be a sane way of doing this.

  • @ruanpelissoli8453
    @ruanpelissoli8453 ปีที่แล้ว +1

    Awesome content Milan. A request: do a video about auth and realtime using supabase. Thanks

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว +1

      Ah, Supabase auth - the lost chapter :) Might do another video on that!

  • @aleksandardevic4426
    @aleksandardevic4426 ปีที่แล้ว +2

    Great content 😎 , maybe in future videos try to cover Multiple External Authentication with callbacks and part with refresh tokens. Best regards. 💪

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

    How do we refresh the token?

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

    hi Milan, what do you recommend? login in the backend or login in the front directly to firebase and send the token to the back?

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

      The latter one is simpler, and that's how you'd use an IDP anyhow

  • @marcusrosberg8502
    @marcusrosberg8502 ปีที่แล้ว +2

    Is this a free service we can use from firebase?

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว +2

      Yes, it's FREE up to 50k users per month

    • @marcusrosberg8502
      @marcusrosberg8502 ปีที่แล้ว

      @@MilanJovanovicTech thanks for the quick reply mate!:)

  • @Tamer_Ali
    @Tamer_Ali ปีที่แล้ว +1

    Thanks Milan for this awesome video 👍
    In the solution you have a Persistence project, you recommend this way over creating a Persistence folder under Infrastructure project?

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว

      Either one is fine :) Just use the approach that makes sense to you, and the amount of separation you want to achieve.

  • @ALOKSHARMAMD
    @ALOKSHARMAMD ปีที่แล้ว +1

    IMHO Microsoft Identity is more then enough in general use cases, didn't even had to use identity server or such extra layers. And im talking about a multi tenant complex project.

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว

      Yep, if you want to use it - gets the job done just as any other IDP

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

    Is it safe to store api keys in appsettings?

  • @microtech2448
    @microtech2448 ปีที่แล้ว +4

    This is what I don't like about external providers. Our users need to stay on their platform too? And this is kind of giving our user accounts to other services .

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว +1

      That is a problem, yeah. You can try Keycloak if that's a problem. It's free, open source, and you can host it yourself.

    • @microtech2448
      @microtech2448 ปีที่แล้ว +1

      @@MilanJovanovicTech thanks for introducing about new thing.
      And what are your thoughts on using own DB and authenticating and authorizing users against our DB? We just need to create some tables and configure jwt tokens and that would save us from external or even open source libraries which may become paid at later stages? Stay awesome 😎

  • @ashish-sharma-developer
    @ashish-sharma-developer 9 หลายเดือนก่อน

    Hello Milan Jovan sir,
    I recently watched your video on implementing Firebase authentication via email and password, and I found it incredibly helpful. However, upon attempting to implement the solution you provided, I encountered an unexpected error.
    Here's the error message I'm receiving:
    {
    "errorMessage": "The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.",
    "statusCode": 500,
    "message": "Internal Server Error!"
    }
    I've double-checked my implementation against the steps outlined in your video, and everything seems to be in place. Despite this, the error persists.
    Could you please provide some insight into what might be causing this issue and how I can resolve it?
    I'm waiting for your response.
    Thank you in advance for your help!

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

      Well, which request is taking 100 seconds...?

    • @ashish-sharma-developer
      @ashish-sharma-developer 6 หลายเดือนก่อน

      @@MilanJovanovicTech When dotnet application is trying to authenticate with firebase server.
      but now it's fixed. everything is working fine,
      Thank you so much

  • @caseyspaulding
    @caseyspaulding ปีที่แล้ว +1

    Thank you

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

    Save me from years of reseaching thanks

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

      You don't want to know how much time I spent researching this 😂

  • @jameshancock
    @jameshancock ปีที่แล้ว +3

    Firebase: how Google spys on users even when not using their platform.

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว +3

      You're literally on TH-cam - a Google product 😂

    • @jameshancock
      @jameshancock ปีที่แล้ว

      @@MilanJovanovicTech I’m doing so personally as a choice. I’m not opting in every one of my own customers to be tracked largely without their knowledge because Google gave me free stuff as a developer.
      BIG DIFFERENCE.

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว

      @@jameshancock There are OS alternatives that offer similar things, like Keycloak, Identity server etc

    • @jameshancock
      @jameshancock ปีที่แล้ว

      @@MilanJovanovicTech hence my point. Ethical devs don’t use firebase because Google uses it to spy on your users. Ethical devs don’t promote firebase for the same reason as soon as they become aware of how unethical firebase is.
      It’s literally why apps know what you did in other apps that had nothing to do with each other. It’s how Google spys in android while claiming android is just as privacy focused as iOS. It’s how they’ve infiltrated iOS with their effectively spyware in almost every app. And the kicker is that they primarily get you with push notifications to android and then suck you in to iOS notifications and then the rest. Try doing push notifications on android without it. It isn’t fun and batteries suffer almost always.
      An excellent series would be: how to be on mobile without Google firebase spyware.

  • @sipho4265
    @sipho4265 ปีที่แล้ว +2

    First.cs

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว +1

      You've got a compile error in there 🔍🔍🔍

  • @geertdoornbos
    @geertdoornbos ปีที่แล้ว +1

    There is no such thing as ' JWT Authentication'

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว

      How so?

    • @geertdoornbos
      @geertdoornbos ปีที่แล้ว

      Because it's called OpenID Connect. For years.
      Or, if your're using a specific Firebase SDK, it's Firebase authentication (or Google Identity Platform Authentication). Custom proprietary API.
      There is no such thing as 'JWT Authentication'. Show me the specs...

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว +3

      @@geertdoornbos Correctness aside, how many people will know what I'm talking about if I write:
      - OpenID Connect
      - JWT Auth
      What should matter is if I'm sharing something valuable or not in the video. Titles are there to attract attention.

    • @geertdoornbos
      @geertdoornbos ปีที่แล้ว

      @@MilanJovanovicTech Hey man, why are you always so defensive when it comes to feedback? I often see you justifying yourself for the reactions of others. Lose the arrogance and you'll be a much nicer person.

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว +1

      @@geertdoornbos Where was I arrogant, exactly?
      I'm trying to nicely explain that we're looking at things from different perspectives.
      Ever thought you're the arrogant one?
      Since you can't seem to fathom my POV.

  • @heshamabdo6024
    @heshamabdo6024 ปีที่แล้ว +1

    Thank you

  • @techpc5453
    @techpc5453 ปีที่แล้ว +1