Skip to content

Add OpenBao-backed secret storage (backend) - #272

Draft
argha-dot wants to merge 2 commits into
developfrom
feat/secrets
Draft

Add OpenBao-backed secret storage (backend)#272
argha-dot wants to merge 2 commits into
developfrom
feat/secrets

Conversation

@argha-dot

Copy link
Copy Markdown
Collaborator

Summary

  • Adds an OpenBao-backed secret store so resource secrets (deployment env-var secrets like API keys) are no longer kept in plaintext in Postgres.
  • Re-enables the workspace secret module and implements the create/update/delete/list handlers: values are written to OpenBao (KV v2), Postgres stores only references, and the plaintext is zeroized after the write.
  • Adds an OpenBaoClient and a cloud-only OpenBaoConfig, with a startup connectivity check; the whole feature is cloud-gated.
  • Adds an OpenBao service to the devcontainer compose, and regenerates .sqlx and the frontend TS bindings.

This is the backend slice; the runner resolve path and the frontend UI land in follow-up PRs.

Test plan

  • cargo check -p api (cloud) and cargo check -p api --no-default-features (self-hosted) both compile; cargo bindings and just prepare are clean.
  • End-to-end against a running API + OpenBao:
    • create → value lands in OpenBao at secret/data/{workspace}/{secret}, Postgres row holds only metadata (no value column).
    • list returns metadata only (no value).
    • update rotates the value in OpenBao.
    • delete removes it from both (OpenBao 404 + row gone).
    • authz correctly refuses a token that doesn't own the workspace.

By opening this pull request, I confirm that I have read and agreed to the terms in CONTRIBUTING.md, and that I am legally allowed to submit this code under those terms.

🤖 Generated with Claude Code

@argha-dot
argha-dot marked this pull request as draft August 2, 2026 16:52
.mount_auth_endpoint(update_workspace_info, state, allowed_client_type)
.mount_auth_endpoint(update_workspace_info, state, allowed_client_type);

#[cfg(feature = "cloud")]

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.

Mount secrets regardless of the mode we're running in. Self hosted will get it as well

@argha-dot argha-dot Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I thought we were limiting secrets to cloud only?

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.

There's two different types of self hosted:

  1. You run the API directly on a server (not fully built yet, but is the future of self hosted)
  2. The runner exposes a UI that acts as the self hosted (older, depreciated, unsupported. Will be removed)

I meant that we're doing cloud only in the sense that there will be no 2. We can add it to the code like we normally would, but since 1 isn't fully built yet, there's no way to currently deploy this anywhere. We'll build it into the API nevertheless, with the intention of 1 being in place in the near future.

#234 was the one that introduced 1. Removal of 2 will be in a future PR

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.

Each route gets a separate file, like the others. Don't put them all in one file like this

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

kewl

Comment thread api/src/utils/openbao.rs

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.

Either:

  • Find a library that does this for us
  • If not, inline these things. Not complex enough to warrant a separate client

- re-enable the workspace secret module and implement the create/update/delete/list handlers
- store secret values in OpenBao (KV v2) with only references in Postgres; zeroize plaintext on write
- add OpenBaoClient and a cloud-only OpenBaoConfig, with a startup connectivity check
- add an OpenBao service to the devcontainer compose
- regenerate .sqlx and the frontend TS bindings
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.

2 participants