fix(startup): read startup settings as the system user, not a tokenless session #13

Merged
KofTwentyTwo merged 1 commits from feature/no-tokenless-session-at-produce into develop 2026-10-14 23:18:22 +00:00
KofTwentyTwo commented 2026-10-14 23:15:06 +00:00 (Migrated from github.com)

Problem

WormAuditQBitProducer.produce() set QContext to a plain new QSession() around addProcesses, which reads worm_audit_settings for the startup schedules. Token-based default authentication (OAuth2, Auth0) accepts a QSystemUserSession without a token and rejects every other tokenless session, so on kof22 (OAuth2) the read failed with JWTDecodeException: The token is null and startup crashed (0.1.96). kof22 carries a stand-in (Website-Backend#243) that switches default auth to anonymous during produce(); this removes the need for it.

Fix

Run the startup read as core QSystemUserSession(qInstance), the same pattern as qbit-object-storage#18 and qbit-backups#24.

Why not defer the read to first use: the settings row's chain_interval_seconds, export_cron and verify_cron drive the schedule metadata, and the README, DESIGN and table help document that edits to them take effect after restart. Deferring would silently drop that contract (schedules would only ever use config values). Reading as the system user keeps it.

Tests

  • TokenRequiredAuthenticationModule (test scope): accepts QSystemUserSession and issued sessions, throws The token is null for any other session, like the OAuth2 module.
  • TokenRequiredHostTest: production on a token-required host succeeds, honors a persisted edited settings row (chain interval, verify and export crons) and falls back to config without a row. All three fail without the fix (IllegalState Cannot read WORM Audit Settings caused by The token is null).
  • ./mvnw verify: 98 tests, 0 skipped (PostgreSQL Testcontainers ran), checkstyle and JaCoCo green.

🤖 Generated with Claude Code

## Problem `WormAuditQBitProducer.produce()` set `QContext` to a plain `new QSession()` around `addProcesses`, which reads `worm_audit_settings` for the startup schedules. Token-based default authentication (OAuth2, Auth0) accepts a `QSystemUserSession` without a token and rejects every other tokenless session, so on kof22 (OAuth2) the read failed with `JWTDecodeException: The token is null` and startup crashed (0.1.96). kof22 carries a stand-in (Website-Backend#243) that switches default auth to anonymous during `produce()`; this removes the need for it. ## Fix Run the startup read as core `QSystemUserSession(qInstance)`, the same pattern as qbit-object-storage#18 and qbit-backups#24. Why not defer the read to first use: the settings row's `chain_interval_seconds`, `export_cron` and `verify_cron` drive the schedule metadata, and the README, DESIGN and table help document that edits to them take effect after restart. Deferring would silently drop that contract (schedules would only ever use config values). Reading as the system user keeps it. ## Tests - `TokenRequiredAuthenticationModule` (test scope): accepts `QSystemUserSession` and issued sessions, throws `The token is null` for any other session, like the OAuth2 module. - `TokenRequiredHostTest`: production on a token-required host succeeds, honors a persisted edited settings row (chain interval, verify and export crons) and falls back to config without a row. All three fail without the fix (`IllegalState Cannot read WORM Audit Settings` caused by `The token is null`). - `./mvnw verify`: 98 tests, 0 skipped (PostgreSQL Testcontainers ran), checkstyle and JaCoCo green. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.