Skip to content

Add GlobalSettingsBridge library - #8156

Merged
justindbaur merged 2 commits into
mainfrom
globalsettings-bridge
Aug 7, 2026
Merged

Add GlobalSettingsBridge library#8156
justindbaur merged 2 commits into
mainfrom
globalsettings-bridge

Conversation

@justindbaur

Copy link
Copy Markdown
Member

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-34549

📔 Objective

Introduces a new GlobalSettingsBridge library (src/Libraries/GlobalSettingsBridge/) that bridges globalSettings-style IConfiguration keys into the ASP.NET Core options pattern via IConfigureOptions<T>.

Calling services.AddGlobalSettingsBridge() registers three configurators:

  • ConfigureSelfHostDetails — reads globalSettings:selfHosted / globalSettings:liteDeployment and populates SelfHostDetails (the SDK's environment type).
  • ConfigureCorsOptions — reads globalSettings:baseServiceUri:vault and uses IBitwardenEnvironment.SelfHosted to configure the default CORS policy, replacing direct GlobalSettings usage in middleware setup.
  • ConfigureForwardedHeadersOptions — reads globalSettings:knownProxies / globalSettings:knownNetworks, handles the nginx DNS lookup for non-lite self-hosted deployments, and sets ForwardLimit = null when multiple proxies/networks are configured.

The library has no dependency on Bit.Core or GlobalSettings directly — it reads all config via IConfiguration. It uses Bitwarden.Server.Sdk (with BitIncludeFeatures=false) to pick up the Bitwarden.Server.Sdk.Environment package.

This method is intended for services migrating away from direct GlobalSettings dependencies. New services should configure CorsOptions, ForwardedHeadersOptions, and SelfHostDetails directly.

📸 Screenshots

N/A — no UI changes.

Bridges GlobalSettings-style configuration into IConfigureOptions<T>
for CorsOptions, ForwardedHeadersOptions, and SelfHostDetails, so
services can migrate away from direct GlobalSettings dependencies.
@justindbaur
justindbaur force-pushed the globalsettings-bridge branch from 5d6d7fb to 9b307cb Compare August 6, 2026 17:42
Comment thread src/Libraries/GlobalSettingsBridge/ConfigureForwardedHeadersOptions.cs Dismissed
Comment thread src/Libraries/GlobalSettingsBridge/ConfigureForwardedHeadersOptions.cs Dismissed
Comment thread src/Libraries/GlobalSettingsBridge/ConfigureForwardedHeadersOptions.cs Dismissed
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.77108% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.06%. Comparing base (73ed2f6) to head (1f2dde6).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...SettingsBridge/ConfigureForwardedHeadersOptions.cs 87.23% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #8156       +/-   ##
===========================================
+ Coverage   15.10%   63.06%   +47.96%     
===========================================
  Files        1417     2319      +902     
  Lines       61422   100593    +39171     
  Branches     4901     9057     +4156     
===========================================
+ Hits         9279    63441    +54162     
+ Misses      51978    34963    -17015     
- Partials      165     2189     +2024     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@justindbaur justindbaur added the t:tech-debt Change Type - Tech debt label Aug 7, 2026
@justindbaur
justindbaur marked this pull request as ready for review August 7, 2026 13:35
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the new GlobalSettingsBridge library, which bridges globalSettings:* configuration keys into SelfHostDetails, CorsOptions, and ForwardedHeadersOptions via IConfigureOptions<T>. Verified each configurator against the code it ports (CoreHelpers.IsCorsOriginAllowed and ServiceCollectionExtensions.UseForwardedHeaders) — the CORS origin predicate, proxy/network parsing, and ForwardLimit nulling are all behaviorally equivalent, and the Vault base service URI is a plain auto-property so reading it straight from IConfiguration matches the bound value. Registration uses TryAddEnumerable per ADR 0026, nullable reference types are on repo-wide, and the library is additive with no call sites migrated yet. Unit test coverage is good across all three configurators.

Code Review Details
  • ❓ : app.UseCors() migration guidance in the XML remarks does not account for Identity's dev-only Swagger origin
    • src/Libraries/GlobalSettingsBridge/GlobalSettingsBridgeServiceCollectionExtensions.cs:25-30

Dependency Changes

Package Change Ecosystem
Bitwarden.Server.Sdk.Environment 0.1.0 (already in use elsewhere) NuGet

@justindbaur
justindbaur requested a review from a team August 7, 2026 15:46
@justindbaur
justindbaur merged commit 9a952ca into main Aug 7, 2026
80 of 81 checks passed
@justindbaur
justindbaur deleted the globalsettings-bridge branch August 7, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t:tech-debt Change Type - Tech debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants