Hi,
I'm trying to implement this into my app (i.e. aspnetcore 2.2 and Azure AD). I can login to the app via Azure AD fine.
I have implemented OnSecurityTokenValidated so that i can check that I'm receiving token and claims correctly, which is the case.
However, for some reason, I'm receiving a blank User.Identity (although it is not null). This means there are no claims and Name property is null.
It looks to me that somehow the HttpContext is not being set correctly with this data. However, where should this be happening? I checked the code in this repository and it's not clear what copying the login data to the HttpContext.User
This object has claims:
IN the OnSecurityTokenValidated Method:
I have create two objects from the context:
the user principal is being set.
however, the context has no claims. Also User.Identity.Name thereefore is null:
I've also tried carrying out a manual signin, but that doesn't work either:
`
private async Task SignInUser(TokenValidatedContext tokenValidatedContext)
{
var httpContext = tokenValidatedContext.HttpContext;
var userPrincipal = tokenValidatedContext.Principal;
await httpContext.SignOutAsync(AppSettings.CookieName);
await httpContext.SignInAsync(AppSettings.CookieName, userPrincipal,
new AuthenticationProperties
{
ExpiresUtc = DateTime.UtcNow.AddDays(1),
IsPersistent = false,
AllowRefresh = false
});
}
`
Any ideas what I am doing wrong?