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
<PackageReference Include="Bitwarden.Server.Sdk.Features" Version="1.1.0" />
<PackageVersion Include="Bitwarden.Server.Sdk.Features" Version="1.1.0" />
<PackageReference Include="Bitwarden.Server.Sdk.Features" />
paket add Bitwarden.Server.Sdk.Features --version 1.1.0
#r "nuget: Bitwarden.Server.Sdk.Features, 1.1.0"
#:package Bitwarden.Server.Sdk.Features@1.1.0
#addin nuget:?package=Bitwarden.Server.Sdk.Features&version=1.1.0
#tool nuget:?package=Bitwarden.Server.Sdk.Features&version=1.1.0
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 | Versions 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. |
-
net8.0
- LaunchDarkly.ServerSdk (>= 8.10.3)
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 |