From 1ceeca785f68c5798b7201972ffda3c084c1bd76 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Wed, 21 Oct 2026 12:03:43 -0500 Subject: [PATCH] docs(secrets,shell): document two-tier secrets model and operator CLI wrappers - Document Two-Tier Secrets Architecture separating Workstation Operator Secrets (Config/secrets.yaml) from Server Runtime Secrets (Core/nixos/secrets.yaml) - Document flarectl and hostinger transparent in-memory secret wrappers in docs/reference/shell.md --- docs/reference/shell.md | 11 +++++++- docs/secrets.md | 61 +++++++++++++++++++++++++++++++++-------- 2 files changed, 60 insertions(+), 12 deletions(-) diff --git a/docs/reference/shell.md b/docs/reference/shell.md index 2b7ad84..4df4a26 100644 --- a/docs/reference/shell.md +++ b/docs/reference/shell.md @@ -13,7 +13,7 @@ The shell environment is modularized: - `jump.sh`: Directory navigation and quick jumping. - `pdf.sh`: PDF compilation, viewing, and OCR helpers. - `quicklinks.sh`: Shortcuts to primary project directories. - - `secrets.sh`: SOPS secret retrieval and Wayland clipboard extraction (`gh-token`). + - `secrets.sh`: SOPS secret retrieval (`gh-token` clipboard utility, transparent `flarectl` and `hostinger` process wrappers). - `todo.sh`: Lightweight terminal task tracking. - `wayland.sh`: Wayland session environment variables and clipboard helpers. @@ -39,6 +39,15 @@ The shell environment is modularized: | `gl` | `git log --oneline --graph --decorate` | Compact visual commit graph. | | `ght` | `gh-token` | Copy GitHub repo token from SOPS into Wayland clipboard. | +### Operator CLI Secret Wrappers (`home/shell/secrets.sh`) +| Command / Function | Injected Environment Variables | Source Secret Key (`~/Config/secrets.yaml`) | +| :--- | :--- | :--- | +| `flarectl` | `CF_API_TOKEN`, `CF_ACCOUNT_ID` | `["cloudflare"]["api_token"]`, `["cloudflare"]["account_id"]` | +| `hostinger` | `HOSTINGER_API_TOKEN` | `["hostinger"]["api_token"]` | +| `gh-token` (`ght`) | *(Copies directly to Wayland clipboard)* | `["system"]["gh_repo_token"]` (from Homelab `Core`) | + +*Note: Environment variables are set exclusively for the child process lifecycle and do not persist in your interactive shell.* + ### Directory Navigation Jumps (`home/shell/jump.sh`) | 2-Letter | Word Alias | Target Directory | Description | | :--- | :--- | :--- | :--- | diff --git a/docs/secrets.md b/docs/secrets.md index 80eb3b6..125c591 100644 --- a/docs/secrets.md +++ b/docs/secrets.md @@ -32,19 +32,58 @@ graph LR end ``` -### Roles & Boundaries -1. **Workstation (`Config`)**: - - Holds **zero** declarative system secrets (`sops-nix` is not imported). - - Provides operator CLI packages (`sops`, `age`, `rbw`) in `home/dev.nix`. - - Stores the operator's personal age identity in `~/.config/sops/age/keys.txt`. -2. **Server (`Core`)**: - - Headless consumer running Docker containers, databases, and Traefik. - - Decrypts secrets at boot into a secure ramfs (`/run/secrets/`) using `/etc/ssh/ssh_host_ed25519_key`. - - Unprivileged SSH sessions cannot edit secrets directly on the server. +### Two-Tier Secrets Architecture + +The infrastructure enforces a strict separation between **Operator Secrets** (workstation) and **Runtime Workload Secrets** (server): + +| Attribute | Workstation Operator Secrets (`Config`) | Server Runtime Secrets (`Core`) | +| :--- | :--- | :--- | +| **Ciphertext File** | `Config/secrets.yaml` | `Core/nixos/secrets.yaml` | +| **Scope** | Personal operator tokens (Cloudflare, Hostinger, GitHub) | Service runtime credentials (Traefik, DBs, Docker daemons) | +| **Tenancy** | Multi-project across account domains | Scoped strictly to homelab infrastructure workloads | +| **Decryption Model** | In-memory on-demand via `sops -d --extract` in shell wrappers | Automated boot-time ramfs mount via `sops-nix` (`/run/secrets/`) | +| **Key Identity** | Personal age identity (`~/.config/sops/age/keys.txt`) | Server host SSH key (`/etc/ssh/ssh_host_ed25519_key`) | +| **Daemon Overhead** | **Zero** (`sops-nix` module intentionally omitted) | Managed via root systemd units | --- -## 2. Operator Workflow: Authoring & Rotating Secrets +## 2. Workstation Operator Secrets (`Config/secrets.yaml`) + +Operator CLI tools (such as `flarectl` and `hostinger`) manage cloud infrastructure across multiple projects. To maintain least-privilege for the server, these credentials are kept on the workstation: + +```yaml +# Config/secrets.yaml (encrypted with operator age key) +cloudflare: + api_token: "..." + account_id: "..." + +hostinger: + api_token: "..." +``` + +### Process-Scoped In-Memory Decryption +Rather than exporting tokens into global interactive shells or writing plaintext config files to disk, shell wrappers in `home/shell/secrets.sh` extract credentials into the child process environment on demand: + +```bash +# Example: flarectl wrapper in home/shell/secrets.sh +flarectl() { + local secrets_file="$HOME/Config/secrets.yaml" + if [[ -f "$secrets_file" ]] && command -v sops >/dev/null 2>&1; then + CF_API_TOKEN=$(sops -d --extract '["cloudflare"]["api_token"]' "$secrets_file" 2>/dev/null) \ + CF_ACCOUNT_ID=$(sops -d --extract '["cloudflare"]["account_id"]' "$secrets_file" 2>/dev/null) \ + command flarectl "$@" + else + command flarectl "$@" + fi +} +``` + +* **Security**: Decryption occurs strictly in RAM (~17ms overhead). +* **Isolation**: The environment variables exist only for the life of `flarectl "$@"` and do not persist in the parent interactive shell. + +--- + +## 3. Homelab Server Runtime Secrets (`Core/nixos/secrets.yaml`) To rotate or add a secret for homelab services: @@ -74,7 +113,7 @@ The server evaluates the new ciphertext, decrypts it into `/run/secrets/`, and r --- -## 3. Backing Up & Restoring the Operator Age Key +## 4. Backing Up & Restoring the Operator Age Key The operator key is your cryptographic identity for managing homelab infrastructure: