diff --git a/bitwarden-dotnet.sln b/bitwarden-dotnet.sln index 4f2b7b3..e0eb7a1 100644 --- a/bitwarden-dotnet.sln +++ b/bitwarden-dotnet.sln @@ -33,6 +33,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{1D 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}") = "tests", "tests", "{D6DCF0A7-5FD8-499E-824C-0FF534DE53F6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalApi", "extensions\Bitwarden.Server.Sdk\tests\MinimalApi\MinimalApi.csproj", "{37636625-2DD3-465F-B4A1-7C1E91E25761}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -78,6 +86,14 @@ Global {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 + {37636625-2DD3-465F-B4A1-7C1E91E25761}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {37636625-2DD3-465F-B4A1-7C1E91E25761}.Debug|Any CPU.Build.0 = Debug|Any CPU + {37636625-2DD3-465F-B4A1-7C1E91E25761}.Release|Any CPU.ActiveCfg = Release|Any CPU + {37636625-2DD3-465F-B4A1-7C1E91E25761}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {5EC8B943-2E9E-437D-9FFC-D18B5DB4D7D0} = {695C76EF-1102-4805-970F-7C995EE54930} @@ -94,5 +110,9 @@ Global {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} + {D6DCF0A7-5FD8-499E-824C-0FF534DE53F6} = {82253883-A5E2-4917-A690-A744C3855FAB} + {37636625-2DD3-465F-B4A1-7C1E91E25761} = {D6DCF0A7-5FD8-499E-824C-0FF534DE53F6} EndGlobalSection EndGlobal diff --git a/extensions/Bitwarden.Server.Sdk/src/Bitwarden.Server.Sdk.csproj b/extensions/Bitwarden.Server.Sdk/src/Bitwarden.Server.Sdk.csproj new file mode 100644 index 0000000..c1b5828 --- /dev/null +++ b/extensions/Bitwarden.Server.Sdk/src/Bitwarden.Server.Sdk.csproj @@ -0,0 +1,43 @@ + + + + netstandard2.0 + MSBuildSdk + + true + $(NoWarn);NU5128 + + false + + ./README.md + true + + 0.1.10 + + + + Bitwarden Inc. + Bitwarden server sdk + + + + ../../Bitwarden.Extensions.Hosting/src/ + + + + + + + + + + + + diff --git a/extensions/Bitwarden.Server.Sdk/src/README.md b/extensions/Bitwarden.Server.Sdk/src/README.md new file mode 100644 index 0000000..c8ee7ea --- /dev/null +++ b/extensions/Bitwarden.Server.Sdk/src/README.md @@ -0,0 +1,8 @@ +# Bitwarden.Server.Sdk + +The Bitwarden server sdk is built for quickly getting started building +a Bitwarden flavored service. The entrypoint for using it is adding `UseBitwardenSdk()` +on your web application and configuring MSBuild properties to configure the features you +want. + +## Feature Flags diff --git a/extensions/Bitwarden.Server.Sdk/src/Sdk/Sdk.props b/extensions/Bitwarden.Server.Sdk/src/Sdk/Sdk.props new file mode 100644 index 0000000..f21754e --- /dev/null +++ b/extensions/Bitwarden.Server.Sdk/src/Sdk/Sdk.props @@ -0,0 +1,6 @@ + + + + true + + diff --git a/extensions/Bitwarden.Server.Sdk/src/Sdk/Sdk.targets b/extensions/Bitwarden.Server.Sdk/src/Sdk/Sdk.targets new file mode 100644 index 0000000..2b9d26b --- /dev/null +++ b/extensions/Bitwarden.Server.Sdk/src/Sdk/Sdk.targets @@ -0,0 +1,44 @@ + + + + + + + + + + + true + $(DefineConstants);BIT_INCLUDE_LOGGING + + true + $(DefineConstants);BIT_INCLUDE_TELEMETRY + + true + $(DefineConstants);BIT_INCLUDE_FEATURES + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/MinimalApi.csproj b/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/MinimalApi.csproj new file mode 100644 index 0000000..0d794e8 --- /dev/null +++ b/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/MinimalApi.csproj @@ -0,0 +1,11 @@ + + + + + + net8.0 + enable + enable + + + diff --git a/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/Program.cs b/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/Program.cs new file mode 100644 index 0000000..49d1e87 --- /dev/null +++ b/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/Program.cs @@ -0,0 +1,7 @@ +var builder = WebApplication.CreateBuilder(args); + +builder.UseBitwardenDefaults(); + +var app = builder.Build(); + +app.Run(); diff --git a/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/Properties/launchSettings.json b/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/Properties/launchSettings.json new file mode 100644 index 0000000..2982561 --- /dev/null +++ b/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:33688", + "sslPort": 44324 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5079", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7263;http://localhost:5079", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/appsettings.Development.json b/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/appsettings.json b/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/extensions/Bitwarden.Server.Sdk/tests/MinimalApi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}