Skip to content

Use public Aspire 17 parameter APIs for Bitwarden secrets - #2565

Merged
aaronpowell merged 4 commits into
CommunityToolkit:mainfrom
sliekens:codex/bitwarden-aspire17-cleanup
Nov 18, 2026
Merged

aaronpowell merged 4 commits into
CommunityToolkit:mainfrom
sliekens:codex/bitwarden-aspire17-cleanup

Conversation

@sliekens

@sliekens sliekens commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2564.

This PR moves the Bitwarden Secrets Manager integration off Aspire’s private parameter internals. Aspire 17 exposes public APIs for the parameter operations the integration used to access through UnsafeAccessor.

The integration lets an Aspire AppHost manage secrets for its services. For example, if a service needs an API key and you haven’t supplied one locally, the integration checks Bitwarden for a value it can reuse. Aspire may show a dashboard prompt during that lookup, so you can enter a replacement while the existing key is still on its way back.

Reviewing the migration surfaced two related cases worth correcting. A remote fallback could take precedence over a local value, and deployment could save a remote fallback as a local input. The PR makes local input take precedence and keeps remote fallbacks in memory for the deployment.

Mechanical changes

  • Replace four UnsafeAccessor calls into Aspire parameter internals with the public Aspire 17 parameter APIs.
  • Pin Aspire.Hosting to 17.0.0 for the Bitwarden hosting project and update its hosting abstractions dependency.
  • Remove three obsolete diagnostic suppressions from the provisioner and update the architecture documentation.

Previous behavior

  • If you submitted a replacement key while Bitwarden was looking up the existing one, Aspire could accept your submission and show the parameter as set while the integration still used the older key it fetched.
  • During deployment, pre-sync checked the configuration key. It could miss a parameter default or a value supplied in code, then save the remote fallback as a deployment input. A later deployment could reuse that saved value after the Bitwarden secret rotated.
  • In a headless run, Bitwarden reconciliation could use a cached remote value while the Aspire parameter itself still reported a missing value.

New behavior

  • Local input takes precedence. A dashboard submission during the remote lookup becomes the value Bitwarden reconciles. Once a write starts, a later edit stays in Aspire for the next reconciliation.
  • Deployments preserve configured values, defaults, and values set in code. A remote fallback stays in memory for that deployment, so a later deployment can pick up a rotated value. Artifact-only publish and build skip remote pre-sync.
  • Headless startup can fill a missing Aspire parameter from Bitwarden. A secret missing from both sources requires explicit input. A failed remote lookup surfaces as an error.

Aspire can still show the local dashboard prompt while Bitwarden checks for a remote value.

The resource-output overload is tracked in #1591.

Validation

Built the Bitwarden hosting project against Aspire 17.0.0 with zero warnings. All 82 Bitwarden hosting tests passed on net10.0, including input submitted during lookup, edits during a write, headless recovery, and repeated deployments.

Dogfooding

I published a package to my private NuGet feed that includes the changes in this PR. I tested it in a local Aspire 17 AppHost and through a staging CI/CD deployment. Local startup loaded existing managed secrets and started dependent services. The staging deployment completed Bitwarden reconciliation and passed its health checks.

https://nuget.sliekens.dev/packages/communitytoolkit.aspire.hosting.bitwarden.secretmanager/17.0.0-bitwarden.20261118.2

Copilot AI balanced review requested due to automatic review settings November 18, 2026 18:25
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 2565

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 2565"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Managed-secret reconciliation can overwrite defaults or user-supplied values during deploy pre-sync or concurrent dashboard input, potentially persisting the remote value instead.

2 open issues
What changed in this PR

Migrates Bitwarden Secrets Manager to public Aspire 17 parameter APIs, removing private-access dependencies while keeping the AddSecret and GetSecret signatures unchanged. This addresses #2564 and prepares for the separate resource-output proposal in #1591.

Changes:

  • Uses optional parameters for read-only secrets and public APIs for value inspection, assignment, and prompting.
  • Pins Aspire Hosting 17.0.0 for the Bitwarden project and updates package-source mappings.
  • Adds parameter-resolution tests and updates compatibility and architecture documentation.
File Description
tests/​CommunityToolkit.Aspire.Hosting.Bitwarden.SecretManager.Tests/​BitwardenSecretSourceResolutionTests.cs Adds coverage for prepared inputs, defaults, cancellation, and remote binding.
tests/​CommunityToolkit.Aspire.Hosting.Bitwarden.SecretManager.Tests/​BitwardenSecretManagerBuilderTests.cs Updates tests for asynchronous binding and explicit parameter assignment.
src/​CommunityToolkit.Aspire.Hosting.Bitwarden.SecretManager/​README.md Updates input precedence and Aspire compatibility documentation.
src/​CommunityToolkit.Aspire.Hosting.Bitwarden.SecretManager/​Extensions/​ParameterResourceExtensions.cs Removes private-access helpers and compatibility logging.
src/​CommunityToolkit.Aspire.Hosting.Bitwarden.SecretManager/​CommunityToolkit.Aspire.Hosting.Bitwarden.SecretManager.csproj Pins Aspire Hosting 17.0.0 and updates hosting abstractions.
src/​CommunityToolkit.Aspire.Hosting.Bitwarden.SecretManager/​BitwardenSecretResource.cs Consolidates value reads through inherited parameter state.
src/​CommunityToolkit.Aspire.Hosting.Bitwarden.SecretManager/​BitwardenSecretManagerResource.cs Uses public parameter APIs for prompting, binding, and reset.
src/​CommunityToolkit.Aspire.Hosting.Bitwarden.SecretManager/​BitwardenSecretManagerProvisioner.cs Replaces private-state updates with public value setters.
src/​CommunityToolkit.Aspire.Hosting.Bitwarden.SecretManager/​BitwardenSecretManagerExtensions.cs Marks read-only secret parameters optional.
src/​CommunityToolkit.Aspire.Hosting.Bitwarden.SecretManager/​ASPIRE-INTERNALS.md Removes obsolete internal-API workaround documentation.
src/​CommunityToolkit.Aspire.Hosting.Bitwarden.SecretManager/​ARCHITECTURE.md Documents the public parameter model and prefill flow.
nuget.config Allows Aspire Hosting resolution from both configured feeds.

Review effort: Balanced

@sliekens
sliekens requested a max review from Copilot November 18, 2026 20:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@sliekens
sliekens requested a balanced review from Copilot November 18, 2026 20:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@aaronpowell

Copy link
Copy Markdown
Member

It's alright Copilot, I got you

@aaronpowell
aaronpowell merged commit fc5e75f into CommunityToolkit:main Nov 18, 2026
174 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace Bitwarden's private Aspire parameter access with public Aspire 17 APIs

3 participants