I\'m using .NET Core 3.0 Preview6.
We have an Intranet application with enabled Windows authentication which means that only valid AD users are allowed to use the applicatio
This is fixed now. It's been a bug in the preview releases. Now it's working like intended. Good luck!
Update: I'd like to post my working code for .NET Core 3.1 Final.
Configure
: app.UseAuthentication();
app.UseAuthorization();
app.UseMiddleware<AutoLoginMiddleware>();
In the custom middleware, after signing in the user you must call CreateUserPrincipalAsync
and save this principal to the HttpContext.User
property.
await signInManager.SignInAsync(user, true);
context.User = await signInManager.CreateUserPrincipalAsync(user);
For Blazor, we must use AuthenticationStateProvider
. It has a property User
which contains the ClaimsPrincipal
from HttpContext
. That's it.
You are now able to get the Identity user like follows:
var authState = await _authenticationStateProvider.GetAuthenticationStateAsync();
var intranetUser = await UserManager.GetUserAsync(authState.User);