generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Bitwarden.Server.Sdk
#43
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0a01210
Add `Bitwarden.Server.Sdk`
justindbaur 4673de6
Make Example Not Packable
justindbaur e562a7f
Remove Example
justindbaur e90acfc
Remove Accidential VSCode Files
justindbaur a23a469
Add More Details to README
justindbaur 1578623
Apply suggestions from code review
justindbaur fb3514c
Merge branch 'introduce-server-sdk' of github.com:bitwarden/dotnet-exโฆ
justindbaur 8914f37
Apply suggestions from code review
justindbaur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
extensions/Bitwarden.Server.Sdk/src/Bitwarden.Server.Sdk.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<!-- Not a true dependency, we just need one to make the CLI happy --> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<PackageType>MSBuildSdk</PackageType> | ||
<!-- We are a meta package, we don't actually want people to have to use netstandard to use us. --> | ||
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking> | ||
<NoWarn>$(NoWarn);NU5128</NoWarn> | ||
|
||
<IncludeBuildOutput>false</IncludeBuildOutput> | ||
|
||
<PackageReadmeFile>./README.md</PackageReadmeFile> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
|
||
<Version>0.1.10</Version> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<Authors>Bitwarden Inc.</Authors> | ||
<Description>Bitwarden Server SDK.</Description> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<ExtensionsHostingRoot>../../Bitwarden.Extensions.Hosting/src/</ExtensionsHostingRoot> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="README.md" Pack="true" PackagePath="/" /> | ||
<None Include="Sdk/**" Pack="true" PackagePath="Sdk/" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content | ||
Include="$(ExtensionsHostingRoot)**/*.cs" | ||
Exclude="$(ExtensionsHostingRoot)bin/**;$(ExtensionsHostingRoot)obj/**" | ||
Pack="true" | ||
PackagePath="content/Bitwarden.Server.Sdk" | ||
Visible="false" | ||
BuildAction="none" | ||
/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. โ TODO? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, meant some brief documentation. Added it. |
||
|
||
Feature flag support can be added by adding `<BitIncludeFeatures>true</BitIncludeFeatures>` to | ||
your `csproj` file. The following APIs become available: | ||
|
||
- `IFeatureService` for getting values of features. | ||
- `RequireFeatureAttribute` for requiring a feature is enabled on controllers and controller actions. | ||
- `IEndpointConventionBuilder.RequireFeature()` for requiring a feature is enabled on minimal APIs. | ||
- `IApplicationBuilder.UseFeatureFlagChecks()` for adding the middleware to do the above checks. | ||
- `IServiceCollection.AddKnownFeatureFlags()` for adding flags that will show up in `IFeatureService.GetAll()` | ||
- `IServiceCollection.AddFeatureFlagValues()` for adding values for feature flags. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<UsingBitwardenServerSdk>true</UsingBitwardenServerSdk> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
These properties are read in targets to allow the csproj file to customize the behavior | ||
--> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Condition="'$(UsingBitwardenServerSdk)' == 'true'"> | ||
<Compile Include="$(MSBuildThisFileDirectory)../content/Bitwarden.Server.Sdk/**/*.cs" /> | ||
</ItemGroup> | ||
|
||
<!-- TODO Use the constants in places to avoid any configuration that doesn't compile --> | ||
<PropertyGroup> | ||
<!-- Logging defaults to on --> | ||
<BitIncludeLogging Condition="'$(BitIncludeLogging)' == ''">true</BitIncludeLogging> | ||
<DefineConstants Condition="'$(BitIncludeLogging)' == 'true'">$(DefineConstants);BIT_INCLUDE_LOGGING</DefineConstants> | ||
<!-- Telemetry defaults to on --> | ||
<BitIncludeTelemetry Condition="'$(BitIncludeTelemetry)' == ''">true</BitIncludeTelemetry> | ||
<DefineConstants Condition="'$(BitIncludeTelemetry)' == 'true'">$(DefineConstants);BIT_INCLUDE_TELEMETRY</DefineConstants> | ||
<!-- Features defaults to on --> | ||
<BitIncludeFeatures Condition="'$(BitIncludeFeatures)' == ''">true</BitIncludeFeatures> | ||
<DefineConstants Condition="'$(BitIncludeFeatures)' == 'true'">$(DefineConstants);BIT_INCLUDE_FEATURES</DefineConstants> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition="'$(UsingBitwardenServerSdk)' == 'true'"> | ||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" /> | ||
</ItemGroup> | ||
|
||
<!-- TODO: Allow for overriding specific package versions? --> | ||
<ItemGroup Condition="'$(BitIncludeLogging)' == 'true'"> | ||
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" /> | ||
<PackageReference Include="Serilog.Formatting.Compact" Version="3.0.0" /> | ||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" /> | ||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" /> | ||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(BitIncludeTelemetry)' == 'true'"> | ||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" /> | ||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(BitIncludeFeatures)' == 'true'"> | ||
<PackageReference Include="LaunchDarkly.ServerSdk" Version="8.6.0" /> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐จ Need to get this working with CI so we can set it outside of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will want it easily set in code. One of the downsides of SDKs is that they can only be consumed via nuget. So to test this I had to add a nuget source to the
bin/Release
directory of this project and had to make sure I incremented the version number in some way or I would have to clear my nuget cache everytime.I do personally like the version being part of the source control though, I'm not a big fan of setting it in CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, well I can get behind the version in code but do appreciate when we can control it via something that isn't an engineer pushing a commit. Maybe we copy what
server
does with a workflow? Have to think about how tags are made too, as that's what I am doing here now where an engineer pushes a tag and then we make a GitHub release by hand -- really should be all streamlined to me and I really want this repo to showcase best practices.