authenticationumbracoopenidduende

Umbraco - Duende server OpenIDconnect: InvalidOperationException


I have a Duende server and a web client and there aren't problems with the OpendID connection. I followed the documentations according this link https://docs.duendesoftware.com/identityserver/v7. Now I'm trying to connect Umbraco web client with my Duende server. I followed this solution https://github.com/jbreuer/Umbraco-OpenIdConnect-Example/tree/main After login, In UmbracoBuilderExtensions.cs the name is null ( rif. var name = claims?.SingleOrDefault(x => x.Type == "user_displayname"); ) and in UmbExternalLoginController.cs the loginInfo is null. So, I have this error in the browser InvalidOperationException: The Name value cannot be null Some ideas? Sergio


Solution

  • If the name is missing, then you need do some claim mapping. Look inside the ID-token and determine what the name of the name claim is.

    So, if the name claim is named "name", then do this:

    .AddOpenIdConnect(options =>
    {
        ...
        options.TokenValidationParameters = new TokenValidationParameters
        {
            NameClaimType = "name",
            RoleClaimType = "role"
        };
        ...
    }
    

    You can read more about this problem in my blog post here: Debugging OpenID Connect Claim Problems in ASP.NET Core