Skip to main content

haematite_cli/
loopback_http.rs

1//! HAEMNET-004 R3: the hosts on which an origin may be plain HTTP.
2//!
3//! The same three for every caller: the seat's Lys issuer,
4//! `mcp --lys-agent`, `mcp --remote` and the installer.
5
6/// Whether `host`, as `http::uri::Authority::host` gives it (an IPv6
7/// literal keeps its brackets), is loopback for plain HTTP.
8#[must_use]
9pub fn host(host: &str) -> bool {
10    matches!(host, "127.0.0.1" | "localhost" | "[::1]")
11}
12
13/// The origins every caller's own test reads: which plain-HTTP origins are
14/// loopback, and that an https origin is always allowed.
15#[cfg(test)]
16pub const CASES: &[(&str, bool)] = &[
17    ("http://127.0.0.1:8080", true),
18    ("http://localhost:8080", true),
19    ("http://[::1]:8080", true),
20    ("https://lys.example", true),
21    ("http://lys.example", false),
22    ("http://10.0.0.1:8080", false),
23    ("http://127.0.0.2:8080", false),
24];