exlab_wizard.tray.storage_secret#

Per-installation NiceGUI storage_secret token. Backend Spec §15.3.

NiceGUI’s ui.run_with requires a non-empty secret to sign the Starlette SessionMiddleware that backs app.storage.user / app.storage.browser. The codebase doesn’t read app.storage.* today, so the secret is functionally vestigial – but mounting NiceGUI demands one. We generate a 32-byte hex token on first boot, write it to <state_dir>/storage_secret (mode 0600) atomically, and reuse it on subsequent boots so a future feature using app.storage doesn’t silently lose state across restarts.

Functions

load_or_create_storage_secret(state_dir)

Return the per-installation storage secret, generating it if absent.

exlab_wizard.tray.storage_secret.load_or_create_storage_secret(state_dir)[source]#

Return the per-installation storage secret, generating it if absent.

The file is created with mode 0600 so other local users cannot read it. On a corrupted / empty file the secret is regenerated and the event is logged WARN – losing the secret only resets browser storage scopes, which we don’t currently use.

Parameters:

state_dir (Path)

Return type:

str