class

Arcana::LocalGuard

Inherits HTTP::Handler < Reference < Object

Keeps web pages off the bus. Any page open in a browser on this machine can reach a server on 127.0.0.1: browsers let it open a WebSocket to any address, and POST a text/plain body without asking first. So a page or an ad could join as any address, call a service that spends money, or consume someone's mail.

The browser names the page's site in Origin and the server it asked for in Host, and a page's scripts can set neither. A request is refused when Origin names a site that isn't this machine, or when Host isn't a name for this machine: DNS rebinding, a site pointing its own name at 127.0.0.1, still sends that site's name. Programs send no Origin, and their Host is the address they connected to, so they pass.

allowed adds names that count as this machine's (a bus reached by a hostname). A server bound to every interface (0.0.0.0) with none listed doesn't check Host, since its clients may use any name for it; Origin is still checked.

Constructors

new(bind_host : String, allowed : Array(String) = [] of String, events : Events::Backend | Nil = nil)
Source

Instance methods

refusal(request : HTTP::Request) : String | Nil

Why the request is refused, or nil.

Source