Assert Secure Gateway Transport • AI Agent SDK

assert_secure_gateway_transport: Guard plaintext “ws://“ / “http://“ gateway URLs.

assert_secure_gateway_transport

Function

</div>

This function is defined in the protocols module.

Guard plaintext `ws:// / http://` gateway URLs.

`wss:// / https://, loopback, private/link-local/CGNAT IPs and single-label names are always allowed. A plaintext URL to a public IP literal raises; a plaintext URL to a multi-label DNS name only logs a warning, because names such as gw.default.svc.cluster.local or Tailscale MagicDNS hosts are commonly private and cannot be classified without a (blocking) DNS lookup. PRAISONAI_ALLOW_INSECURE_WS=1` disables the check.

Signature

python
def assert_secure_gateway_transport(url: str) -> None

Parameters

ParamField str

No description available.

Exceptions

InsecureGatewayTransportError

On plaintext transport to a public IP.

Usage

python
>>> assert_secure_gateway_transport("ws://localhost:8765")
    >>> assert_secure_gateway_transport("wss://gateway.example.com")

Uses

  • urlsplit
  • rstrip
  • is_loopback
  • warning
  • logging.getLogger
  • ipaddress.ip_network
  • InsecureGatewayTransportError

Source

View on GitHub

praisonaiagents/gateway/protocols.py at line 2719


Related Documentation