Skip to main content

Module control

Module control 

Source
Expand description

The control API: the only path that will ever be allowed to write.

No CORS headers are emitted anywhere in this module, and OPTIONS is refused. That combination is the security boundary, so it is worth spelling out.

A page served under an alias origin is untrusted code. If it tries to reach the control API it has to send the token header; a custom header is not CORS-safelisted, so sending it forces a preflight; and a refused preflight means the request is never made. Without the header the request is a 401 instead. An extension is outside CORS by virtue of its host permissions, so none of this impedes it.

The listener also only routes here for requests whose Host is the loopback address, which guard::classify already separates from alias requests. A proxied request cannot arrive here at all.

Structs§

Token
A bearer token for the control API.

Enums§

Source
Where the token this run is using came from.

Constants§

FETCH_SITE_HEADER
What a browser says about who started a request.
PATH_PREFIX
PROTOCOL_MAX
PROTOCOL_MIN
Protocol versions this daemon can speak.
TOKEN_HEADER
The header the token must arrive in.

Functions§

from_a_page
Check the two things that must hold before any control route runs, returning the refusal if there is one.
gate
hello
json
route_of
The route name within the control namespace, e.g. hello.
state_dir
Where this daemon keeps the small things it remembers between runs.
text