Skip to content

feat: allow a whole Bitwarden Secrets Manager project in one config section - #185

Merged
groupsky merged 1 commit into
mainfrom
hq-job/nodkey-177-build/r-20261115-194012-428a
Nov 15, 2026
Merged

groupsky merged 1 commit into
mainfrom
hq-job/nodkey-177-build/r-20261115-194012-428a

Conversation

@groupsky

Copy link
Copy Markdown
Contributor

Closes #177.

A [project.NAME] section allows every secret of one Bitwarden Secrets Manager project, with one rule. A client asks for a secret as SECTION/KEY, for example nodkey run --secret GH_TOKEN=ci/GITHUB_TOKEN -- ....

What it does

  • Config (internal/config/project.go): store (type bws), project (UUID), clients, and a rule. ask = "never" is an error. One project in two sections (compared in lower case, in one or two stores) is an error at start and at reload. config-diff lists [project.*] changes.
  • Names: SECTION/KEY, each part by the name rule; api.MaxSecretName = 129, each part at most 64. Two or more / are refused. The client checks the form too.
  • Lookup (internal/broker/projects.go, internal/store/bwsproject.go): bws secret list PROJECT --output json --color no, exact key match. No match: denied. Two secrets with one key: denied, with an audit entry that names SECTION/KEY and a journal line. After the tap, bws secret get ID must have the same key and projectId as the list, else denied. The list parser reads only id, key and projectId; the answer is cleared. Keys that break the name rule are skipped and never kept.
  • Which rule wins: one [secret.*] entry with the same ID in any bws store wins completely (its clients, rule and grants). Two entries: denied. Checked in the broker and again in the approval core (config.Broker.RuleFor).
  • Grants per secret ID (internal/approval/project.go): a new ref kind keyed by (project section, secret UUID). Window grants, pre-approvals and standing grants work this way. A rename that gives the key to another secret makes the broker ask again.
  • Reload: a project grant stays only while the same project rule gives that ID to the client. A new [secret.*] entry for the ID ends it.
  • Message: ci/GITHUB_TOKEN (project rule, ID …1a2b3c4d), or (rule of secret NAME, …) when an entry wins. Telegram and ntfy check this form.
  • Audit: project_secrets holds the name and the ID. A key the client made up never reaches the audit log.

DESIGN.md (section 14 "Projects", the reload rules, section 16 table), THREAT-MODEL.md (T49–T51) and docs/setup.md ("bws: allow a whole project", with the "Can read" step) are updated.

Done when → evidence

  • DESIGN.md: section 14 "Projects", reload rules 2 and 5, section 16 bws secret list row and the array rule.
  • THREAT-MODEL.md: T49, T50, T51. docs/setup.md: "bws: allow a whole project".
  • Hands out by SECTION/KEY / refuses a key not in the project: TestProjectSecret, TestProjectSecretRefused.
  • Entry overrides: TestProjectEntryWins (stricter, looser, two entries, another bws store); config.TestProjectRuleFor.
  • Duplicate key with audit entry: TestProjectDuplicateKey.
  • get differs from the list: TestProjectGetDiffers, store.TestBWSFetchListed.
  • ask = "never" and one project in two sections stop the start: config.TestProjectConfigRefused (loadBroker is the same code for start, reload and nodkey broker check).
  • Reload adds an entry → old grant ends: TestProjectReloadAddsEntry, config.TestSameProjectSecret; reload with one project in two sections is refused: config.TestProjectConfigRefused (the reload loads the config with loadBroker).
  • 15-minute grant does not hand out a renamed secret: TestProjectGrantRename.
  • 129 bytes works, longer names and parts refused: TestProjectSecretLimits, config.TestParseSecretName, api.TestCaps, api.TestPreapproveCaps, client.TestRunUsage.
  • Reads only id, key, projectId and clears: store.TestBWSListSecrets, store.TestReadListClears, store.TestParseBWSListBad (fake bws).
  • Security review: done with .claude/agents/security-reviewer.md. It found three points (made-up keys in the audit log on some deny paths; no per-client cap while bws secret list runs; two names for one secret). All three are fixed, with tests (TestProjectMadeUpKeysNotLogged, TestProjectSameSecretTwice).

Also: TestProjectPreapprove, TestProjectReloadKeepsGrant, TestProjectStoreFails, TestDiffProjects, audit.TestProjectSecretsValidate, Telegram/ntfy TestProjectSecretsInMessages.

No new dependency.

🤖 Generated with Claude Code

…ection (#177)

A [project.NAME] section allows every secret of one bws project, asked
for as SECTION/KEY. A [secret.*] entry with the same ID wins completely;
two entries, or two secrets with one key, deny. Grants are kept per
secret ID, so a rename does not hand out another secret. The get answer
must match the list. DESIGN.md, THREAT-MODEL.md (T49-T51) and
docs/setup.md are updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@groupsky
groupsky merged commit 9d6cb8a into main Nov 15, 2026
11 of 13 checks passed
@groupsky
groupsky deleted the hq-job/nodkey-177-build/r-20261115-194012-428a branch November 15, 2026 18:12
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.

feat: allow a whole Bitwarden Secrets Manager project in one config section, with clear rules when a secret also has its own entry

1 participant