Repository navigation
feat(secrets): read secret settings from Vaultwarden by reference - #550
Merged
Merged
Conversation
A secret field in Settings can hold a reference such as vaultwarden://OpenAI/password instead of the secret. Lens reads the value from the vault when it builds its settings, keeps it in memory for secrets.cache_minutes and reads it again in the background; only the reference is stored, and it's checked against the vault before it's saved. Settings, the API, MCP and the assistant show references and whether they could be read, never a value. The built-in sealed store stays the default. Vaultwarden is read with python-vaultwarden (Apache-2.0), fetched as a component once an address is set; Lens reads one folder of its own account. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019okSDRfFHV74BTpMzinTFg
…-56g82s # Conflicts: # CHANGELOG.md # docs/mcp.md
…-56g82s # Conflicts: # fastapi_backend/app/api/mcp_tools.py # fastapi_backend/app/domain/ops_tools.py # fastapi_backend/tests/api/test_mcp.py
21 of 23 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Requested by Adeel · project thread
Description
Before: every secret in Settings (model API keys, chat-app tokens, mail passwords) had to be typed into Lens, which kept it sealed with the server's key.
After: a secret field can hold a reference to a Vaultwarden or Bitwarden item instead, like
vaultwarden://OpenAI/password. Lens reads the value from the vault and keeps it in memory forsecrets.cache_minutes(10 by default). It then reads it again in the background, so a key rotated in the vault reaches Lens by itself. Only the reference is stored, and it's checked against the vault before it's saved. Settings, the API, MCP and the assistant show references and whether they could be read, never a value. Secrets saved in Lens stay the default.How:
secret_providers.pyis a small provider layer over the existing sealed settings:builtin, plusvaultwarden. A new password manager is one moreProvider.settings.effective()resolves references after the settings are built.Settings.current()rebuilds when a value read from the vault changes.secrets.vaultwarden_folder, "Lens").New for agents and the API:
GET /api/v1/secrets,GET /api/v1/secrets/itemsandPOST /api/v1/secrets/test, for admins.list_secrets,list_vault_itemsandset_secret_reference.list_secretsandvault_items.change_settingson thesecretssection always asks first, and approval cards show references instead of "(a secret)".Motivation and Context
Adeel asked for a secrets manager, starting with Vaultwarden. Others will follow.
Types of changes
!in the title)Checklist:
tests/api/test_secrets.pyruns againsttests/fake_vaultwarden.py, a loopback Vaultwarden that encrypts with the library's own Bitwarden crypto. It covers logins, notes, cards, items with keys of their own, other folders and a refused sign-in.test_mcp.pylists the new tool. The full backend suite passes locally: 1644 passed, 23 skipped.docs/accordingly: a newdocs/secrets.md, plus the configuration, MCP, assistant and components pages.## UnreleasedinCHANGELOG.md.Done questions (AGENTS.md)
.envedit.secrets.*settings have defaults and can be changed throughPUT /settings/secretsand the assistant. The web section is next. The setup wizard is unchanged.secrets.cache_minutes.openapi.jsonand the client were regenerated with themake openapisteps, anduv.lockwithuv lock.docs/secrets.mdandDEVLOG.md:pip_install, and uses the library's sign-in and crypto rather than new crypto.Generated by Claude Code