Implement persistent API-key authentication

Protect the research lifecycle with X-API-Key validation backed by persistent user and key records. Store only salted scrypt hashes, support expiry and revocation, and expose a local admin CLI for create/list/revoke workflows.

Initialize only the authentication schema at startup, prevent SQL echo from exposing sensitive bound values, and keep health probes public. Add coverage for valid, missing, invalid, expired, and revoked keys.

Document deployment and key administration, update the local CLI to send NSCT_API_KEY, and record the reset handoff state.
This commit is contained in:
faligam
2026-09-06 17:23:05 +02:00
parent 64eb4e8465
commit 1aacf4aa20
14 changed files with 1065 additions and 60 deletions

View File

@@ -23,6 +23,11 @@ NSCT_AUDIO_API_KEY=
# ---------- PostgreSQL ----------
NSCT_DB_URL=postgresql+asyncpg://nsct:nsct_secret@localhost:5432/nsct
# User-facing API keys are persisted in NSCT_DB_URL and administered with
# `nsct-api-key create|list|revoke`. These are distinct from provider keys.
# Do not put a user key in this file.
# NSCT_API_KEY= # optional: key used by the local `nsct` client
POSTGRES_USER=nsct
POSTGRES_PASSWORD=nsct_secret
POSTGRES_DB=nsct
@@ -31,4 +36,4 @@ POSTGRES_DB=nsct
NSCT_SEARXNG_BASE_URL=http://localhost:8888/
# ---------- General ----------
NSCT_DEBUG=false
NSCT_DEBUG=false