diff --git a/10-systems/services/gnexus-creds.md b/10-systems/services/gnexus-creds.md index 222ae9f..f4cff24 100644 --- a/10-systems/services/gnexus-creds.md +++ b/10-systems/services/gnexus-creds.md @@ -28,6 +28,7 @@ - MCP search default limit is 20 (max 50, paginate with offset). - Web UI lists 20 secrets per page with pagination (since commit aae771f, predates 2026-10 updates). - As of 2026-10-02 (later count): 71 secrets total (69 actual + 2 archived), all owned by goldmikki@gmail.com; 20 actual with allow_mcp=true, 49 with allow_mcp=false (mostly personal logins created via extension since May 2026). Nothing was lost during the 2026-10-01/02 updates: .env byte-identical to pre-update backup, zero app errors, only 2 deletions ever (2026-05-28). +- Extension-created secrets are stored with `source` = site domain (44 domain-like sources, all alive). The extension creates them via REST (audit channel=rest); there is no channel=extension in audit. ## Audit semantics (verified 2026-10-02, resolved a second false alarm) - Audit events keep a `metadata` snapshot (title, tags, category) forever, including after deletion — deleted secrets remain visible in the audit log under their last known title. Deletion code: `gnexus_creds/services.py` (`audit(..., action="secret.deleted", metadata={"snapshot": ...})`). @@ -36,6 +37,15 @@ - `ip_address` in audit for UI traffic via https://creds.gnexus.space shows the internal reverse-proxy IP (192.168.1.226, [[internal-proxy-vps]]), not the real client IP — attribute by `user_agent`, not by IP. - Full reconciliation 2026-10-02: exactly 2 audit titles reference secrets absent from the DB — "git.gnexus.space — root" and "git.gnexus.space — testing", both deleted 2026-05-28 via UI (Chrome/Linux, through the proxy). "gntodo SSO client + MCP token (tasks.gnexus.space)" audit title refers to a since-renamed/split secret (now "gntodo SSO client + webhook secret" + "gntodo MCP token"). No phantom reveals, no unexplained deletions. +## Backups (set up 2026-10-02 by rei, owner-requested after false data-loss alarm) +- **Script**: `/root/gnexus-creds-backups/backup.sh` (root-only, 700) on gnexus-creds-host. +- **What**: `pg_dump` of the gnexus_creds DB from the running container (gzip) + snapshot of `.env` — the dump is undecryptable without `GNEXUS_CREDS_MASTER_KEY` from `.env`, so both are snapshotted together. +- **Schedule**: root crontab, daily 04:00 UTC (07:00 Europe/Kyiv), log: `/root/gnexus-creds-backups/backup.log` + cron.log. +- **Retention**: 10 days (find -mtime +10 -delete for both db-*.sql.gz and env-*.bak). +- **Sanity check**: dump must be non-empty and contain `CREATE TABLE public.secrets`, otherwise exit 1. +- **Verified**: manual run 2026-10-02 12:18 UTC, EXIT=0, db-20261002-121808.sql.gz 64080 bytes + env-20261002-121808.bak 874 bytes. +- **Restore sketch**: stop app → recreate empty DB (or drop schema) → `zcat db-*.sql.gz | docker compose exec -T db psql -U gnexus_creds -d gnexus_creds` → restore `.env` → `docker compose up -d app`. Dumps are --clean/--if-exists, so they can be replayed over an existing schema. + ## Configuration - Environment variables are managed via `.env` file in `/home/ubuntu/gnexus-creds`. - Production mode enabled (`GNEXUS_CREDS_ENV=production`). diff --git a/90-maintenance/pending-changes/20261002121832-c039922c.json b/90-maintenance/pending-changes/20261002121832-c039922c.json new file mode 100644 index 0000000..b19480f --- /dev/null +++ b/90-maintenance/pending-changes/20261002121832-c039922c.json @@ -0,0 +1,19 @@ +{ + "id": "20261002121832-c039922c", + "kind": "doc", + "target": "10-systems/services/gnexus-creds.md", + "summary": "Add Backups section: daily pg_dump + .env snapshot, 10-day retention, root crontab 04:00 UTC; note extension secrets use source=domain and REST channel", + "reason": "Owner requested daily backups (10-day retention) after a false data-loss alarm. Backup script created, tested (EXIT=0, 64KB dump + .env snapshot), scheduled in root crontab at 04:00 UTC. Also documented: extension secrets use source=site domain and REST channel.", + "payload": { + "content": "---\nowner: gmikcon\nstatus: active\nlast_reviewed: 2026-10-02\nreview_interval: 90d\nconfidence: high\nsource_of_truth: deployment-verified\n---\n\n# gnexus-creds\n\nPersonal secret storage service with REST API, MCP HTTP/SSE adapter, and Vue UI.\n\n## Deployment\n- **Host**: [[gnexus-creds-host]] (192.168.1.173)\n- **Method**: Docker Compose\n- **Port**: 80 (External) $\\to$ 8000 (Internal)\n- **Database**: PostgreSQL 17 (Containerized)\n- **Repository**: https://git.gnexus.space/git/root/gnexus-creds.git (branch master)\n- **Current version**: 543d6ae (2026-10-02, updated by rei; splash on sign-in, logout to internal sign-in without SSO auto-login, extension 0.2.1; previous 3b5a00d: extension 0.2.0 builds on download page; 02a2441: en/uk/ru localization, mobile UX fixes; 4c6a4f7 2026-10-01: PWA shell, biometric reveal gate, ui-kit 1.0)\n\n## Users (verified 2026-10-02)\n- Two accounts exist: goldmikki@gmail.com (Eugene Sukhodolskiy, owns ALL secrets) and lnikita2o1o@gmail.com (Popelous, registered 2026-09-18 via SSO, owns 0 secrets, 1 session + 1 encryption key).\n- Secrets are per-user (`secrets.user_id` → users, ON DELETE CASCADE); users cannot see each other's secrets.\n\n## Visibility semantics (important, caused a false \"data loss\" alarm 2026-10-02)\n- MCP `search_secrets` returns ONLY secrets with `allow_mcp=true` (by design, commit 2082db2: secrets created via MCP always get allow_mcp=true; secrets created via UI/extension default to allow_mcp=false).\n- MCP search default limit is 20 (max 50, paginate with offset).\n- Web UI lists 20 secrets per page with pagination (since commit aae771f, predates 2026-10 updates).\n- As of 2026-10-02 (later count): 71 secrets total (69 actual + 2 archived), all owned by goldmikki@gmail.com; 20 actual with allow_mcp=true, 49 with allow_mcp=false (mostly personal logins created via extension since May 2026). Nothing was lost during the 2026-10-01/02 updates: .env byte-identical to pre-update backup, zero app errors, only 2 deletions ever (2026-05-28).\n- Extension-created secrets are stored with `source` = site domain (44 domain-like sources, all alive). The extension creates them via REST (audit channel=rest); there is no channel=extension in audit.\n\n## Audit semantics (verified 2026-10-02, resolved a second false alarm)\n- Audit events keep a `metadata` snapshot (title, tags, category) forever, including after deletion — deleted secrets remain visible in the audit log under their last known title. Deletion code: `gnexus_creds/services.py` (`audit(..., action=\"secret.deleted\", metadata={\"snapshot\": ...})`).\n- Renaming a secret does NOT rewrite old audit metadata — each event shows the title as of that moment.\n- Archiving hides a secret from the default UI list, but it stays in the DB (`archived=true`) and its audit history remains.\n- `ip_address` in audit for UI traffic via https://creds.gnexus.space shows the internal reverse-proxy IP (192.168.1.226, [[internal-proxy-vps]]), not the real client IP — attribute by `user_agent`, not by IP.\n- Full reconciliation 2026-10-02: exactly 2 audit titles reference secrets absent from the DB — \"git.gnexus.space — root\" and \"git.gnexus.space — testing\", both deleted 2026-05-28 via UI (Chrome/Linux, through the proxy). \"gntodo SSO client + MCP token (tasks.gnexus.space)\" audit title refers to a since-renamed/split secret (now \"gntodo SSO client + webhook secret\" + \"gntodo MCP token\"). No phantom reveals, no unexplained deletions.\n\n## Backups (set up 2026-10-02 by rei, owner-requested after false data-loss alarm)\n- **Script**: `/root/gnexus-creds-backups/backup.sh` (root-only, 700) on gnexus-creds-host.\n- **What**: `pg_dump` of the gnexus_creds DB from the running container (gzip) + snapshot of `.env` — the dump is undecryptable without `GNEXUS_CREDS_MASTER_KEY` from `.env`, so both are snapshotted together.\n- **Schedule**: root crontab, daily 04:00 UTC (07:00 Europe/Kyiv), log: `/root/gnexus-creds-backups/backup.log` + cron.log.\n- **Retention**: 10 days (find -mtime +10 -delete for both db-*.sql.gz and env-*.bak).\n- **Sanity check**: dump must be non-empty and contain `CREATE TABLE public.secrets`, otherwise exit 1.\n- **Verified**: manual run 2026-10-02 12:18 UTC, EXIT=0, db-20261002-121808.sql.gz 64080 bytes + env-20261002-121808.bak 874 bytes.\n- **Restore sketch**: stop app → recreate empty DB (or drop schema) → `zcat db-*.sql.gz | docker compose exec -T db psql -U gnexus_creds -d gnexus_creds` → restore `.env` → `docker compose up -d app`. Dumps are --clean/--if-exists, so they can be replayed over an existing schema.\n\n## Configuration\n- Environment variables are managed via `.env` file in `/home/ubuntu/gnexus-creds`.\n- Production mode enabled (`GNEXUS_CREDS_ENV=production`).\n- Secrets (`SECRET_KEY`, `MCP_TOKEN`) are randomly generated.\n\n## Local runtime adaptation (do not overwrite)\n`docker-compose.yml` has an uncommitted local modification that matches the live stack:\n- service renamed `postgres` $\\to$ `db` (container names gnexus-creds-db-1 / app-1 depend on it);\n- port mapping `80:8000` (upstream default is `8000:8000`);\n- app healthcheck uses python urllib instead of curl (curl not in image);\n- `restart: unless-stopped` on both services.\nPreserve it across updates: `git stash push docker-compose.yml` $\\to$ pull $\\to$ `git stash pop`.\n\n## Operations\n- **Health Check**: `GET /health`\n- **Readiness Check**: `GET /ready`\n- **Migrations**: `docker compose run --rm app alembic upgrade head`\n- **Logs**: `docker compose logs -f app`\n- **Update procedure** (verified 2026-10-01 ×1 and 2026-10-02 ×3): backup `.env` + `docker-compose.yml` to `~/backups/` $\\to$ stash compose $\\to$ `git pull --ff-only origin master` $\\to$ stash pop $\\to$ `sudo docker compose up -d --build` $\\to$ `alembic upgrade head` $\\to$ check `/health`, `/ready` and https://creds.gnexus.space/health.\n- **SSH access**: ubuntu@192.168.1.173, password same as navi swarm password (see gnexus-creds secret \"navi (192.168.1.168) — SSH ubuntu\"); sudo same password. No dedicated secret for this host yet." + }, + "status": "applied", + "created_at": "2026-10-02T12:18:32Z", + "updated_at": "2026-10-02T12:18:33Z", + "applied_at": "2026-10-02T12:18:33Z", + "validation": { + "status": "ok", + "issue_count": 0, + "issues": [] + } +}