Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

OpenID Connect Error with Azure AD #5991


User avatar
0
netaji.sapkal created

Hello Support, There is bug in below method in case Active Directory user Name doesn't have space in the Name property (claim) . please see the method GetUserInfo in OpenIdConnectAuthProviderApi class there is no check for  handling array as mentioned below. Please fix this ASAP. var fullNameParts = fullName.Split(' '); **Name = fullNameParts[0], **This line give error if AD User doesn't have Space

public override async Task<ExternalAuthUserInfo> GetUserInfo(string token)
{
    var issuer = ProviderInfo.AdditionalParams["Authority"];
    if (string.IsNullOrEmpty(issuer))
    {
        throw new ApplicationException("Authentication:OpenId:Issuer configuration is required.");
     }
    var configurationManager = new ConfigurationManager\<OpenIdConnectConfiguration>(
        issuer + "/.well-known/openid-configuration",
    new OpenIdConnectConfigurationRetriever(),
    new HttpDocumentRetriever());
    var validatedToken = await ValidateToken(token, issuer, configurationManager);
    var fullName = (c => c.Type == "name").Value;
    var email = validatedToken.Claims.First(c => c.Type == "unique_name").Value;
    var fullNameParts = fullName.Split(' ');
    
    return new ExternalAuthUserInfo
    {
        Provider = Name,
        ProviderKey = validatedToken.Subject,
        Name = fullNameParts[0],
        Surname = fullNameParts[1],
        EmailAddress = email
    };
}

1 Answer(s)