Module middleware

Module middleware 

Source
Expand description

Auth + protocol middleware for the v1 router.

StructsΒ§

AuthenticatedCn πŸ”’
Type-system witness that auth ran; private field prevents forgery in handler code.

ConstantsΒ§

NOT_READY_RETRY_AFTER_SECS πŸ”’
Retry-After hint advertised on 503 not-ready responses. Tracks channel_refs_poll::POLL_INTERVAL (60 s) loosely - agents spread their retries across the hint so the next poll cycle has time to complete before they all reconnect.

FunctionsΒ§

protocol_version_middleware πŸ”’
Forward-compat: missing header accepted; mismatched major -> 426. Strict mode rejects missing.
require_cn πŸ”’
401 on missing/revoked cert; re-enrolled certs (notBefore > revoked_before) pass.
require_cn_layer πŸ”’
require_ready_layer πŸ”’
503 with Retry-After: 30 until AppState::is_ready() returns true. Applied to every /v1/* route so agents see a deterministic β€œcome back later” signal instead of partial behaviour driven by stale or missing trust state. Health/version/metrics are routed outside /v1/* and stay unguarded so operators can scrape them while the daemon is still priming.