Expand description
Secure-by-default response headers and configurable CORS.
The framework’s threat model treats a Seiva service as a JSON API sitting behind a TLS-terminating edge. Two transport-level controls address OWASP API Security API8 (Security Misconfiguration):
security_headers— a tower middleware that adds a conservative set of response headers (content-type sniffing off, framing denied, a locked-down Content-Security-Policy, HSTS) to every response, problems included. It only ever adds a header that is absent, so a handler that deliberately set its own value (a UI route relaxing the CSP, say) keeps it — no hidden override.cors_layer— builds aCorsLayerfrom an explicit allowlist of origins (HttpSecurity::cors_allowed_origins). An empty allowlist means no CORS layer at all, i.e. browsers enforce same-origin — the secure default. A cross-origin caller is admitted only when itsOriginis on the list.
Neither control changes a same-origin, non-browser caller’s behaviour beyond
the added response headers, so wiring them into router does
not break an existing request path.
Structs§
- Http
Security - The transport’s security configuration: the knobs a deployment turns that are
not safe to hard-code. Read from the environment by the server runtime (see
seiva-server) and handed torouter_with_security.
Functions§
- cors_
layer - Builds the CORS layer from the configured allowlist, or
Nonewhen the allowlist is empty (same-origin only — the secure default). - security_
headers - Middleware that adds the framework’s default security response headers.