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
def assert_secure_gateway_transport(url: str) -> NoneParameters
ParamField
strNo description available.
Exceptions
InsecureGatewayTransportError
On plaintext transport to a public IP.
Usage
>>> assert_secure_gateway_transport("ws://localhost:8765")
>>> assert_secure_gateway_transport("wss://gateway.example.com")Uses
urlsplitrstripis_loopbackwarninglogging.getLoggeripaddress.ip_networkInsecureGatewayTransportError
Source
View on GitHubpraisonaiagents/gateway/protocols.py at line 2719