Class Nexus\Mcp\Server\Transport\Http\Middleware\DnsRebindingProtectionMiddleware

final
readonly
implements MiddlewareInterface

Guards the MCP endpoint against DNS rebinding by rejecting requests from an unrecognised Origin or Host. A present-but-unlisted Origin is answered with an id-less JSON-RPC error on HTTP 403. A request without an Origin header (non-browser clients) passes through, since only browsers send it. Host validation is a beyond-spec, opt-in dimension: an empty allow-list disables it, otherwise the Host header must be present and listed. Matching is case-insensitive, since RFC 9110 makes the scheme and host of a URI so.

Methods