Skip to content

feat(ingest): set the first ingest token from configuration - #450

Merged
vishr merged 3 commits into
mainfrom
feat/ingest-token-from-config
Nov 8, 2026
Merged

vishr merged 3 commits into
mainfrom
feat/ingest-token-from-config

Conversation

@vishr

@vishr vishr commented Nov 8, 2026

Copy link
Copy Markdown
Member

Closes #446

What changed

An automated install can now accept telemetry as soon as it starts. FANOUT_INGEST_TOKEN (or FANOUT_INGEST_TOKEN_FILE) supplies the first ingest token.

  • Applied once. At startup the token's hash is stored only when no hash exists. Once one exists the setting is ignored, so a token rotated in the UI survives restarts.
  • Validated at load. A value that is not foi_ plus 43 base64url characters fails configuration load. The error names the setting and never the value.
  • Hash only. The raw token is not stored or logged. Startup logs the outcome by setting name, and the write records an ingest_key.rotated audit event with source: configuration.
  • Interactive setup still works. Setup already leaves an existing token alone, so after a configured token it completes normally and returns no ingest_token. The login UI treats that response as a normal sign-in.
  • Without the setting, behaviour is unchanged.
  • Docs. The generated settings reference and .env.example are regenerated. Send-telemetry, first-boot, deploy, operations and authentication docs are updated, including removing the deploy guide's statement that no such setting exists.

For reviewers

  • Security and runtime behaviour: this adds a new way to set the ingest credential. The ingest auth check itself is unchanged.
  • The check and the write share one transaction, so the setting row and audit event commit together. A read-then-write transaction can be aborted by a concurrent SQLite writer, so startup applies the token before the alert engine starts. settingsStore and auditStore moved earlier in main for this reason.
  • A stored row with an empty hash counts as no token.
  • The format check in Validate uses the same secret.ValidSecret(value, "foi_") as ingest auth. internal/config cannot import internal/settings, because settings depends on auth, which config already imports.

Verification

Ran:

  • just check, through the pre-push hook on this commit: passed.
  • bash scripts/with-duckdb.sh go test -race ./internal/config ./internal/settings ./internal/ingest ./internal/api ./cmd/fanout -count=1: passed.
  • just docs-generate, then just docs-generate-check: in sync.
  • Manual run of the built binary against an empty data directory, using OTLP/HTTP to /v1/logs:
    • First boot with the setting: the configured token returned 200, a different token returned 401.
    • Restart with a different value: the original token still returned 200, the new value returned 401.
    • Malformed value: exit 1, with an error naming the setting and not containing the value.
    • Neither token appeared in the captured process logs.

New tests cover the hash stored on an empty install, a later restart with a different value, UI rotation surviving a restart, an empty stored hash, a corrupt stored setting, malformed values through both the environment and _FILE, both forms set, ingest accepting the token, setup after a configured token, and log output never containing the token or its hash.

Not run:

  • Full just test-race; only the five packages above ran with -race.
  • Interactive setup in a browser after a configured token. It is covered at the API level by TestSetupKeepsTokenAppliedFromConfiguration; the UI branch for a response without ingest_token was read, and no UI code changed.

Checklist:

  • just check
  • just test-race (focused -race run only, as above)
  • User-facing behavior and configuration docs are current
  • No credentials, private telemetry, host details, or enterprise-only source are included
  • API, migration, ingest, MCP/AG-UI, or release-contract changes are called out
  • No breaking or batch-format change

vishr added 2 commits November 8, 2026 08:21
Ingest stays closed until an administrator issues a token by hand, so an
automated install cannot accept telemetry as soon as it starts.

FANOUT_INGEST_TOKEN (or its _FILE form) now supplies the first token. Its
hash is stored at startup only when no hash exists, so a token rotated in
the UI survives restarts. The value must match the ingest token format,
and a malformed one fails configuration load naming only the setting.

Closes #446
@vishr
vishr enabled auto-merge (squash) November 8, 2026 16:38
@vishr
vishr merged commit 6f28a9a into main Nov 8, 2026
19 checks passed
@vishr
vishr deleted the feat/ingest-token-from-config branch November 8, 2026 17:25
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.

Set the first ingest token from configuration

1 participant