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.
![image](https://user-images.githubusercontent.com/7569380/51987941-65ebe500-249b-11e9-87c5-9bd70c5fb8eb.png)
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:
![image](https://user-images.githubusercontent.com/7569380/51988157-eb6f9500-249b-11e9-86b6-95f48ac0fff8.png)
IN the OnSecurityTokenValidated Method:
I have create two objects from the context:
![image](https://user-images.githubusercontent.com/7569380/51988305-45705a80-249c-11e9-88d8-86632bcef6f8.png)
the user principal is being set.
![image](https://user-images.githubusercontent.com/7569380/51988704-40f87180-249d-11e9-8b1e-d83eafd2e93b.png)
however, the context has no claims. Also User.Identity.Name thereefore is null:
![image](https://user-images.githubusercontent.com/7569380/51988805-81f08600-249d-11e9-8488-28f330b1cd78.png)
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?