After logging in 'User.Identity.Name' is null, but 'IsAuthenticated' is true when using Sustainsys.Saml2.Mvc integration
You have properly completed the authentication. And you have a working session authentication cookie.
What you don't have however is a claim that matches the default name claim type. You have the NameIdentifier claim (which is what the stub idp supplies by default). But you don't have a claim with the default NameClaimType
The Name
property of a ClaimsIdentity
is implemented as
return Claims.FirstOrDefault(c => c.Type == NameClaimType)?.Value;
So to get a value on the Name
property you either need to change the NameClaimType
(can be done by modifying the created identity in the AcsCommandResultCreated
notification) or get your Idp to provide an attribute of type http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
. You can do that by adding an attribute at the bottom of the stubidp form.