Skip to content

"utid" (home tenant id) missing in claims after update from 2.14.0 to 2.15.1 #2508

@rufer7

Description

@rufer7

Microsoft.Identity.Web Library

Microsoft.Identity.Web

Microsoft.Identity.Web version

2.15.1

Web app

Sign-in users

Web API

Protected web APIs call downstream web APIs

Token cache serialization

Distributed caches

Description

I have a .NET Core 7 Web API that registers a delegate to the OnTokenValidated event and then uses the claim utid in the event handler. However after updating from 2.14.0 to 2.15.1 I don't get the utid claim (home tenant id) not anymore.

Reproduction steps

  1. Logout
  2. Login

Error message

None

Id Web logs

No response

Relevant code snippets

ServiceCollectionExtensions.cs

        services.AddMicrosoftIdentityWebAppAuthentication(configuration)
            .EnableTokenAcquisitionToCallDownstreamApi(initialScopes)
            .AddMicrosoftGraph(defaultScopes: initialScopes)
            .AddDistributedTokenCaches();

        services.AddScoped<CustomClaimsTransformator>();

        services.Configure<MicrosoftIdentityOptions>(OpenIdConnectDefaults.AuthenticationScheme, options =>
        {
            options.Events.OnTokenValidated = async context =>
            {
                var applicationServices = context.HttpContext.RequestServices;
                if (context.Principal != null)
                {
                    using var scope = applicationServices.CreateScope();
                    context.Principal = await scope.ServiceProvider
                        .GetRequiredService<CustomClaimsTransformator>()
                        .TransformAsync(context.Principal);
                }
            };
        });

CustomClaimsTransformator.cs

public class CustomClaimsTransformator
{
    public async Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
    {
        var homeTenantId = principal.GetHomeTenantId(); // THIS RETURNS NULL AFTER UPDATE TO 2.15.1

Regression

No response

Expected behavior

As the version change from 2.14.0 to 2.15.1 is a minor version bump I would expect the utid claim as in v 2.14.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions