Plugin proxies and secrets
A proxy is a request that the server makes on behalf of a widget, built from a template in the manifest. The frame names the proxy and supplies arguments. It never builds a URL or a header itself, and it never sees a secret. A proxy is the right choice whenever a call needs an API key, or whenever the answer should not appear in the browser's network panel.
This manifest excerpt declares a secret and a proxy that reads quotes from an external service:
"secrets": [{ "name": "api_key", "purpose": "Reads quotes from the quote service" }],
"server": {
"network": ["https://quotes.example.org"],
"proxies": [
{
"id": "quote",
"method": "GET",
"url": "https://quotes.example.org/v1/quotes/${arg:symbol}",
"query": { "period": "${arg:period}" },
"headers": { "Authorization": "Bearer ${secret:api_key}" },
"args": {
"symbol": { "type": "string", "maxLength": 12, "required": true },
"period": { "type": "enum", "values": ["day", "week"] }
},
"response": { "accepts": ["application/json"], "maxBytes": 1048576, "timeoutMs": 10000 }
}
]
}
The widget lists the proxy as "server": { "proxies": ["quote"] }, asks for the permission core:proxy:call, and then calls the proxy from its module:
const [quote] = await experimental.invoke("core:proxy:call", {
id: "quote",
args: { symbol: "IBM", period: "day" },
});
The parts of a proxy
The tables are generated from the model that the backend validates a proxy with, so their limits are the ones that the backend enforces. A proxy has these properties:
argsobjectmaxProperties 32The arguments that the proxy accepts, by name. The server refuses unknown arguments.
bodymap<string, string | integer | number | boolean | null> | nulldefaultnullThe JSON body of a POST request, a flat object with literal names. A field whose value is exactly ${arg:<name>} keeps the type of the argument, and text around a token turns the field into a string.
headersmap<string, string>maxProperties 16The headers of the request. A value may contain ${secret:<name>} and nothing else. A manifest cannot set a header that changes how a request travels.
idstringrequiredpattern ^[a-z][a-z0-9_-]{0,63}$The proxy's id, unique within the plugin.
method"GET" | "POST"default"GET"The method of the request that the server makes.
querymap<string, string>maxProperties 32property names: maxLength 128The query of the request, with literal names. A value may contain ${arg:<name>}, and the server leaves out a value whose argument is absent.
responseProxyResponseThe limits of the upstream's answer.
urlstringrequiredminLength 1maxLength 2048The https URL of the request, with a literal host and port that appear in server.network and no query or fragment. A ${arg:<name>} token may appear in the path after the host.
An argument has these properties:
maxLengthintegerdefault256minimum 1maximum 2048The most characters that a string argument may have.
maximumnumber | nulldefaultnullThe largest value that a number argument may have.
minimumnumber | nulldefaultnullThe smallest value that a number argument may have.
requiredbooleandefaultfalseWhether a call must supply the argument.
type"string" | "number" | "boolean" | "enum"requiredThe kind of value that the argument holds.
values(string | integer | number | boolean)[] | nulldefaultnullThe values that an enum argument may have.
The response has these properties:
accepts("application/json" | "text/plain" | "text/csv" | "text/markdown" | "text/html" | "application/xml")[]minItems 1The content types that the server accepts from the upstream. A response of another type is refused.
maxBytesintegerdefault1048576minimum 1maximum 26214400The most bytes that the server reads from the upstream. The deployment caps the value as well.
timeoutMsintegerdefault10000minimum 100maximum 30000How long a call may take, in milliseconds. The deployment caps the value as well.
The field accepts lists one or more of the content types application/json, text/plain, text/csv, text/markdown, text/html and application/xml, and it defaults to JSON. The field maxBytes may be at most 25 MiB and the field timeoutMs at most 30 seconds. The deployment caps both values as well, by default at 5 MiB and 30 seconds, with the settings WIDGET_PLUGIN_PROXY_MAX_BYTES and WIDGET_PLUGIN_PROXY_TIMEOUT_MS.
Several further rules apply to every proxy:
- The
idconsists of lowercase letters, digits,_and-, and it is unique within the plugin. The method isGETorPOST. - The URL uses
https://with a literal host and port that appear inserver.network, and it has no query or fragment. A${arg:<name>}token may appear only in the path after the host. The server encodes its value as one path segment, and the argument is required. - A
${secret:...}token is never allowed in the URL, the query or the body. A key therefore never ends up in a URL or a log. A header value may contain${secret:<name>}and nothing else. - A manifest cannot set a header that changes how a request travels. These are the headers
accept-encoding,connection,content-length,content-type,cookie,expect,forwarded,host,keep-alive,proxy-authorization,proxy-connection,te,trailer,transfer-encoding,upgrade,x-forwarded-for,x-forwarded-host,x-forwarded-protoandx-real-ip, and every header whose name starts withsec-orproxy-. A header value may contain printable ASCII only. - A body is allowed only with
POST, and it is a flat object with literal names. A field whose value is exactly${arg:<name>}keeps the type of the argument, and text around a token turns the field into a string. A field whose argument is absent is left out. The server sends the body as JSON. - A query value may contain
${arg:<name>}, and the server leaves out a value whose argument is absent. - The
server.networklist contains https origins, and it follows the host rules of the frame policy, so it cannot contain an IP address or a private host. The host of every proxy must appear in it. Atcp://entry belongs to a backend and never to a proxy. - The server resolves the host itself. It refuses a name that resolves to a private, loopback, link-local or metadata address, and it does not follow redirects. It asks for an uncompressed answer and refuses a compressed one. When the upstream answers with a status outside the 2xx range, the widget receives an error that names only the class of the status, and the server keeps only the
Content-Typeof the answer. - A successful call resolves to the response body. That is parsed JSON for
application/jsonand text for every other type. - A refused call rejects with one of the error names on Plugin permissions and commands. The name is
invalid_argsfor bad arguments,not_grantedwhen the permission was removed, andout_of_scopefor a proxy that the widget does not list. It israte_limited,timeoutortoo_largewhen the matching limit is exceeded, andunavailablein every other case, for example when a secret is not set or when the upstream failed. - The server rate limits calls for each user and for each plugin, by default at 60/minute and 600/minute, and it lets at most 8 calls of one plugin run at the same time in each API process.
Secrets
A manifest declares the secrets that it needs by name and purpose, and it never ships a value. A value is at most 4,096 characters. The deployment or a superuser sets the values, as Deploy a widget plugin explains. A value can be written but never read back: the server encrypts it at rest with WORKSPACE_AES_KEY, sends it only in the requests that declare it, and never returns it, logs it or puts it in an error message.
The outbound guard
Every proxy request passes through the outbound guard in backend-api/backend/utilities/egress.py. The guard resolves the host name itself and refuses the request when any resolved address is loopback, private, link-local (including the cloud metadata address), shared, multicast, reserved or part of a documentation range, in IPv4 or in IPv6. A superuser's override can allow private hosts. The guard connects to the address that it checked, and it keeps the name for the Host header and for TLS. It verifies the certificate and follows no redirects. It also refuses a compressed answer, so that the size cap counts the bytes that actually arrive. An upstream that uses a certificate from a private authority needs WIDGET_PLUGIN_PROXY_CA_FILE.