microsoft / FeatureManagement-Dotnet

Microsoft.FeatureManagement provides standardized APIs for enabling feature flags within applications. Utilize this library to secure a consistent experience when developing applications that use patterns such as beta access, rollout, dark deployments, and more.
MIT License
1.02k stars 111 forks source link

Adds Default Targeting Accessor and extension method WithTargeting #466

Closed rossgrambo closed 1 month ago

rossgrambo commented 2 months ago

Why this PR?

  1. Addresses issues a. https://github.com/microsoft/FeatureManagement-Dotnet/issues/415
  2. Updates FeatureFlagDemo example to use the new extension

Visible Changes

Developers using ASP.NET will now have a new extension method available to them, WithTargeting(). Previously, they could only use WithTargeting<ITargetingContextAccessor>()

builder.Services.AddFeatureManagement()
    .WithTargeting()

This default accessor will extract the targeting info from HttpContext.User. Groups will be extracted from claims of type Role. UserId is taken from the Identity.Name field.

zhiyuanliang-ms commented 2 months ago

This is a new feature. After this is released, we need to update our public doc to introduce it.

zhiyuanliang-ms commented 1 month ago

@jimmyca15 @rossgrambo After this PR is merged, I think we can publish a new stable release. What do you think?

rossgrambo commented 1 month ago

Sounds good to me.

There was an issue with the build not starting. Should be fixed now, so I'll merge shortly.