Authentication made easy with ASP.NET Core Identity in .NET 8

preview_player
Показать описание

ASP.NET Core Identity is the simplest approach to implementing authentication in .NET. With a few simple configuration steps, you can have cookie and token authentication up and running in minutes. Identity can also integrate with EF Core, allowing you to customize the database. In this video, I'll show you how to get started with ASP.NET Core Identity. We'll also explore the brand-new Identity endpoints.

Master Claims Transformation for Flexible ASP.NET Core Authorization

Join my weekly .NET newsletter:

Read my Blog here:

Subscribe for more:

Chapters
0:00 Configuring Authorization and Authentication
0:49 Adding ASP.NET Core Identity
4:27 Customizing the IdentityDbContext
6:27 Testing the .NET 8 Identity endpoints
8:05 Implementing token authentication
8:55 Adding Authentication to endpoints
Рекомендации по теме
Комментарии
Автор

Milan's videos' value per second is always so high, lol. Absolutely no fluff whatsoever.

dotnetbuilds
Автор

It's explained really nicely, I like that you don't waste time and get straight to the point. Completely different from the official Microsoft documentation and tutorials, which rely on already generated code or don't have an easy to navigate structure. Thank you!

aiviskri
Автор

Great video! One thing was missed when discussing adding JWT tokens. If you are going to add both Application Cookies and Jwt Bearers, things are going to get wonky. Using the provided solution, you have to manually specify which scheme you want to use for every request. This code didn't work in Postman using JWT for example and would return a 404.

The solution is to change the Authorization setup to the following:
=>
{
var policy = new AuthorizationPolicyBuilder(IdentityConstants.ApplicationScheme,
.RequireAuthenticatedUser()
.Build();

options.DefaultPolicy = policy;
});

This means anything tagged with [Authorize] will allow both schemes automatically.

jonahl
Автор

This is Awesome and more helpful for Devs; Thank you!

dotnetMasterCSharp
Автор

wow. this makes things easier. i use to make the endpoints manually.

arnelirobles
Автор

I know that identity is simple enough here but it could be really good to have a video on using oidc external authentication providers and how to configure oidc in dotnet backends together with a frontend application using maybe the bff pattern?😊

Mig
Автор

thanks thanks. I've been waiting for this video

itirush
Автор

I wonder how can I add this to my project which follows clean architecture and DDD. I has a thought that I can put the ApplicationUser and related terms inside Infrastructure/Identity, include a foreign key from ApplicationUser to my domain user (customer and staff), change the DbContext to IdentityDbContext, add loginservice in Application layer. Is this okay?

nguyentrungkien
Автор

Hey I wonder how we use TwoFactorAuthentication in identity with using google or microsoft authenticator app can you make a video for this topic?

yunusemreteke
Автор

Hello Milan can we add other models to this identity dbcontext? and when we run migration will it change them as well or just users

mariomandzukic
Автор

Which layer would the IdentyUser exist in a Clean Architecture solution? And how would it affect other layers?

chrisauret
Автор

No authenticationScheme was specified, and there was no DefaultChallengeScheme found. The default schemes can be set using either AddAuthentication(string defaultScheme) or configureOptions).

aqorda
Автор

how can I add custom claims on register, is it possible? I wanted to be able to add custom Role authorization in the apis but I haven't found a way so far... Also, disabling the register endpoint would be useful for sure

rodrigo-
Автор

I Notice that Custom Property you Added [Initial] doesn't apply value or any custom property like [FirstName, LastName, ...], is that normal?
and thank you for your great video

hozmannew
Автор

Can I integrate web api with external authentication service like google or facebook with this library, without blazor identity side or mvc ?

tomekres
Автор

Why only run migrations on development? How do you apply them in other environments?

hdjfgt
Автор

Great, thanks! But can we use JWT here? or just Bearer?

yuravertsimaga
Автор

What do I need to adjust to use int as a key for all the generated classes

ha
Автор

hello, I have an error when I'm trying to use a custom User:IdentityUser. The error is was not authenticated. Failure message: Unprotected token failed".
If I use DbContext with simply IdentityDbContext all work.
Please can you help?

fredchess
Автор

we need more videos like this which covers full end to end steps

tayyabshaikh