Skip to content

fix(ingest): persist JWT signing key in database to survive volume resets#194

Merged
simonjcarr merged 1 commit into
mainfrom
fix/jwt-key-db-persistence
Apr 15, 2026
Merged

fix(ingest): persist JWT signing key in database to survive volume resets#194
simonjcarr merged 1 commit into
mainfrom
fix/jwt-key-db-persistence

Conversation

@simonjcarr
Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: The ingest container's RSA keypair (used to sign agent JWTs) is regenerated on every restart when the Docker volume containing the key file is absent or reset. This produces a crypto/rsa: verification error on all existing agent JWTs — agents can still heartbeat (the heartbeat handler has a fallback), but software inventory streaming fails silently with Unauthenticated.
  • Fix: On startup, load the JWT private key from the new system_config database table first, then fall back to the key file, and finally generate fresh — writing it back to DB in all cases. The key now survives volume resets because it lives in PostgreSQL.
  • Adds a generic system_config table (key/value, no org scope) for system-level settings.

Test plan

  • Stop the ingest container, delete its volume, restart — verify agents can still submit software inventory without re-registering
  • Verify newly generated keys are written to system_config table on first startup
  • Verify existing key is loaded from DB on subsequent restarts

🤖 Generated with Claude Code

…sets

When the ingest container is restarted without a persistent volume the RSA
keypair is regenerated, invalidating all existing agent JWTs with a signature
verification error (not just an expiry error). This caused software inventory
to fail silently for any agent that registered before the last restart.

- Add system_config table (key/value) for system-level settings not scoped
  to an organisation
- On startup, load the JWT private key from system_config first, then fall
  back to the key file, and finally generate a fresh key — writing it back
  to the database in all cases so subsequent restarts find it there
- This makes the JWT signing key resilient to Docker volume loss

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@simonjcarr simonjcarr merged commit 385caa2 into main Apr 15, 2026
8 checks passed
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.

1 participant