#30MinsLearning Day 12, in the code implementation, this Context.SignInAsync() method got me confused for quite a while. Firstly, there's no SignInAsync() method on HttpContext class: learn.microsoft.com/en-us/dotnet... ...
Bluesky

Bluesky Social
Digging a bit, there's actually an extension method described here: learn.microsoft.com/en-us/dotnet.... Good, what does that actually do?
AuthenticationHttpContextExtensions.SignInAsync Method (Microsoft.AspNetCore.Authentication)

Sign in a principal for the default authentication scheme. The default scheme for signing in can be configured using DefaultSignInScheme.

Time to dig out the .net source: source.dot.net/Microsoft.As... It calls GetAuthenticationService and then calls SignInAsync on that. Right, what does GetAuthenticationService mean?
SignInAsync

Well, it gets the service of IAuthenticationService from the IoC container. That means, some code is registering IAuthenticationService, and what is that? 🤔
In ASP.NET Core Identity, the `AddDefaultIdentity<TUser>` looks ... suspecious because it calls `AddAuthentication()` for us.
Follow the lead, the AddAuthentication calls AddAuthenticationCore():
And then it registers AuthenthicationServiceImpl as IAuthenticationService:
Okay, cool. But what does it do? Let's find out together the next time 😁