Skip to content

feat: add 1Password secrets backend - #38569

Closed
santileoni wants to merge 1 commit into
NousResearch:mainfrom
santileoni:feat/onepassword-secrets
Closed

feat: add 1Password secrets backend#38569
santileoni wants to merge 1 commit into
NousResearch:mainfrom
santileoni:feat/onepassword-secrets

Conversation

@santileoni

Copy link
Copy Markdown

Summary

  • add a 1Password secret-source backend using the op CLI and OP_SERVICE_ACCOUNT_TOKEN
  • support secrets.onepassword.mapping so env vars can resolve from op://... secret references at startup
  • add hermes secrets onepassword / op / 1password CLI commands for setup, status, sync, and disable
  • document the 1Password setup path alongside Bitwarden

Behavior

  • resolves mapped 1Password references into os.environ during load_hermes_dotenv()
  • never logs secret values; only env var names and references are shown
  • failures are non-fatal so Hermes startup continues with existing env/config
  • tracks secret origin as onepassword for UI suffixes

Test Plan

  • python -m pytest tests/test_bitwarden_secrets.py tests/test_env_loader_secret_sources.py tests/test_onepassword_secrets.py -q
  • python -m py_compile agent/secret_sources/onepassword.py hermes_cli/onepassword_secrets_cli.py hermes_cli/env_loader.py hermes_cli/main.py

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have area/config Config system, migrations, profiles labels Jun 4, 2026
@santileoni
santileoni force-pushed the feat/onepassword-secrets branch from 20b01b8 to 551ca4f Compare June 4, 2026 00:53

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review Summary

Verdict: Approved

Changes

This PR adds a 1Password CLI (op) secret-source integration alongside the existing Bitwarden integration. It introduces:

  • agent/secret_sources/onepassword.py — full 1Password reference resolution with subprocess-driven op read, SHA-256 fingerprint-based caching, timeout handling, and a structured FetchResult dataclass.
  • hermes_cli/onepassword_secrets_cli.py — CLI commands (setup, status, sync, disable) for the new backend.
  • hermes_cli/env_loader.py — extended to call both Bitwarden and 1Password from _apply_external_secret_sources.
  • hermes_cli/main.py — adds parser for hermes secrets onepassword ....

Security Observations

  1. Token handling is correct — the service-account token is never logged or cached in plain mappable form (only a SHA-256 fingerprint is used as the cache key).
  2. Startup-block failure pathapply_onepassword_secrets calls are wrapped in except Exception so op failures never block Hermes startup, matching the existing Bitwarden pattern.
  3. Subprocess call_run_op_read passes the token via env["OP_SERVICE_ACCOUNT_TOKEN"] rather than the command line, avoiding process-table leakage.
  4. No secrets in diff — no actual credential values are present in the code, only op:// reference strings.

Code Quality

  • Consistent with the existing Bitwarden architecture (FetchResult, find_<tool>(), apply function signature).
  • Test scaffolding (_reset_cache_for_tests()) present for cache isolation.
  • Docstrings and design summary are clear.

Suggestions

  • Missing test coverage: No unit tests for onepassword.py itself (only mocked CLI setup). Consider adding a small tests/agent/test_secret_sources_onepassword.py that patches subprocess.run to verify the happy-path, timeout, timeout-expired, non-zero-returncode, and op not found branches. The Bitwarden module has tests; parity here would help.
  • noqa: BLE001 usage is consistent with existing exceptions; not a concern.
  • Consider whether the 20 second _OP_RUN_TIMEOUT should be documented as a tunable in the module docstring or made configurable — it's fine hard-coded for now, but users on slow networks may hit it.

Reviewed by Hermes Agent

@santileoni

Copy link
Copy Markdown
Author

Thanks for the review @tonydwb. Do you want me to work on the suggestions before we run the tests and merge?

@teknium1

teknium1 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

1Password support landed on main via PR #59498, which also ships a pluggable SecretSource interface — an ABC + orchestrator that lets multiple secret managers run simultaneously with deterministic precedence, conflict warnings, and per-var provenance. The merged backend is a salvage of #36896 (earliest full-cluster credit to #32254). This PR is superseded by that interface; thanks for the contribution and sorry we couldn't land them all — six independent 1Password PRs is exactly why the interface now exists. If you'd like to build further secret-manager backends, they now plug in as standalone plugins via ctx.register_secret_source() with a conformance kit in tests/secret_sources/conformance.py — see https://hermes-agent.nousresearch.com/docs/user-guide/secrets/ .

@teknium1 teknium1 closed this Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants