class LittleGhost::Network::AuthorizerServer

Answers Envoy’s headers-only external authorization requests on a Unix socket by calling a trusted authorizer.

EnvoyGateway starts one for each run that needs it. An application that supervises Envoy itself can run the server in a separate, less privileged process so credentials stay out of both the sandbox and Envoy:

hosts = LittleGhost::Network::HostPolicy.new do
  host("api.example.com") { inject { {"x-api-key" => ENV.fetch("HELP_CENTER_API_KEY")} } }
end
server = LittleGhost::Network::AuthorizerServer.new(
  socket_path: "/run/egress-private/authorizer.sock",
  authorizer: hosts.authorizer,
  mode: 0o660,
  peer_uids: [Etc.getpwnam("envoy").uid]
)
stop_reader, stop_writer = IO.pipe
Signal.trap("TERM") { stop_writer.write_nonblock(".", exception: false) }
server.serve(stop_io: stop_reader)

authorizer receives request:, a Network::Request, and an optional run: keyword, and returns a Network::Decision. It may be called from several threads at once. An exception or any other return value denies the request with status 503; the response never includes the exception message.

Every allowed request also loses its Network::CREDENTIAL_HEADERS and forwarding headers unless the decision sets them.

The server answers only authorization requests that come from a listener in a configuration written by EnvoyGateway: Envoy prefixes each request path with the listener’s origin, which tells the server whether the destination comes from the inspected request’s Host or from a facade’s fixed upstream. Any other request is denied with status 503 without calling authorizer.