From c24931f098e5f471b56ddf6fc145606bc1fb6a94 Mon Sep 17 00:00:00 2001 From: mikemao Date: Wed, 11 Mar 2026 16:20:28 +1300 Subject: [PATCH 1/2] Refactor role claim retrieval to use identity-specific role claim type --- .../DefaultHttpTargetingContextAccessor.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.FeatureManagement.AspNetCore/DefaultHttpTargetingContextAccessor.cs b/src/Microsoft.FeatureManagement.AspNetCore/DefaultHttpTargetingContextAccessor.cs index f2fe6201..fa9aadc7 100644 --- a/src/Microsoft.FeatureManagement.AspNetCore/DefaultHttpTargetingContextAccessor.cs +++ b/src/Microsoft.FeatureManagement.AspNetCore/DefaultHttpTargetingContextAccessor.cs @@ -53,8 +53,8 @@ public ValueTask GetContextAsync() // // Treat claims of type Role as groups - IEnumerable groups = httpContext.User.Claims - .Where(c => c.Type == ClaimTypes.Role) + IEnumerable groups = httpContext.User.Identities + .SelectMany(identity => identity.Claims.Where(c => c.Type == identity.RoleClaimType)) .Select(c => c.Value) .ToList(); From 6dd513050fe195da15b3a86598ba5b63b788874c Mon Sep 17 00:00:00 2001 From: Mike Mao Date: Fri, 13 Mar 2026 08:38:43 +1300 Subject: [PATCH 2/2] Apply suggestion from @rossgrambo Co-authored-by: Ross Grambo --- .../DefaultHttpTargetingContextAccessor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.FeatureManagement.AspNetCore/DefaultHttpTargetingContextAccessor.cs b/src/Microsoft.FeatureManagement.AspNetCore/DefaultHttpTargetingContextAccessor.cs index fa9aadc7..338da601 100644 --- a/src/Microsoft.FeatureManagement.AspNetCore/DefaultHttpTargetingContextAccessor.cs +++ b/src/Microsoft.FeatureManagement.AspNetCore/DefaultHttpTargetingContextAccessor.cs @@ -56,6 +56,7 @@ public ValueTask GetContextAsync() IEnumerable groups = httpContext.User.Identities .SelectMany(identity => identity.Claims.Where(c => c.Type == identity.RoleClaimType)) .Select(c => c.Value) + .Distinct() .ToList(); TargetingContext targetingContext = new TargetingContext