Creating a plugin proxy
Last updated
Last updated
To access authenticated external APIs with your , you can configure a plugin proxy.
Plugin proxies try to match incoming requests against configured URL prefixes and apply rules to those requests (such as adding headers) before propagating the request to the specified downstream URL. Header rules have access to secrets via Mustache-like templating for easy authentication.
Plugin proxies must be explicitly associated with a particular plugin in the plugin configuration; once specified, all proxyFetch requests made by that plugin will use the proxy. If no proxy is defined for a plugin, no special logic will apply and requests will be propagated to downstream URLs without modification.
When creating a plugin proxy, consider the following:
If there are multiple matching URL prefixes with overlapping header keys, the more specific (i.e. longer) prefix rules will be used.
If a request from the plugin is invoked with header keys that overlap the proxy ruleset, the request-specific header values will be used.
Users with the Edit plugin proxies
permission can create a plugin proxy.
If you are using a proxy with sensitive information, such as an access token, first follow the for your proxy.
Navigate to Plugins. In the upper right corner, click Create proxy.
Configure the proxy:
Proxy name: Enter a human-readable name for the proxy.
Path: This field is automatically populated based on the name. It is a unique identifier for the proxy.
URL prefixes: Click Add URL to configure URL prefixes to apply rules to requests going through this proxy. All requests passing through this proxy that match the URL prefix will have a set of rules applied.
Header: Optionally configure a header for the URL.
If you are using a proxy with sensitive information, you can use Mustache-like templating to reference a global secret by tag, e.g., {{secrets.my_auth_token}}
.
Click Create proxy.
In this scenario, the request to fetch GitHub requests will be sent with the X-GitHub-API-Version
and Authorization
headers, with the Authorization
header value interpolated to include the github_read_token secret if it exists in your Cortex workspace.
In the row containing the proxy, click the 3 dots icon.
In the dropdown that appears, click Edit proxy.
Make any desired changes, then click Save proxy.
In the row containing the proxy, click the 3 dots icon.
In the dropdown that appears, click Delete proxy.
In the confirmation modal, click Delete.
See a sample plugin proxy configuration and sample plugin code below under .
You can view your plugin proxies in Plugins under the .
Navigate to Plugins then click the .
Navigate to Plugins then click the .