secrets management #36
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_proc#36
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
in HERO PROC we manage secrets
FORGE_TOKEN
all to set the FORGE_TOKEN
this token is needed to get info from FORGE on our behalf
check if we can get to FORGE
more info how all of this works see
/Volumes/T7/code0/hero_lib/crates/tools/README.md
pull secrets
implement function pull_secrets()
do as we do in /Users/despiegk/hero/code/hero_skills/tools/modules/secrets_lib.nu
THIS IS IMPLEMENTED IN /Volumes/T7/code0/hero_lib/crates/tools
use this library, check all functionality is there
only do this if FORGE_TOKEN set ,otherwise error
load all the secrets from remote and put them in local secrets
do init secrets at end (maybe there are SECRETS in ENV which are not on FORGE yet)
push secrets
all known secrets from hero_proc are pushed to that location on FORGE (default location), create repo if needed
if repo is there, then get the info of what is there are give prio to info we have in hero_proc
the the most complete version is saved remotely
use functionality from /Volumes/T7/code0/hero_lib/crates/tools or add it to it
init secrets
in admin put a "init secrets" action which calls a function
init_secrets() which is in openrpc and server in submodule for secrets mgmt
reach which KEYS we have in SECRETS from /Users/despiegk/hero/code/hero_skills/tools/modules/secrets_lib.nu (all in upper case)
load the env variables as mentioned there, start a subprocess check if we can find these variables in EXPORT'ed ENV variables from OS, if so and not in SECRETS YET in our hero_proc then put them there
the priority is secrets already loaded, don't overwrite
use /Volumes/T7/code0/hero_lib/crates/tools, if there, if not add it
Implementation Spec for Issue #36 — Secrets Management
Objective
Add full secrets lifecycle management to hero_proc: setting the FORGE_TOKEN, pulling secrets from a remote Forgejo repository into the local hero_proc secrets store, pushing local secrets to the remote, and initializing secrets from OS environment variables. All operations are exposed via OpenRPC (JSON-RPC 2.0) and wired into the admin UI.
Requirements
{username}/secretsrepo into hero_proc's SQLite secrets store; requires FORGE_TOKEN; call init_secrets() at the end{username}/secretsrepo; create repo if needed; merge with remote giving priority to local valuessecret.pull,secret.push,secret.initArchitecture
The existing hero_proc secrets infrastructure provides SQLite-backed CRUD (secret.set/get/list/delete). The
herolib_toolscrate in hero_lib provides:secrets::source()— load secrets.toml as a flat HashMapsecrets::SecretsSync— clone/pull the secrets repo from Forgejo, merge template keyssecrets::SECRETS_TEMPLATE— canonical list of all secret key namessecrets::secrets_flatten()— flatten TOML sections into uppercase key mapsecrets::secrets_set_var()— update a single key in secrets.tomlforge::ForgeClient— Forgejo API (create_repo, push, pull, is_online, user)Plan: add
herolib_toolsas a dependency tohero_proc_serverand implement three new RPC handlers that bridge between file-based secrets (herolib_tools) and SQLite-backed secrets (hero_proc_lib).Implementation Plan
Step 1: Add herolib_tools dependency (no deps)
herolib_toolsto workspace and server crate Cargo.tomlStep 2: Implement init_secrets handler (depends on Step 1)
Step 3: Implement pull_secrets handler (depends on Steps 1, 2)
Step 4: Implement push_secrets handler (depends on Step 1)
Step 5: Wire handlers into RPC dispatch (depends on Steps 2-4)
Step 6: Update OpenRPC discovery schema (depends on Step 5)
Step 7: Add Init Secrets button to admin UI (depends on Step 5)
Acceptance Criteria
secret.initreads canonical keys from template, imports env vars not already in DBsecret.pullfails with clear error if FORGE_TOKEN is not setsecret.pullclones/pulls remote secrets repo, loads into hero_proc DB, calls init at endsecret.pushcreates repo on forge if it does not existsecret.pushmerges hero_proc secrets into secrets.toml (local priority), pushesrpc.discoverincludes the three new methodsspawn_blockingNotes
herolib_toolsuses synchronousureqHTTP — all forge/git ops wrapped inspawn_blockingTest Results
Automated test run
Implementation Summary
Changes Made
New RPC methods (
crates/hero_proc_server/src/rpc/secret.rs):secret.init— Scans OS environment variables for all canonical secret keys (from the full nushell template: AI, DB, CFG, Services sections — 50+ keys). Imports any found env vars into the hero_proc SQLite secrets DB without overwriting existing values.secret.pull— Validates FORGE_TOKEN, gets Forgejo username, clones/pulls{username}/secretsrepo to~/hero/code/secrets, loads all non-empty secrets fromsecrets.tomlinto DB, then runs init to capture any additional env vars.secret.push— Validates FORGE_TOKEN, creates{username}/secretsrepo on Forge if it doesn't exist, clones/pulls locally, merges all hero_proc DB secrets intosecrets.toml(local values take priority), commits and pushes to remote.RPC dispatch (
crates/hero_proc_server/src/rpc/mod.rs):secret.init,secret.pull,secret.pushwith async.await(handlers usespawn_blockingfor I/O)OpenRPC spec (
crates/hero_proc_server/openrpc.json):Admin UI (
crates/hero_proc_ui/templates/index.html,static/js/dashboard.js):Dependencies (
Cargo.toml,crates/hero_proc_server/Cargo.toml):ureq(HTTP client for Forgejo API),toml(TOML parsing),dirs(home directory resolution) as workspace and server dependenciesArchitecture Decisions
herolib_tools → hero_proc_sdksecrets_lib.nu) and Rustherolib_toolslibrarytokio::task::spawn_blockingTest Results
Implementation committed:
6056c4dBrowse:
6056c4d