ExMCP.Authorization.SecureHTTP (ex_mcp v1.0.0-rc.8)

Copy Markdown View Source

Bounded, redirect-free HTTP boundary for OAuth protocol requests.

The destination is resolved once, every returned address is checked against the network policy, and the request URL is rewritten to the selected address. The original host is retained in the HTTP Host header and TLS SNI, so DNS cannot be re-resolved between validation and connection establishment. Response bodies are read incrementally and the connection is closed as soon as the configured size limit is exceeded.

Plain HTTP is accepted only for loopback development endpoints. Private HTTPS endpoints are rejected by default and may be enabled only by listing their exact hostname in :allowed_private_hosts.

Summary

Functions

Returns the effective configuration after application and call overrides.

Sends one request through the hardened OAuth HTTP boundary.

Validates and resolves a URL under the same policy used by request/5.

Types

response()

@type response() ::
  {{String.t() | charlist(), non_neg_integer(), String.t() | charlist()},
   list(), binary()}

Functions

options(overrides \\ [])

@spec options(keyword()) :: keyword()

Returns the effective configuration after application and call overrides.

request(method, url, headers \\ [], body \\ nil, opts \\ [])

@spec request(
  atom(),
  String.t(),
  [{String.t(), String.t()}],
  iodata() | nil,
  keyword()
) ::
  {:ok, response()} | {:error, term()}

Sends one request through the hardened OAuth HTTP boundary.

The response shape matches :httpc.request/4, but the body is always a binary. Redirects are returned to the caller and are never followed.

resolve_target(url, opts \\ [])

@spec resolve_target(
  String.t(),
  keyword()
) :: {:ok, URI.t(), :inet.ip_address()} | {:error, term()}

Validates and resolves a URL under the same policy used by request/5.

The returned address is the address that a caller must connect to in order to preserve the validation result.