From 99e0770fede7fb1867f0ce94daf8da92020c78ff Mon Sep 17 00:00:00 2001
From: Justin Baur <19896123+justindbaur@users.noreply.github.com>
Date: Fri, 20 Dec 2024 09:33:42 -0500
Subject: [PATCH] Move Features to SDK (#70)
* Move features to SDK
* Finish Features Migration
* Update Mode
* Lower TargetFramework
* Lower Microsoft.AspNetCore.TestHost Version
---
bitwarden-dotnet.sln | 30 ++++--
.../examples/MinimalApi/MinimalApi.csproj | 13 ---
.../examples/MinimalApi/Program.cs | 21 ----
.../MinimalApi/Properties/launchSettings.json | 41 --------
.../src/BitwardenHostOptions.cs | 16 ----
.../src/Features/IFeatureMetadata.cs | 9 --
.../examples/Standard/Program.cs | 18 ++++
.../Standard/Properties/launchSettings.json | 23 +++++
.../examples/Standard/Standard.csproj | 27 ++++++
.../Standard/appsettings.Development.json} | 3 +-
.../examples/Standard/appsettings.json} | 9 +-
.../src/Bitwarden.Server.Sdk.csproj | 32 ++++++-
.../FeatureApplicationBuilderExtensions.cs | 4 +-
.../Features/FeatureCheckMiddleware.cs | 6 +-
...tureEndpointConventionBuilderExtensions.cs | 2 +-
.../Content}/Features/FeatureFlagOptions.cs | 4 +-
.../FeatureServiceCollectionExtensions.cs | 2 +-
.../src/Content/Features/IFeatureMetadata.cs | 18 ++++
.../src/Content}/Features/IFeatureService.cs | 4 +-
.../Features/LaunchDarklyFeatureService.cs | 12 ++-
.../src/Content}/Features/LoggerExtensions.cs | 7 +-
.../Features/RequireFeatureAttribute.cs | 4 +-
.../src/Content}/HostBuilderExtensions.cs | 96 +++++--------------
.../Utilities/HostEnvironmentExtensions.cs | 9 +-
.../Content/Utilities/InternalConstants.cs | 7 ++
.../src/Content}/Utilities/VersionInfo.cs | 9 +-
.../Bitwarden.Server.Sdk/src/Sdk/Sdk.targets | 17 +++-
.../Bitwarden.Server.Sdk.UnitTests.csproj | 28 ++++++
...eatureApplicationBuilderExtensionsTests.cs | 4 +-
.../Features/FeatureCheckMiddlewareTests.cs | 6 +-
...ndpointConventionBuilderExtensionsTests.cs | 4 +-
...FeatureServiceCollectionExtensionsTests.cs | 4 +-
.../LaunchDarklyFeatureServiceTests.cs | 4 +-
.../Content}/Utilities/VersionInfoTests.cs | 4 +-
34 files changed, 277 insertions(+), 220 deletions(-)
delete mode 100644 extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/MinimalApi.csproj
delete mode 100644 extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/Program.cs
delete mode 100644 extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/Properties/launchSettings.json
delete mode 100644 extensions/Bitwarden.Extensions.Hosting/src/BitwardenHostOptions.cs
delete mode 100644 extensions/Bitwarden.Extensions.Hosting/src/Features/IFeatureMetadata.cs
create mode 100644 extensions/Bitwarden.Server.Sdk/examples/Standard/Program.cs
create mode 100644 extensions/Bitwarden.Server.Sdk/examples/Standard/Properties/launchSettings.json
create mode 100644 extensions/Bitwarden.Server.Sdk/examples/Standard/Standard.csproj
rename extensions/{Bitwarden.Extensions.Hosting/examples/MinimalApi/appsettings.json => Bitwarden.Server.Sdk/examples/Standard/appsettings.Development.json} (80%)
rename extensions/{Bitwarden.Extensions.Hosting/examples/MinimalApi/appsettings.Development.json => Bitwarden.Server.Sdk/examples/Standard/appsettings.json} (53%)
rename extensions/{Bitwarden.Extensions.Hosting/src => Bitwarden.Server.Sdk/src/Content}/Features/FeatureApplicationBuilderExtensions.cs (94%)
rename extensions/{Bitwarden.Extensions.Hosting/src => Bitwarden.Server.Sdk/src/Content}/Features/FeatureCheckMiddleware.cs (92%)
rename extensions/{Bitwarden.Extensions.Hosting/src => Bitwarden.Server.Sdk/src/Content}/Features/FeatureEndpointConventionBuilderExtensions.cs (97%)
rename extensions/{Bitwarden.Extensions.Hosting/src => Bitwarden.Server.Sdk/src/Content}/Features/FeatureFlagOptions.cs (94%)
rename extensions/{Bitwarden.Extensions.Hosting/src => Bitwarden.Server.Sdk/src/Content}/Features/FeatureServiceCollectionExtensions.cs (97%)
create mode 100644 extensions/Bitwarden.Server.Sdk/src/Content/Features/IFeatureMetadata.cs
rename extensions/{Bitwarden.Extensions.Hosting/src => Bitwarden.Server.Sdk/src/Content}/Features/IFeatureService.cs (96%)
rename extensions/{Bitwarden.Extensions.Hosting/src => Bitwarden.Server.Sdk/src/Content}/Features/LaunchDarklyFeatureService.cs (95%)
rename extensions/{Bitwarden.Extensions.Hosting/src => Bitwarden.Server.Sdk/src/Content}/Features/LoggerExtensions.cs (71%)
rename extensions/{Bitwarden.Extensions.Hosting/src => Bitwarden.Server.Sdk/src/Content}/Features/RequireFeatureAttribute.cs (94%)
rename extensions/{Bitwarden.Extensions.Hosting/src => Bitwarden.Server.Sdk/src/Content}/HostBuilderExtensions.cs (68%)
rename extensions/{Bitwarden.Extensions.Hosting/src => Bitwarden.Server.Sdk/src/Content}/Utilities/HostEnvironmentExtensions.cs (76%)
create mode 100644 extensions/Bitwarden.Server.Sdk/src/Content/Utilities/InternalConstants.cs
rename extensions/{Bitwarden.Extensions.Hosting/src => Bitwarden.Server.Sdk/src/Content}/Utilities/VersionInfo.cs (87%)
create mode 100644 extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Bitwarden.Server.Sdk.UnitTests.csproj
rename extensions/{Bitwarden.Extensions.Hosting/tests => Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content}/Features/FeatureApplicationBuilderExtensionsTests.cs (93%)
rename extensions/{Bitwarden.Extensions.Hosting/tests => Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content}/Features/FeatureCheckMiddlewareTests.cs (98%)
rename extensions/{Bitwarden.Extensions.Hosting/tests => Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content}/Features/FeatureEndpointConventionBuilderExtensionsTests.cs (95%)
rename extensions/{Bitwarden.Extensions.Hosting/tests => Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content}/Features/FeatureServiceCollectionExtensionsTests.cs (96%)
rename extensions/{Bitwarden.Extensions.Hosting/tests => Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content}/Features/LaunchDarklyFeatureServiceTests.cs (97%)
rename extensions/{Bitwarden.Extensions.Hosting/tests => Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content}/Utilities/VersionInfoTests.cs (90%)
diff --git a/bitwarden-dotnet.sln b/bitwarden-dotnet.sln
index 2c3c94e..d683591 100644
--- a/bitwarden-dotnet.sln
+++ b/bitwarden-dotnet.sln
@@ -29,14 +29,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{C0
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalApi", "extensions\Bitwarden.Extensions.Configuration\examples\MinimalApi\MinimalApi.csproj", "{0C4EE450-B1FF-42F6-AE44-9E79493A47B5}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{1D751C2C-4102-4A95-B411-95F31FC50A26}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalApi", "extensions\Bitwarden.Extensions.Hosting\examples\MinimalApi\MinimalApi.csproj", "{441E6BF0-4C2B-4512-9ECD-3C0390CE83C5}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bitwarden.Server.Sdk", "Bitwarden.Server.Sdk", "{82253883-A5E2-4917-A690-A744C3855FAB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bitwarden.Server.Sdk", "extensions\Bitwarden.Server.Sdk\src\Bitwarden.Server.Sdk.csproj", "{482E0C0B-586D-41B7-AF90-35CD8B383084}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{AEF7870E-D4E5-4ECC-88A1-BD2C5A6CC9C7}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Standard", "extensions\Bitwarden.Server.Sdk\examples\Standard\Standard.csproj", "{061FB6BF-6F7E-4E48-BD89-6BA826B15432}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{384C7FC2-51CB-4723-B2EC-353833AB4354}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bitwarden.Server.Sdk.UnitTests", "extensions\Bitwarden.Server.Sdk\tests\Bitwarden.Server.Sdk.UnitTests\Bitwarden.Server.Sdk.UnitTests.csproj", "{6CF2554F-67DA-494F-A414-3974FAB96E6E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -78,14 +82,18 @@ Global
{0C4EE450-B1FF-42F6-AE44-9E79493A47B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C4EE450-B1FF-42F6-AE44-9E79493A47B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C4EE450-B1FF-42F6-AE44-9E79493A47B5}.Release|Any CPU.Build.0 = Release|Any CPU
- {441E6BF0-4C2B-4512-9ECD-3C0390CE83C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {441E6BF0-4C2B-4512-9ECD-3C0390CE83C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {441E6BF0-4C2B-4512-9ECD-3C0390CE83C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {441E6BF0-4C2B-4512-9ECD-3C0390CE83C5}.Release|Any CPU.Build.0 = Release|Any CPU
{482E0C0B-586D-41B7-AF90-35CD8B383084}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{482E0C0B-586D-41B7-AF90-35CD8B383084}.Debug|Any CPU.Build.0 = Debug|Any CPU
{482E0C0B-586D-41B7-AF90-35CD8B383084}.Release|Any CPU.ActiveCfg = Release|Any CPU
{482E0C0B-586D-41B7-AF90-35CD8B383084}.Release|Any CPU.Build.0 = Release|Any CPU
+ {061FB6BF-6F7E-4E48-BD89-6BA826B15432}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {061FB6BF-6F7E-4E48-BD89-6BA826B15432}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {061FB6BF-6F7E-4E48-BD89-6BA826B15432}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {061FB6BF-6F7E-4E48-BD89-6BA826B15432}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6CF2554F-67DA-494F-A414-3974FAB96E6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6CF2554F-67DA-494F-A414-3974FAB96E6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6CF2554F-67DA-494F-A414-3974FAB96E6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6CF2554F-67DA-494F-A414-3974FAB96E6E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5EC8B943-2E9E-437D-9FFC-D18B5DB4D7D0} = {695C76EF-1102-4805-970F-7C995EE54930}
@@ -100,9 +108,11 @@ Global
{2EABE7A5-6B68-4DAC-9D37-F312059C3C27} = {A1C893A6-887B-44FE-9DA3-B85E6ACADC55}
{C0631F08-D41D-4FCE-AE2B-2F4990254ACC} = {0008B44C-95E9-4A33-92EF-66741AC8AE47}
{0C4EE450-B1FF-42F6-AE44-9E79493A47B5} = {C0631F08-D41D-4FCE-AE2B-2F4990254ACC}
- {1D751C2C-4102-4A95-B411-95F31FC50A26} = {A1C893A6-887B-44FE-9DA3-B85E6ACADC55}
- {441E6BF0-4C2B-4512-9ECD-3C0390CE83C5} = {1D751C2C-4102-4A95-B411-95F31FC50A26}
{82253883-A5E2-4917-A690-A744C3855FAB} = {695C76EF-1102-4805-970F-7C995EE54930}
{482E0C0B-586D-41B7-AF90-35CD8B383084} = {82253883-A5E2-4917-A690-A744C3855FAB}
+ {AEF7870E-D4E5-4ECC-88A1-BD2C5A6CC9C7} = {82253883-A5E2-4917-A690-A744C3855FAB}
+ {061FB6BF-6F7E-4E48-BD89-6BA826B15432} = {AEF7870E-D4E5-4ECC-88A1-BD2C5A6CC9C7}
+ {384C7FC2-51CB-4723-B2EC-353833AB4354} = {82253883-A5E2-4917-A690-A744C3855FAB}
+ {6CF2554F-67DA-494F-A414-3974FAB96E6E} = {384C7FC2-51CB-4723-B2EC-353833AB4354}
EndGlobalSection
EndGlobal
diff --git a/extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/MinimalApi.csproj b/extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/MinimalApi.csproj
deleted file mode 100644
index 5c798bd..0000000
--- a/extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/MinimalApi.csproj
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
- net8.0
- enable
- enable
-
-
-
-
-
-
-
diff --git a/extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/Program.cs b/extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/Program.cs
deleted file mode 100644
index 3cd99bc..0000000
--- a/extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/Program.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using Bitwarden.Extensions.Hosting.Features;
-
-var builder = WebApplication.CreateBuilder(args);
-
-builder.UseBitwardenDefaults();
-
-var app = builder.Build();
-
-app.UseRouting();
-
-app.UseFeatureFlagChecks();
-
-app.MapGet("/", (IConfiguration config) => ((IConfigurationRoot)config).GetDebugView());
-
-app.MapGet("/requires-feature", (IFeatureService featureService) =>
-{
- return featureService.GetAll();
-})
- .RequireFeature("feature-one");
-
-app.Run();
diff --git a/extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/Properties/launchSettings.json b/extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/Properties/launchSettings.json
deleted file mode 100644
index 142cc3b..0000000
--- a/extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/Properties/launchSettings.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "$schema": "http://json.schemastore.org/launchsettings.json",
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:16827",
- "sslPort": 44378
- }
- },
- "profiles": {
- "http": {
- "commandName": "Project",
- "dotnetRunMessages": true,
- "launchBrowser": true,
- "launchUrl": "swagger",
- "applicationUrl": "http://localhost:5037",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "https": {
- "commandName": "Project",
- "dotnetRunMessages": true,
- "launchBrowser": true,
- "launchUrl": "swagger",
- "applicationUrl": "https://localhost:7138;http://localhost:5037",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "IIS Express": {
- "commandName": "IISExpress",
- "launchBrowser": true,
- "launchUrl": "swagger",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- }
- }
-}
diff --git a/extensions/Bitwarden.Extensions.Hosting/src/BitwardenHostOptions.cs b/extensions/Bitwarden.Extensions.Hosting/src/BitwardenHostOptions.cs
deleted file mode 100644
index c844be6..0000000
--- a/extensions/Bitwarden.Extensions.Hosting/src/BitwardenHostOptions.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace Bitwarden.Extensions.Hosting;
-
-///
-/// Options for configuring the Bitwarden host.
-///
-public class BitwardenHostOptions
-{
- ///
- /// Gets or sets a value indicating whether to include request logging.
- ///
- public bool IncludeLogging { get; set; } = true;
- ///
- /// Gets or sets a value indicating whether to include metrics.
- ///
- public bool IncludeMetrics { get; set; } = true;
-}
diff --git a/extensions/Bitwarden.Extensions.Hosting/src/Features/IFeatureMetadata.cs b/extensions/Bitwarden.Extensions.Hosting/src/Features/IFeatureMetadata.cs
deleted file mode 100644
index 693b0fc..0000000
--- a/extensions/Bitwarden.Extensions.Hosting/src/Features/IFeatureMetadata.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Bitwarden.Extensions.Hosting.Features;
-
-internal interface IFeatureMetadata
-{
- ///
- /// A method to run to check if the feature is enabled.
- ///
- Func FeatureCheck { get; set; }
-}
diff --git a/extensions/Bitwarden.Server.Sdk/examples/Standard/Program.cs b/extensions/Bitwarden.Server.Sdk/examples/Standard/Program.cs
new file mode 100644
index 0000000..469491b
--- /dev/null
+++ b/extensions/Bitwarden.Server.Sdk/examples/Standard/Program.cs
@@ -0,0 +1,18 @@
+#if BIT_INCLUDE_FEATURES
+using Bitwarden.Server.Sdk.Features;
+#endif
+
+var builder = WebApplication.CreateBuilder(args);
+
+builder.UseBitwardenSdk();
+
+var app = builder.Build();
+
+#if BIT_INCLUDE_FEATURES
+app.MapGet("/features", (IFeatureService featureService) =>
+{
+ return featureService.GetAll();
+});
+#endif
+
+app.Run();
diff --git a/extensions/Bitwarden.Server.Sdk/examples/Standard/Properties/launchSettings.json b/extensions/Bitwarden.Server.Sdk/examples/Standard/Properties/launchSettings.json
new file mode 100644
index 0000000..4c7b394
--- /dev/null
+++ b/extensions/Bitwarden.Server.Sdk/examples/Standard/Properties/launchSettings.json
@@ -0,0 +1,23 @@
+{
+ "$schema": "https://json.schemastore.org/launchsettings.json",
+ "profiles": {
+ "http": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": false,
+ "applicationUrl": "http://localhost:5087",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "https": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": false,
+ "applicationUrl": "https://localhost:7186;http://localhost:5087",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/extensions/Bitwarden.Server.Sdk/examples/Standard/Standard.csproj b/extensions/Bitwarden.Server.Sdk/examples/Standard/Standard.csproj
new file mode 100644
index 0000000..b37fd64
--- /dev/null
+++ b/extensions/Bitwarden.Server.Sdk/examples/Standard/Standard.csproj
@@ -0,0 +1,27 @@
+
+
+
+
+
+ net8.0
+ enable
+ true
+
+
+
+ false
+
+
+
+ false
+ false
+
+
+
+ false
+ false
+ false
+
+
+
+
diff --git a/extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/appsettings.json b/extensions/Bitwarden.Server.Sdk/examples/Standard/appsettings.Development.json
similarity index 80%
rename from extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/appsettings.json
rename to extensions/Bitwarden.Server.Sdk/examples/Standard/appsettings.Development.json
index 10f68b8..0c208ae 100644
--- a/extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/appsettings.json
+++ b/extensions/Bitwarden.Server.Sdk/examples/Standard/appsettings.Development.json
@@ -4,6 +4,5 @@
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
- },
- "AllowedHosts": "*"
+ }
}
diff --git a/extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/appsettings.Development.json b/extensions/Bitwarden.Server.Sdk/examples/Standard/appsettings.json
similarity index 53%
rename from extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/appsettings.Development.json
rename to extensions/Bitwarden.Server.Sdk/examples/Standard/appsettings.json
index 28d6b86..f44f872 100644
--- a/extensions/Bitwarden.Extensions.Hosting/examples/MinimalApi/appsettings.Development.json
+++ b/extensions/Bitwarden.Server.Sdk/examples/Standard/appsettings.json
@@ -5,12 +5,11 @@
"Microsoft.AspNetCore": "Warning"
}
},
+ "AllowedHosts": "*",
"Features": {
+ "KnownFlags": ["one"],
"FlagValues": {
- "feature-one": true,
- "feature-two": 1,
- "feature-three": "my-value"
- },
- "KnownFlags": ["feature-one", "feature-two"]
+ "one": true
+ }
}
}
diff --git a/extensions/Bitwarden.Server.Sdk/src/Bitwarden.Server.Sdk.csproj b/extensions/Bitwarden.Server.Sdk/src/Bitwarden.Server.Sdk.csproj
index 80a2ed7..e10c7fe 100644
--- a/extensions/Bitwarden.Server.Sdk/src/Bitwarden.Server.Sdk.csproj
+++ b/extensions/Bitwarden.Server.Sdk/src/Bitwarden.Server.Sdk.csproj
@@ -1,7 +1,6 @@
-
- netstandard2.0
+ net8.0
MSBuildSdk
true
@@ -16,8 +15,22 @@
beta
1
$(PreReleaseVersionLabel).$(PreReleaseVersionIteration)
+ true
+ enable
+
+ $(DefineConstants);BIT_INCLUDE_FEATURES;BIT_INCLUDE_TELEMETRY
+
+
+
+
+
+
+
+
+
+
Bitwarden Inc.
Bitwarden Server SDK.
@@ -25,6 +38,8 @@
../../Bitwarden.Extensions.Hosting/src/
+
+ $(NoWarn);BWSDK0001
@@ -33,7 +48,18 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureApplicationBuilderExtensions.cs b/extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureApplicationBuilderExtensions.cs
similarity index 94%
rename from extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureApplicationBuilderExtensions.cs
rename to extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureApplicationBuilderExtensions.cs
index 30c8ac6..77b4085 100644
--- a/extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureApplicationBuilderExtensions.cs
+++ b/extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureApplicationBuilderExtensions.cs
@@ -1,4 +1,6 @@
-using Bitwarden.Extensions.Hosting.Features;
+#pragma warning disable BWSDK0001
+
+using Bitwarden.Server.Sdk.Features;
namespace Microsoft.AspNetCore.Builder;
diff --git a/extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureCheckMiddleware.cs b/extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureCheckMiddleware.cs
similarity index 92%
rename from extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureCheckMiddleware.cs
rename to extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureCheckMiddleware.cs
index b5e7336..60b4b0e 100644
--- a/extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureCheckMiddleware.cs
+++ b/extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureCheckMiddleware.cs
@@ -1,10 +1,14 @@
+using System.ComponentModel;
+using Bitwarden.Server.Sdk.Utilities.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
-namespace Bitwarden.Extensions.Hosting.Features;
+namespace Bitwarden.Server.Sdk.Features;
+[EditorBrowsable(EditorBrowsableState.Never)]
+[Obsolete(InternalConstants.InternalMessage, DiagnosticId = InternalConstants.InternalId)]
internal sealed class FeatureCheckMiddleware
{
private readonly RequestDelegate _next;
diff --git a/extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureEndpointConventionBuilderExtensions.cs b/extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureEndpointConventionBuilderExtensions.cs
similarity index 97%
rename from extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureEndpointConventionBuilderExtensions.cs
rename to extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureEndpointConventionBuilderExtensions.cs
index bdfa620..bb21c48 100644
--- a/extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureEndpointConventionBuilderExtensions.cs
+++ b/extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureEndpointConventionBuilderExtensions.cs
@@ -1,4 +1,4 @@
-using Bitwarden.Extensions.Hosting.Features;
+using Bitwarden.Server.Sdk.Features;
namespace Microsoft.AspNetCore.Builder;
diff --git a/extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureFlagOptions.cs b/extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureFlagOptions.cs
similarity index 94%
rename from extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureFlagOptions.cs
rename to extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureFlagOptions.cs
index 1caf152..fd80b9d 100644
--- a/extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureFlagOptions.cs
+++ b/extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureFlagOptions.cs
@@ -1,4 +1,6 @@
-namespace Bitwarden.Extensions.Hosting.Features;
+#nullable enable
+
+namespace Bitwarden.Server.Sdk.Features;
///
/// A collection of Launch Darkly specific options.
diff --git a/extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureServiceCollectionExtensions.cs b/extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureServiceCollectionExtensions.cs
similarity index 97%
rename from extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureServiceCollectionExtensions.cs
rename to extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureServiceCollectionExtensions.cs
index b617b1d..d6d96be 100644
--- a/extensions/Bitwarden.Extensions.Hosting/src/Features/FeatureServiceCollectionExtensions.cs
+++ b/extensions/Bitwarden.Server.Sdk/src/Content/Features/FeatureServiceCollectionExtensions.cs
@@ -1,4 +1,4 @@
-using Bitwarden.Extensions.Hosting.Features;
+using Bitwarden.Server.Sdk.Features;
namespace Microsoft.Extensions.DependencyInjection;
diff --git a/extensions/Bitwarden.Server.Sdk/src/Content/Features/IFeatureMetadata.cs b/extensions/Bitwarden.Server.Sdk/src/Content/Features/IFeatureMetadata.cs
new file mode 100644
index 0000000..90ca731
--- /dev/null
+++ b/extensions/Bitwarden.Server.Sdk/src/Content/Features/IFeatureMetadata.cs
@@ -0,0 +1,18 @@
+#pragma warning disable BWSDK0001
+#nullable enable
+
+using System.ComponentModel;
+using Bitwarden.Server.Sdk.Utilities.Internal;
+
+namespace Bitwarden.Server.Sdk.Features;
+
+
+[EditorBrowsable(EditorBrowsableState.Never)]
+[Obsolete(InternalConstants.InternalMessage, DiagnosticId = InternalConstants.InternalId)]
+internal interface IFeatureMetadata
+{
+ ///
+ /// A method to run to check if the feature is enabled.
+ ///
+ Func FeatureCheck { get; set; }
+}
diff --git a/extensions/Bitwarden.Extensions.Hosting/src/Features/IFeatureService.cs b/extensions/Bitwarden.Server.Sdk/src/Content/Features/IFeatureService.cs
similarity index 96%
rename from extensions/Bitwarden.Extensions.Hosting/src/Features/IFeatureService.cs
rename to extensions/Bitwarden.Server.Sdk/src/Content/Features/IFeatureService.cs
index c0961a3..33ec926 100644
--- a/extensions/Bitwarden.Extensions.Hosting/src/Features/IFeatureService.cs
+++ b/extensions/Bitwarden.Server.Sdk/src/Content/Features/IFeatureService.cs
@@ -1,6 +1,8 @@
+#nullable enable
+
using System.Text.Json.Nodes;
-namespace Bitwarden.Extensions.Hosting.Features;
+namespace Bitwarden.Server.Sdk.Features;
///
/// Checks feature status for the current request.
diff --git a/extensions/Bitwarden.Extensions.Hosting/src/Features/LaunchDarklyFeatureService.cs b/extensions/Bitwarden.Server.Sdk/src/Content/Features/LaunchDarklyFeatureService.cs
similarity index 95%
rename from extensions/Bitwarden.Extensions.Hosting/src/Features/LaunchDarklyFeatureService.cs
rename to extensions/Bitwarden.Server.Sdk/src/Content/Features/LaunchDarklyFeatureService.cs
index dac588e..7fa1651 100644
--- a/extensions/Bitwarden.Extensions.Hosting/src/Features/LaunchDarklyFeatureService.cs
+++ b/extensions/Bitwarden.Server.Sdk/src/Content/Features/LaunchDarklyFeatureService.cs
@@ -1,7 +1,12 @@
+#pragma warning disable BWSDK0001
+#nullable enable
+
+using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Security.Claims;
using System.Text.Json.Nodes;
-using Bitwarden.Extensions.Hosting.Utilities;
+using Bitwarden.Server.Sdk.Utilities;
+using Bitwarden.Server.Sdk.Utilities.Internal;
using LaunchDarkly.Logging;
using LaunchDarkly.Sdk;
using LaunchDarkly.Sdk.Server;
@@ -12,8 +17,11 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
-namespace Bitwarden.Extensions.Hosting.Features;
+namespace Bitwarden.Server.Sdk.Features;
+
+[EditorBrowsable(EditorBrowsableState.Never)]
+[Obsolete(InternalConstants.InternalMessage, DiagnosticId = InternalConstants.InternalId)]
internal sealed class LaunchDarklyFeatureService : IFeatureService
{
const string AnonymousUser = "25a15cac-58cf-4ac0-ad0f-b17c4bd92294";
diff --git a/extensions/Bitwarden.Extensions.Hosting/src/Features/LoggerExtensions.cs b/extensions/Bitwarden.Server.Sdk/src/Content/Features/LoggerExtensions.cs
similarity index 71%
rename from extensions/Bitwarden.Extensions.Hosting/src/Features/LoggerExtensions.cs
rename to extensions/Bitwarden.Server.Sdk/src/Content/Features/LoggerExtensions.cs
index 9314ae0..455f97a 100644
--- a/extensions/Bitwarden.Extensions.Hosting/src/Features/LoggerExtensions.cs
+++ b/extensions/Bitwarden.Server.Sdk/src/Content/Features/LoggerExtensions.cs
@@ -1,7 +1,12 @@
+using System.ComponentModel;
+using Bitwarden.Server.Sdk.Utilities.Internal;
using Microsoft.Extensions.Logging;
-namespace Bitwarden.Extensions.Hosting.Features;
+namespace Bitwarden.Server.Sdk.Features;
+
+[EditorBrowsable(EditorBrowsableState.Never)]
+[Obsolete(InternalConstants.InternalMessage, DiagnosticId = InternalConstants.InternalId)]
internal static partial class LoggerExtensions
{
[LoggerMessage(1, LogLevel.Warning, "No endpoint set -- did you forget to call 'UseRouting()'?")]
diff --git a/extensions/Bitwarden.Extensions.Hosting/src/Features/RequireFeatureAttribute.cs b/extensions/Bitwarden.Server.Sdk/src/Content/Features/RequireFeatureAttribute.cs
similarity index 94%
rename from extensions/Bitwarden.Extensions.Hosting/src/Features/RequireFeatureAttribute.cs
rename to extensions/Bitwarden.Server.Sdk/src/Content/Features/RequireFeatureAttribute.cs
index af0102f..c77228f 100644
--- a/extensions/Bitwarden.Extensions.Hosting/src/Features/RequireFeatureAttribute.cs
+++ b/extensions/Bitwarden.Server.Sdk/src/Content/Features/RequireFeatureAttribute.cs
@@ -1,4 +1,6 @@
-namespace Bitwarden.Extensions.Hosting.Features;
+#pragma warning disable BWSDK0001
+
+namespace Bitwarden.Server.Sdk.Features;
///
/// Specifies that the class or method that this attribute is applied to requires a feature check to run.
diff --git a/extensions/Bitwarden.Extensions.Hosting/src/HostBuilderExtensions.cs b/extensions/Bitwarden.Server.Sdk/src/Content/HostBuilderExtensions.cs
similarity index 68%
rename from extensions/Bitwarden.Extensions.Hosting/src/HostBuilderExtensions.cs
rename to extensions/Bitwarden.Server.Sdk/src/Content/HostBuilderExtensions.cs
index 7612f5b..f1617af 100644
--- a/extensions/Bitwarden.Extensions.Hosting/src/HostBuilderExtensions.cs
+++ b/extensions/Bitwarden.Server.Sdk/src/Content/HostBuilderExtensions.cs
@@ -1,16 +1,23 @@
+#pragma warning disable BWSDK0001
+
using System.Diagnostics;
using System.Reflection;
-using Bitwarden.Extensions.Hosting;
-using Bitwarden.Extensions.Hosting.Features;
+#if BIT_INCLUDE_FEATURES
+using Bitwarden.Server.Sdk.Features;
using LaunchDarkly.Sdk.Server.Interfaces;
+#endif
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Json;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
+#if BIT_INCLUDE_TELEMETRY
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
+#endif
+#if BIT_INCLUDE_LOGGING
using Serilog;
using Serilog.Formatting.Compact;
+#endif
namespace Microsoft.Extensions.Hosting;
@@ -21,23 +28,6 @@ public static class HostBuilderExtensions
{
const string SelfHostedConfigKey = "globalSettings:selfHosted";
- ///
- /// Configures the host to use Bitwarden defaults.
- ///
- /// The host application builder.
- /// The function to customize the Bitwarden defaults.
- /// The original host application builder parameter.
- public static TBuilder UseBitwardenDefaults(this TBuilder builder, Action? configure = null)
- where TBuilder : IHostApplicationBuilder
- {
- ArgumentNullException.ThrowIfNull(builder);
-
- var bitwardenHostOptions = new BitwardenHostOptions();
- configure?.Invoke(bitwardenHostOptions);
- builder.UseBitwardenDefaults(bitwardenHostOptions);
- return builder;
- }
-
///
/// Configures the host to use Bitwarden defaults.
///
@@ -45,67 +35,31 @@ public static TBuilder UseBitwardenDefaults(this TBuilder builder, Act
///
///
///
- public static TBuilder UseBitwardenDefaults(this TBuilder builder, BitwardenHostOptions bitwardenHostOptions)
+ public static TBuilder UseBitwardenSdk(this TBuilder builder)
where TBuilder : IHostApplicationBuilder
{
ArgumentNullException.ThrowIfNull(builder);
- ArgumentNullException.ThrowIfNull(bitwardenHostOptions);
-
- builder.Services.AddOptions()
- .Configure((options, config) =>
- {
- options.IsSelfHosted = config.GetValue(SelfHostedConfigKey, false);
- });
-
if (builder.Configuration.GetValue(SelfHostedConfigKey, false))
{
AddSelfHostedConfig(builder.Configuration, builder.Environment);
}
- if (bitwardenHostOptions.IncludeLogging)
- {
- AddLogging(builder.Services, builder.Configuration, builder.Environment);
- }
-
- if (bitwardenHostOptions.IncludeMetrics)
- {
- AddMetrics(builder.Services);
- }
-
+ AddLogging(builder.Services, builder.Configuration, builder.Environment);
+ AddMetrics(builder.Services);
AddFeatureFlagServices(builder.Services, builder.Configuration);
return builder;
}
- ///
- /// Configures the host to use Bitwarden defaults.
- ///
- public static IHostBuilder UseBitwardenDefaults(this IHostBuilder hostBuilder, Action? configure = null)
- {
- // We could default to not including logging in development environments like we currently do.
- var bitwardenHostOptions = new BitwardenHostOptions();
- configure?.Invoke(bitwardenHostOptions);
- return hostBuilder.UseBitwardenDefaults(bitwardenHostOptions);
- }
-
///
/// Configures the host to use Bitwarden defaults.
///
/// Host builder.
/// Host options.
///
- public static IHostBuilder UseBitwardenDefaults(this IHostBuilder hostBuilder, BitwardenHostOptions bitwardenHostOptions)
+ public static IHostBuilder UseBitwardenSdk(this IHostBuilder hostBuilder)
{
- hostBuilder.ConfigureServices((_, services) =>
- {
- services.AddOptions()
- .Configure((options, config) =>
- {
- options.IsSelfHosted = config.GetValue("globalSettings:selfHosted", false);
- });
- });
-
hostBuilder.ConfigureAppConfiguration((context, builder) =>
{
if (context.Configuration.GetValue(SelfHostedConfigKey, false))
@@ -114,21 +68,15 @@ public static IHostBuilder UseBitwardenDefaults(this IHostBuilder hostBuilder, B
}
});
- if (bitwardenHostOptions.IncludeLogging)
+ hostBuilder.ConfigureServices((context, services) =>
{
- hostBuilder.ConfigureServices((context, services) =>
- {
- AddLogging(services, context.Configuration, context.HostingEnvironment);
- });
- }
+ AddLogging(services, context.Configuration, context.HostingEnvironment);
+ });
- if (bitwardenHostOptions.IncludeMetrics)
+ hostBuilder.ConfigureServices((_, services) =>
{
- hostBuilder.ConfigureServices((_, services) =>
- {
- AddMetrics(services);
- });
- }
+ AddMetrics(services);
+ });
hostBuilder.ConfigureServices((context, services) =>
{
@@ -198,6 +146,7 @@ private static void AddSelfHostedConfig(IConfigurationBuilder configurationBuild
private static void AddLogging(IServiceCollection services, IConfiguration configuration, IHostEnvironment environment)
{
+#if BIT_INCLUDE_LOGGING
services.AddSerilog((sp, serilog) =>
{
var builder = serilog.ReadFrom.Configuration(configuration)
@@ -214,19 +163,23 @@ private static void AddLogging(IServiceCollection services, IConfiguration confi
builder.WriteTo.Console();
}
});
+#endif
}
private static void AddMetrics(IServiceCollection services)
{
+#if BIT_INCLUDE_TELEMETRY
services.AddOpenTelemetry()
.WithMetrics(options =>
options.AddOtlpExporter())
.WithTracing(options =>
options.AddOtlpExporter());
+#endif
}
private static void AddFeatureFlagServices(IServiceCollection services, IConfiguration configuration)
{
+#if BIT_INCLUDE_FEATURES
services.AddProblemDetails();
services.AddHttpContextAccessor();
@@ -240,5 +193,6 @@ private static void AddFeatureFlagServices(IServiceCollection services, IConfigu
// client from LaunchDarklyClientProvider, effectively being a singleton.
services.TryAddScoped(sp => sp.GetRequiredService().Get());
services.TryAddScoped();
+#endif
}
}
diff --git a/extensions/Bitwarden.Extensions.Hosting/src/Utilities/HostEnvironmentExtensions.cs b/extensions/Bitwarden.Server.Sdk/src/Content/Utilities/HostEnvironmentExtensions.cs
similarity index 76%
rename from extensions/Bitwarden.Extensions.Hosting/src/Utilities/HostEnvironmentExtensions.cs
rename to extensions/Bitwarden.Server.Sdk/src/Content/Utilities/HostEnvironmentExtensions.cs
index c2f9d2f..60294d7 100644
--- a/extensions/Bitwarden.Extensions.Hosting/src/Utilities/HostEnvironmentExtensions.cs
+++ b/extensions/Bitwarden.Server.Sdk/src/Content/Utilities/HostEnvironmentExtensions.cs
@@ -1,8 +1,15 @@
+#nullable enable
+
+using System.ComponentModel;
using System.Reflection;
+using Bitwarden.Server.Sdk.Utilities.Internal;
using Microsoft.Extensions.Hosting;
-namespace Bitwarden.Extensions.Hosting.Utilities;
+namespace Bitwarden.Server.Sdk.Utilities;
+
+[EditorBrowsable(EditorBrowsableState.Never)]
+[Obsolete(InternalConstants.InternalMessage, DiagnosticId = InternalConstants.InternalId)]
internal static class HostEnvironmentExtensions
{
public static VersionInfo? GetVersionInfo(this IHostEnvironment hostEnvironment)
diff --git a/extensions/Bitwarden.Server.Sdk/src/Content/Utilities/InternalConstants.cs b/extensions/Bitwarden.Server.Sdk/src/Content/Utilities/InternalConstants.cs
new file mode 100644
index 0000000..2b507e9
--- /dev/null
+++ b/extensions/Bitwarden.Server.Sdk/src/Content/Utilities/InternalConstants.cs
@@ -0,0 +1,7 @@
+namespace Bitwarden.Server.Sdk.Utilities.Internal;
+
+internal static class InternalConstants
+{
+ public const string InternalId = "BWSDK0001";
+ public const string InternalMessage = "This is a type of Bitwarden.Server.Sdk and not intended for external use. This type may change shape with no warning.";
+}
diff --git a/extensions/Bitwarden.Extensions.Hosting/src/Utilities/VersionInfo.cs b/extensions/Bitwarden.Server.Sdk/src/Content/Utilities/VersionInfo.cs
similarity index 87%
rename from extensions/Bitwarden.Extensions.Hosting/src/Utilities/VersionInfo.cs
rename to extensions/Bitwarden.Server.Sdk/src/Content/Utilities/VersionInfo.cs
index 03c97bb..7940e82 100644
--- a/extensions/Bitwarden.Extensions.Hosting/src/Utilities/VersionInfo.cs
+++ b/extensions/Bitwarden.Server.Sdk/src/Content/Utilities/VersionInfo.cs
@@ -1,8 +1,15 @@
+#nullable enable
+
+using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Text.RegularExpressions;
+using Bitwarden.Server.Sdk.Utilities.Internal;
+
+namespace Bitwarden.Server.Sdk.Utilities;
-namespace Bitwarden.Extensions.Hosting;
+[EditorBrowsable(EditorBrowsableState.Never)]
+[Obsolete(InternalConstants.InternalMessage, DiagnosticId = InternalConstants.InternalId)]
internal sealed partial class VersionInfo : ISpanParsable
{
[GeneratedRegex("[0-9a-f]{5,40}")]
diff --git a/extensions/Bitwarden.Server.Sdk/src/Sdk/Sdk.targets b/extensions/Bitwarden.Server.Sdk/src/Sdk/Sdk.targets
index 2b9d26b..91fbe08 100644
--- a/extensions/Bitwarden.Server.Sdk/src/Sdk/Sdk.targets
+++ b/extensions/Bitwarden.Server.Sdk/src/Sdk/Sdk.targets
@@ -3,10 +3,19 @@
These properties are read in targets to allow the csproj file to customize the behavior
-->
+
+ $(MSBuildThisFileDirectory)../Content
+
+
-
+
+
+
+ true
+
+
@@ -20,10 +29,6 @@
$(DefineConstants);BIT_INCLUDE_FEATURES
-
-
-
-
@@ -40,5 +45,7 @@
+
+
diff --git a/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Bitwarden.Server.Sdk.UnitTests.csproj b/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Bitwarden.Server.Sdk.UnitTests.csproj
new file mode 100644
index 0000000..99a4527
--- /dev/null
+++ b/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Bitwarden.Server.Sdk.UnitTests.csproj
@@ -0,0 +1,28 @@
+
+
+
+ net8.0
+ enable
+ enable
+ false
+ $(NoWarn);BWSDK0001
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/extensions/Bitwarden.Extensions.Hosting/tests/Features/FeatureApplicationBuilderExtensionsTests.cs b/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/FeatureApplicationBuilderExtensionsTests.cs
similarity index 93%
rename from extensions/Bitwarden.Extensions.Hosting/tests/Features/FeatureApplicationBuilderExtensionsTests.cs
rename to extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/FeatureApplicationBuilderExtensionsTests.cs
index 5154ba2..a4f2e90 100644
--- a/extensions/Bitwarden.Extensions.Hosting/tests/Features/FeatureApplicationBuilderExtensionsTests.cs
+++ b/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/FeatureApplicationBuilderExtensionsTests.cs
@@ -1,11 +1,11 @@
-using Bitwarden.Extensions.Hosting.Features;
+using Bitwarden.Server.Sdk.Features;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using NSubstitute;
-namespace Bitwarden.Extensions.Hosting.Tests.Features;
+namespace Bitwarden.Server.Sdk.Features;
public class FeatureApplicationBuilderExtensionsTests
{
diff --git a/extensions/Bitwarden.Extensions.Hosting/tests/Features/FeatureCheckMiddlewareTests.cs b/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/FeatureCheckMiddlewareTests.cs
similarity index 98%
rename from extensions/Bitwarden.Extensions.Hosting/tests/Features/FeatureCheckMiddlewareTests.cs
rename to extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/FeatureCheckMiddlewareTests.cs
index c2b1bec..2d2110f 100644
--- a/extensions/Bitwarden.Extensions.Hosting/tests/Features/FeatureCheckMiddlewareTests.cs
+++ b/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/FeatureCheckMiddlewareTests.cs
@@ -1,6 +1,6 @@
using System.Net;
using System.Net.Http.Json;
-using Bitwarden.Extensions.Hosting.Features;
+using Bitwarden.Server.Sdk.Features;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
@@ -12,7 +12,7 @@
using Microsoft.Extensions.Logging.Abstractions;
using NSubstitute;
-namespace Bitwarden.Extensions.Hosting.Tests.Features;
+namespace Bitwarden.Server.Sdk.UnitTests.Features;
public class FeatureCheckMiddlewareTests
{
@@ -158,7 +158,7 @@ private static IHost CreateHost(Action? configureServices =
{
return new HostBuilder()
.UseEnvironment("Development") // To get easier to read logs
- .UseBitwardenDefaults()
+ .UseBitwardenSdk()
.ConfigureWebHost((webHostBuilder) =>
{
webHostBuilder
diff --git a/extensions/Bitwarden.Extensions.Hosting/tests/Features/FeatureEndpointConventionBuilderExtensionsTests.cs b/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/FeatureEndpointConventionBuilderExtensionsTests.cs
similarity index 95%
rename from extensions/Bitwarden.Extensions.Hosting/tests/Features/FeatureEndpointConventionBuilderExtensionsTests.cs
rename to extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/FeatureEndpointConventionBuilderExtensionsTests.cs
index 94218ee..9231503 100644
--- a/extensions/Bitwarden.Extensions.Hosting/tests/Features/FeatureEndpointConventionBuilderExtensionsTests.cs
+++ b/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/FeatureEndpointConventionBuilderExtensionsTests.cs
@@ -1,9 +1,9 @@
-using Bitwarden.Extensions.Hosting.Features;
+using Bitwarden.Server.Sdk.Features;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Routing.Patterns;
-namespace Bitwarden.Extensions.Hosting.Tests.Features;
+namespace Bitwarden.Server.Sdk.UnitTests.Features;
public class FeatureEndpointConventionBuilderExtensionsTests
{
diff --git a/extensions/Bitwarden.Extensions.Hosting/tests/Features/FeatureServiceCollectionExtensionsTests.cs b/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/FeatureServiceCollectionExtensionsTests.cs
similarity index 96%
rename from extensions/Bitwarden.Extensions.Hosting/tests/Features/FeatureServiceCollectionExtensionsTests.cs
rename to extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/FeatureServiceCollectionExtensionsTests.cs
index 91bd948..7597505 100644
--- a/extensions/Bitwarden.Extensions.Hosting/tests/Features/FeatureServiceCollectionExtensionsTests.cs
+++ b/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/FeatureServiceCollectionExtensionsTests.cs
@@ -1,8 +1,8 @@
-using Bitwarden.Extensions.Hosting.Features;
+using Bitwarden.Server.Sdk.Features;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
-namespace Bitwarden.Extensions.Hosting.Tests.Features;
+namespace Bitwarden.Server.Sdk.UnitTests.Features;
public class FeatureServiceCollectionExtensionsTests
{
diff --git a/extensions/Bitwarden.Extensions.Hosting/tests/Features/LaunchDarklyFeatureServiceTests.cs b/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/LaunchDarklyFeatureServiceTests.cs
similarity index 97%
rename from extensions/Bitwarden.Extensions.Hosting/tests/Features/LaunchDarklyFeatureServiceTests.cs
rename to extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/LaunchDarklyFeatureServiceTests.cs
index fc2e150..fa4d6f7 100644
--- a/extensions/Bitwarden.Extensions.Hosting/tests/Features/LaunchDarklyFeatureServiceTests.cs
+++ b/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Features/LaunchDarklyFeatureServiceTests.cs
@@ -1,4 +1,4 @@
-using Bitwarden.Extensions.Hosting.Features;
+using Bitwarden.Server.Sdk.Features;
using LaunchDarkly.Sdk;
using LaunchDarkly.Sdk.Server;
using LaunchDarkly.Sdk.Server.Interfaces;
@@ -7,7 +7,7 @@
using Microsoft.Extensions.Options;
using NSubstitute;
-namespace Bitwarden.Extensions.Hosting.Tests.Features;
+namespace Bitwarden.Server.Sdk.UnitTests.Features;
public class LaunchDarklyFeatureServiceTests
{
diff --git a/extensions/Bitwarden.Extensions.Hosting/tests/Utilities/VersionInfoTests.cs b/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Utilities/VersionInfoTests.cs
similarity index 90%
rename from extensions/Bitwarden.Extensions.Hosting/tests/Utilities/VersionInfoTests.cs
rename to extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Utilities/VersionInfoTests.cs
index 00d618f..571e56f 100644
--- a/extensions/Bitwarden.Extensions.Hosting/tests/Utilities/VersionInfoTests.cs
+++ b/extensions/Bitwarden.Server.Sdk/tests/Bitwarden.Server.Sdk.UnitTests/Content/Utilities/VersionInfoTests.cs
@@ -1,4 +1,6 @@
-namespace Bitwarden.Extensions.Hosting.Tests.Utilities;
+using Bitwarden.Server.Sdk.Utilities;
+
+namespace Bitwarden.Server.Sdk.UnitTests.Utilities;
public class VersionInfoTests
{