Bitwarden.Server.Sdk.Features 1.1.0

Prefix Reserved
dotnet add package Bitwarden.Server.Sdk.Features --version 1.1.0
                    
NuGet\Install-Package Bitwarden.Server.Sdk.Features -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bitwarden.Server.Sdk.Features" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitwarden.Server.Sdk.Features" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Bitwarden.Server.Sdk.Features" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bitwarden.Server.Sdk.Features --version 1.1.0
                    
#r "nuget: Bitwarden.Server.Sdk.Features, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bitwarden.Server.Sdk.Features@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bitwarden.Server.Sdk.Features&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Bitwarden.Server.Sdk.Features&version=1.1.0
                    
Install as a Cake Tool

Bitwarden.Server.Sdk.Features

About

This package enables the use of feature flags to allow remotely toggling features. You can read more about feature management at Bitwarden by reading this ADR.

How to use

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddFeatureFlagServices();

var app = builder.Build();

app.UseRouting();

app.UseFeatureFlagChecks();

app.MapGet("/", () =>
{
    return Results.Ok("my-feature enabled!");
})
    .RequireFeature("my-feature");

app.Run();
class MyService(IFeatureService featureService)
{
    public void Run()
    {
        if (featureService.IsEnabled("my-feature"))
        {
            RunNew();
        }
        else
        {
            RunOld();
        }
    }
}

The [RequireFeature] attribute can also be placed on a controller class or individual controller actions.

Both the RequireFeature method on minimal API endpoints and the [RequireFeature] attribute require the UseFeatureFlagChecks() middleware to be registered. It needs to be after UseRouting and before UseEndpoints/Map*. If you rely on authentication information in your custom context builder then the middleware should also be registered after your authentication middleware.

Out of the box, this package binds our options object FeatureFlagOptions to the Features section of configuration. This means to enable the use of Launch Darkly you need to have Features:LaunchDarkly:SdkKey set. If no key is set then local flag values can be used through Features:FlagValues:<Key>=<Value>. This can be helpful for local development.

Features:KnownFlags must be populated with all flag keys that you wish to be returned from IFeatureService.GetAll(). If you have no need to use that method you do not need to add values to that option. IFeatureService.IsEnabled and other single feature checks should continue to work just fine without it.

Example JSON configuration:

{
  "Features": {
    "FlagValues": {
      "my-flag": true,
      "another-flag": false
    },
    "KnownFlags": ["my-flag"],
    "LaunchDarkly": {
      "SdkKey": "your-sdk-key"
    }
  }
}

Customization

Context Builder

By default the feature flag context will be for an anonymous user. This doesn't allow granular targeting of feature flag values. To enable this you can implement your own IContextBuilder and register it using services.AddContextBuilder<MyContextBuilder>(). Learn more about context configuration by reading the code docs on IContextBuilder and reading Launch Darkly's docs on context configuration.

OnFeatureCheckFailed

The response that is sent back to the client on failed feature checks will return a problem details formatted error with a 404 status code by default but this can be customized through the OnFeatureCheckFailed property on FeatureCheckOptions.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 831 11/11/2025
1.0.0 281 11/10/2025
0.3.0-beta.1 105 11/7/2025
0.1.0 639 9/18/2025
0.0.3-beta.1 481 2/24/2025