Skip to content

Configuration

All configuration is managed through environment variables defined in .env. Copy .env.example to .env and adjust values for your environment.

Database

VariableDefaultDescription
DATABASE_URLpostgresql+asyncpg://nis2:nis2secret@postgres:5432/nis2Async database connection string (used by FastAPI)
DATABASE_URL_SYNCpostgresql://nis2:nis2secret@postgres:5432/nis2Sync connection string (used by Alembic migrations)
POSTGRES_USERnis2PostgreSQL user
POSTGRES_PASSWORDnis2secretPostgreSQL password
POSTGRES_DBnis2PostgreSQL database name

Redis

VariableDefaultDescription
REDIS_URLredis://redis:6379/0Redis connection for caching and sessions

Authentication (JWT)

VariableDefaultDescription
JWT_SECRET(change in production)Secret key for signing JWT tokens. Generate with openssl rand -hex 32
JWT_ALGORITHMHS256JWT signing algorithm
ACCESS_TOKEN_EXPIRE_MINUTES30Access token lifetime in minutes
REFRESH_TOKEN_EXPIRE_DAYS7Refresh token lifetime in days

Password reset (B05)

The forgot/reset flow needs a public URL to put in the email link and an SMTP relay (or the dev outbox) to deliver it. In make dev and the e2e suite, leaving SMTP_HOST empty activates the in-memory dev outbox — the email is logged at INFO and captured for GET /api/v1/auth/debug/last-email (mounted only when ENVIRONMENT != "production"). Production with SMTP_HOST empty refuses to deliver: the route turns the RuntimeError into a 5xx rather than silently dropping the email.

VariableDefaultDescription
PUBLIC_URLhttp://localhost:8077Base URL the reset link points to. The user clicks ${PUBLIC_URL}/reset-password?token=…
RESET_TOKEN_TTL_MINUTES30Lifetime of the reset token. Tokens are single-use; once consumed (used_at non-null) they're rejected even within the TTL
SMTP_HOST`` (dev outbox)SMTP relay hostname. Leave empty in dev / e2e — the email is captured in-process instead
SMTP_PORT587SMTP relay port
SMTP_USER``SMTP auth username (omit if your relay doesn't require auth)
SMTP_PASSWORD``SMTP auth password
SMTP_FROMnoreply@nis2.localFrom: header on outgoing emails
SMTP_STARTTLStrueIssue STARTTLS after EHLO (the common case for ports 25 / 587)
SMTP_SSLfalseWrap the entire connection in TLS (port 465 style). Mutually exclusive with SMTP_STARTTLS

Reports

Generated reports (PDF / HTML / Markdown / JSON / CSV / JUnit XML) live under /tmp/nis2-reports/ on the Celery worker, shared with the API container via the reports-data Docker named volume. A daily Celery beat task (cleanup-old-reports) sweeps this directory of files older than the TTL — without it, the disk grows unbounded as users generate reports.

VariableDefaultDescription
REPORT_TTL_DAYS30Days to keep generated report files before the daily cleanup task deletes them. Long enough for a compliance team to download last week's report after a holiday; short enough that a deploy generating 100s of scans/day doesn't fill the disk in weeks. The cleanup task always runs at the schedule's wall-clock cadence regardless of this value (it just changes the cutoff age).

Celery

VariableDefaultDescription
CELERY_BROKER_URLredis://redis:6379/1Celery message broker
CELERY_RESULT_BACKENDredis://redis:6379/2Celery result backend

Frontend (Next.js)

VariableDefaultDescription
NEXTAUTH_URLhttp://localhost:8077NextAuth base URL
NEXTAUTH_SECRET(change in production)NextAuth encryption secret
API_URLhttp://localhost:8000Internal API URL (server-side)
NEXT_PUBLIC_API_URLhttp://localhost:8000Public API URL (client-side)

Production (Caddy)

VariableDefaultDescription
DOMAINnis2.yourdomain.comDomain for Caddy auto-HTTPS. Set this for production deployments

Scanner Defaults

Scanner behavior is configured per scan via the API when creating a scan or schedule. Organization settings store defaults that new scans inherit. Key defaults in the scan creation endpoint:

  • Timeout: 10 seconds per check (scan_timeout)
  • Concurrency: 20 parallel tasks (concurrency)
  • Max hosts: 0 (unlimited) -- configurable limit on targets per scan (max_hosts)
  • Features: Individual check categories (dns_checks, web_checks, port_scan, whois_checks) can be toggled per scan. Organization settings store the defaults that new scans inherit.

Organization Settings

Organization-level settings are managed through the dashboard under Settings:

  • Organization name and metadata
  • Default scan configuration (features, concurrency, timeout)
  • Team member management (invite, role assignment)
  • API key management
  • Notification channel preferences