Skip to main content

Module scheme

Module scheme 

Source
Expand description

Externally visible request scheme, with proxy headers honoured only from a trusted proxy.

JSS derives the public scheme from X-Forwarded-Proto and, failing that, the Cloudflare cf-visitor: {"scheme":"https"} header (src/ap/index.js getProtocol 49-56 and src/ap/routes/actor.js 17-18). Those headers are attacker-controlled unless a proxy that the operator trusts overwrites them, and the scheme feeds the NIP-98 signed-URL check and every absolute base URI the server mints. So here they are honoured only when the operator sets the trusted-proxy flag (--trust-proxy / JSS_TRUST_PROXY, default off). Without it the scheme is the transport’s own: https when the listener terminates TLS, else http.

Functions§

effective_scheme
effective_scheme_with using the server’s configured trusted-proxy flag (false when the request carries no AppState).
effective_scheme_with
The request scheme as the client sees it.
host_allowed
true when host (a host[:port]) is permitted by allowed, an empty list permitting everything. Entries match case-insensitively either the whole authority or just the host part.
host_with
The authority a request should be treated as addressed to, with the configuration passed explicitly.
normalise_origin
Reduce a configured public base URL to its origin (scheme://authority, no path, no trailing slash). None when it is not an http(s) URL with a usable authority.
proxy_header_scheme
Scheme named by the proxy headers, if any: X-Forwarded-Proto first (first element of a comma list), else the scheme member of the cf-visitor JSON object. An unusable X-Forwarded-Proto value falls through to cf-visitor.
request_host
host_with using the server’s configured public origin and trusted-proxy flag.
request_origin
scheme://host of the request. A configured public origin wins outright; otherwise effective_scheme plus request_host.
request_url
The absolute URL the client addressed (origin plus request target), the value a NIP-98 u tag is signed over.