New .NET 8 Authentication Features in ASP.NET Core

Поделиться
HTML-код
  • Опубликовано: 5 фев 2025
  • .NET 8 brings new authentication features that are still in preview. SUPER simple bearer token authentication for your api and integration with the identity framework.
    Support my Work 🤝 / raw_coding
    Buy my Courses 📚 learning.raw-c...
    Buy my Merch 🛒 shop.raw-codin...
    Join the Community 💬 / discord
    Tweet Tweet 📣 / anton_t0shik
    Tune in LIVE! 🎥 / raw_coding
    #aspnetcore #dotnet8 #csharp

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

  • @alijamal7893
    @alijamal7893 Год назад +32

    can you use dark mode please .. it's better to our eyes

    • @RawCoding
      @RawCoding  Год назад +48

      What doesn’t kill you makes you stronger

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

      @@RawCoding 😅😅🤣

    • @DeepWorksStudios
      @DeepWorksStudios Год назад +5

      @@RawCoding after working for a long time, the eyes hurt, so a darker mode would be appropriate

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

      dark mode not good for some disabled people.

    • @13O42O
      @13O42O Год назад +3

      @@DeepWorksStudios after working for a long time, consider taking a rest.

  • @19balazs86
    @19balazs86 Год назад +7

    I was just thinking this week about "Anton will surely create a video about the new authentication process/features". And here it comes 😀
    Thanks for the explanation. Better than MS documentation.

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

    Awesome stuff! I love in-depth videos about authentication

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

    Great video as usual. I stopped the video to check that I was not on 1.5x speed, you are too fast xD I would appreciate it if you could be a little slower when explaining new concepts :)
    Regarding the new Auth am I getting it correctly that the new things are:
    - We now can put the session token as a Bearer token since we have it as auth_token in response and before only the cookie mode was supported? So it's like a way to avoid our custom token providers and just use this approach with SPA and mobile clients.
    - We have a bunch of endpoints for Asp Identity as minimal API which we can use without Razore pages and all this old stuff, with Sap and mobile clients.
    - We are not sure in what scenarios we can use it. Maybe a simple web app with SPA + mobile client is a good fit to avoid our own JWT token provider and custom auth endpoints

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

    Awesome, thank you for your content ! I learned a lot :D finally i choosed C# over java lol.. im loving net for your content

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

    thanks! you deserve many more subscribers!

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

    Why are they injecting IServiceProvider and then manually resolving dependencies like UserManager, instead of just injecting it via method arguments like [FromServices] UserManager?

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

    Thanks for this usefull insight!
    Keep producing your valuable content!

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

    I posit that we are, quite conceivably, an exclusive duo amidst the global populous, electing to utilize the light theme for our Integrated Development Environments, a choice seemingly eschewed by the majority.

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

    Hey Raw Coding,
    I work with the stack Nextjs as frontend / bff backend and dotnet as the backend
    would the nextjs bff comunicating with the dotnet via bearer and keeping this bearer in a secure cookie token make a better security for the token?

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

      Just use cookies

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

      @zeuga6111 do you use CORS when connecting your C# backend to Next JS front end or do you use BFF?

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

    They should make it the Identity API easier and remove the existing bloat so that developer write these handlers themselves and be able to customize it for any special case

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

      They can’t remove - otherwise it’s breaking changes. Introducing new packages means people have to rewrite.
      It’s a sticky situation you have to get it right the 1st time.

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

    will those endpoints for login and register show in swagger? maybe we can override it or if your app have the same endpoints it ignore the built it one?

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

      Aye that’s a good point I think it will actually show up in swagger since it’s just another endpoint on the minimal api

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

      They do!

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

    Not directly related and maybe you've discussed this topic in other contexts that I've missed, but curious what IDE or editor you're using here and how it compares to visual studio.

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

      Rider and I think it’s miles better

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

      JetBrains Rider. There are a few things it's missing(some integrations with Roslyn, like Diagnostic Suppressors), but other than that it loads way faster, has better IntelliSense, more extensible, and is a lot cheaper than a Visual Studio license.
      Oh, and it's cross platform(Mac, Linux, and Windows) unlike Visual Studio which is just on Windows

  • @user-sq7ry5vx7t
    @user-sq7ry5vx7t Год назад

    In what aspects is this different from old Identity Framework? Seems exactly what everyone was doing a few years ago before the jump to IdentityServer and its subsequent demise.

  • @w4.k
    @w4.k Год назад +2

    Do you have statistics for the average number of minutes watched on this video? Guess most of us got conjunctivitis at ‏‪0:33‬‏

  • @ManderO9
    @ManderO9 Год назад +7

    holly shit my eyes, why are you using light theme

    • @RawCoding
      @RawCoding  Год назад +5

      So you’d have something to complain about

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

      Summer is a good time to not work at night😂

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

      @@RawCoding Replies like these ain't the way you wanna go if you want to gain subscribers.

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

      ​@@OeHomestead could you elaborate what I could've answered with please

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

    Ok is there a simplification of JWT usage?

  • @user-re6bu7dy1l
    @user-re6bu7dy1l Год назад +1

    You can disable /Account/Login redirect via header? Can you post link to the docs/your video where you mention this?

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

      No link to docs but you can have the source code )
      github.com/dotnet/aspnetcore/blob/240377059ec25b4d9d86d4188a26722e55edc5a1/src/Security/Authentication/Cookies/src/CookieAuthenticationEvents.cs#L44

    • @user-re6bu7dy1l
      @user-re6bu7dy1l Год назад

      ​@@RawCoding Thanks!

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

      this might be too late but you can just override the behavior of the .OnRedirectToLogin event:
      .AddCookie("your_scheme", o =>
      {
      o.Events.OnRedirectToLogin = rc =>
      {
      rc.Response.StatusCode = StatusCodes.Status401Unauthorized;
      return Task.CompletedTask;
      };
      // you might also wanna override this:
      o.Events.OnRedirectToAccessDenied = rc =>
      {
      rc.Response.StatusCode = StatusCodes.Status403Forbidden;
      return Task.CompletedTask;
      };
      });

  • @AbhishekPatel-d9z
    @AbhishekPatel-d9z 11 месяцев назад

    How to do client certificate base authentication in .NET 8

  • @cocoscacao6102
    @cocoscacao6102 Год назад +4

    IdentityUser, SignInManager, Result.SignIn, HttpContext.SignIn... I don't know how you do it man... Either I'm dumb, or auth in Net is an utter shitshow...

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

    @RawCoding I think with Minimal APIs you cannot handle FormPosts not even on your own endpoint, period.

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

      You can via HttpRequest and then reading the body. And I think support for FromForm is actually coming in net 8

    • @davidfowl
      @davidfowl Год назад +4

      Form binding is supported for minimal APIs in .NET 8

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

    Dot net 8 final is released on Nov 14 now make vedios bro

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

    Awesome video, thanks! Could you make a video showing how to use Azure Ad authentication (with the AddMicrosoftIdentityWebAppAuthentication method) in a container running without TLS certificate? There is a problem that the app sets the redirect url as .., and that is not allowed as a callbackpath in Azure App Registration.. And if I set the redirect url manually by using the following code I get a correlation error in some authentication handler that I'm not smart enought to debug.. Any advice or chance for a video? 🙂
    builder.Services.Configure(OpenIdConnectDefaults.AuthenticationScheme, options =>
    {
    options.SaveTokens = true;
    options.Events = new OpenIdConnectEvents
    {
    OnRedirectToIdentityProvider = ctx =>
    {
    if (ctx.ProtocolMessage.RedirectUri.Contains("https") is false)
    {
    ctx.ProtocolMessage.RedirectUri = ctx.ProtocolMessage.RedirectUri.Replace("http", "https");
    }
    return Task.CompletedTask;
    }
    };
    });

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

    please update that browser, the poor guy

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

    hi, hello I have a comment related identity server on other video please have look and response

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

    .AddIdentityBearerToken has already disappeared ! in Preview 7