DocsServer features
Security middleware
Apply a PulsePoint-compatible browser security baseline to every response, with explicit application-owned overrides.
Generated once, applied everywhere
The generated router installs security headers automatically around pages, RPCs, APIs, redirects, probes, development endpoints, 404s, and public files. An existing response header wins, allowing a route or proxy to enforce a stricter value.
| Header | Default purpose |
|---|---|
| Content-Security-Policy | Restricts loading, framing, forms, base URLs, and plugins. |
| Permissions-Policy | Limits camera, geolocation, microphone, payment, and USB. |
| Referrer-Policy | Keeps paths and queries out of cross-origin referrers. |
| X-Content-Type-Options | Disables MIME guessing. |
| X-Frame-Options | Adds legacy same-origin framing protection. |
| Strict-Transport-Security | One year, this host only, outside development. |
HSTS is sent even when TLS terminates at a reverse proxy, because the browser reads it from the final response. The default, max-age=31536000, covers this host only. Add includeSubDomains only when every subdomain of the site is served over HTTPS: a browser that has seen it refuses plain HTTP on all of them for the whole max-age, and no later response can take that back.
Content Security Policy
The default locks default-src 'self', script-src 'self', object-src 'none', base-uri 'self', form-action 'self', frame-ancestors 'self', require-trusted-types-for 'script', and trusted-types pulsepoint. Applications should replace broad HTTPS allowances for styles, images, media and connections with the exact external hosts they use.
script-src is 'self' and nothing else, because PulsePoint never turns page text into code. Every binding, handler and component script is compiled when the application is built and served from /_rahti/client.js, which public/js/main.js imports before it mounts the page. The runtime runs only what that registry holds, and the browser refuses an injected inline script or onerror= attribute and reports the violation.
Trusted Types make the browser refuse a plain string at every sink that parses markup or code, such as innerHTML. Exactly one policy may exist, PulsePoint's, so the runtime is the only code on the page that can write markup. A library that assigns innerHTML with a string throws; give it an element to own through pp.ref and its own DOM API instead.
Replace the policy during startup
use rahti::security::{self, SecurityHeaders};
security::configure(SecurityHeaders {
content_security_policy: Some(
"default-src 'self'; \
script-src 'self' https://js.stripe.com; \
style-src 'self' 'unsafe-inline'; \
img-src 'self' data:; connect-src 'self' ws: wss:; \
object-src 'none'; base-uri 'self'; \
form-action 'self'; frame-ancestors 'self'; \
require-trusted-types-for 'script'; trusted-types pulsepoint".into(),
),
// This deployment's proxy owns HSTS.
strict_transport_security: None,
..SecurityHeaders::default()
});Each field is an Option<String>; None omits it. Malformed values fail configuration. Set strict_transport_security to None when the reverse proxy owns HSTS.
What headers do not replace
Keep using escaped rendering, validation, authentication, authorization, and the generated CSRF layer. Security headers constrain a browser; they do not decide whether a caller or mutation is valid.
