Adding JWT Authentication in ASP.NET Core With Supabase Auth

Поделиться
HTML-код
  • Опубликовано: 12 янв 2025

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

  • @MilanJovanovicTech
    @MilanJovanovicTech  7 месяцев назад +1

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

  • @joshuadawson8237
    @joshuadawson8237 2 месяца назад

    Thanks for the guide. Was having some issues with Auth0 so tried this and working well for me frontend and now api. Thank you!

    • @MilanJovanovicTech
      @MilanJovanovicTech  2 месяца назад

      Glad it helped! Are you switching to Supabase?

    • @joshuadawson8237
      @joshuadawson8237 2 месяца назад

      @ trying it out. I’m used to identity server but trying other solutions.

  • @ramax495
    @ramax495 7 месяцев назад +4

    Why do you set "ValidateIssuerSigningKey" to "true"? This option is for asymmetric algorithms if I'm not mistaken. And in this JWT is used HS256 algorithm.

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

      You're correct! It's not needed. Setting the IssuerSigningKey is enough.

  • @dotnetMasterCSharp
    @dotnetMasterCSharp Месяц назад

    Awesome content, thank you Milan!

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

    Great video. Thank you for making. Im watching 3x times now. Im new to both dotnet and also postgres. This helps alot.
    By the way, at 1:04 what program are you using to visualise the schema?

  • @wicho5401
    @wicho5401 7 месяцев назад +3

    What would you recommend for and small production app?
    Supabase
    Keycloack
    Custom IdentityServer

    • @MilanJovanovicTech
      @MilanJovanovicTech  7 месяцев назад +1

      Supabase/Firebase auth are both great, easy to setup, and "just work". Keycloak you will need to host yourself, which could be a hassle.

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

    Just a note, the response from the refresh token endpoint doesn't seem to return a cached response. The access token is different for each request. You can even see it in the video. What would be the difference between using a login compared to the refresh endpoint?

    • @MilanJovanovicTech
      @MilanJovanovicTech  5 месяцев назад +1

      You're right, I'm not 100% sure what I wanted to say there 🤔 I believe just the expiration time changes, which alters the access token signature.

  • @patasmajeris
    @patasmajeris 6 месяцев назад +2

    I think good video should be showing how to add Supabase Auth to Blazor SSR (and if possible SR, WebAssembly)

    • @MilanJovanovicTech
      @MilanJovanovicTech  6 месяцев назад

      I rarely cover client-side topics, but that's a nice suggestion

  • @matthewrossee
    @matthewrossee 6 месяцев назад

    How would you add authorization to an app that uses Supabase authentication? There's a possibility to create custom supabase hook that adds additional claims to the JWT, but I was wondering if it was better to store roles/permissions against the user identifier directly in the database (the one that aspnet core app uses, not the supabase db) and implement authorization handler that checks if there's a valid record in the database. What do you think?

    • @MilanJovanovicTech
      @MilanJovanovicTech  6 месяцев назад

      I honestly think that Auth hooks are too good to pass on. So easy to just check the claims. Don't you think?

  • @Clemens-j7u
    @Clemens-j7u 3 месяца назад

    Can i also use this way to protect my pages in blazor with the authorization view or should i use another way?

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

      I think you can, but check if there are some examples out there

  • @manzot7646
    @manzot7646 6 месяцев назад

    Is it possible to not include some function to require an accessToken? For Example Login and Register (made with Supabase authentication) shouldn't require an AccessToken.
    If I'm using Controllers how can I require the authorization in them?

  • @vinp2007
    @vinp2007 7 месяцев назад +1

    is this something like keycloak like an authentication aggregator but light weight?

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

      Supabase is a much more feature-rich platform. The auth component is just one part of it, and it's a fully-fledged solution (OAuth, social logins, SSO)

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

    Awesome video man! I have one question for this video, what about RLS you disabled it for the video but when I want to query supabase it uses anon token and not the token that I send from postman (frontend). Ive looked every way to somehow set the new token to supabaseClient but I cant get it to work. Thank you!

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

      Is this an issue of the supabase client perhaps?

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

      @@MilanJovanovicTech I don't know either. I think the supabase client needs the active session which I dont have on my backend because I manage session on frontend. I tought that there is some way to include just a access token to supabase client query. I think that I will need to call supabase api directly from backend without supabase client. I tested this using postman and it works. Is this the right move ? Thank you

  • @ruekkart
    @ruekkart 7 месяцев назад +1

    Can we use this together with Microsoft Identity users? Also, what if we need to manage users directly from our apps?

    • @sunzhang-d9v
      @sunzhang-d9v 7 месяцев назад

      I also want to ask, is user registration also registered to supabase, the main logic is on our side, supabase just does user data synchronization

    • @MilanJovanovicTech
      @MilanJovanovicTech  7 месяцев назад +1

      No, I don't think these two go well together. 🤔

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

    Hi Milan, could you make a video about many to many relationships in domain driven design? I don’t know how to design my aggregates. Also, do you think that relationships between aggregates should be resolved via ef core HasMany/HasOne foreign keys, or should the relationships be updated manually in domain event handler, like Amichai Mantinband does?

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

      Check out my recent video on DDD Aggregates

    • @matthewrossee
      @matthewrossee 6 месяцев назад

      @@MilanJovanovicTech I've watched it, but unfortunately there isn't a case with many to many relationship.

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

    i have sign in and up endpoints with oauth providers, should i have a endpoint for the callback o that should be on the front?

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

      Callback is on the UI typically, as the OAuth provider will append some query parameters

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

    Thanks for this informative video. Does it supports "Onbehalf" flow?

  • @SecretMember-n9d
    @SecretMember-n9d Месяц назад

    Adding ValidateIssuer = false resolves the issue, but without it, I get a 401 error. What could be the reason for this?

    • @SecretMember-n9d
      @SecretMember-n9d Месяц назад

      I found the reason. When using a custom domain, the iss value changes, so ValidateIssuer must be set to false

    • @MilanJovanovicTech
      @MilanJovanovicTech  Месяц назад

      Interesting. But you should be able to specify who the valid issuer is, right?

    • @SecretMember-n9d
      @SecretMember-n9d Месяц назад

      ​@@MilanJovanovicTech That's right. When setting it up, we can configure multiple valid issuers, right? At that time, adding the previous domain along with the custom domain resolved the issue without any problems. The only downside is that I wish they had returned the custom domain during the validation process. Well, since the custom domain can be changed at any time, it might actually be better to stick with the original domain.

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

    How to prevent IDOR vulnerabilities?

  • @OscarGarcia-up3ph
    @OscarGarcia-up3ph 6 месяцев назад

    Could you make a tutorial on Authentication using Keycloak? I love this videos

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

    How to setup the Auth Hooks?

  • @aymenbachiri-yh2hd
    @aymenbachiri-yh2hd 2 месяца назад

    Thank you so much

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

    Please make a video .NET core with oracle database

  • @tungvu4339
    @tungvu4339 2 месяца назад

    subscribed!!!