-
Notifications
You must be signed in to change notification settings - Fork 245
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
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
- Logout
- 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.1Regression
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
Labels
questionFurther information is requestedFurther information is requested