Skip to main content

Admin UI plugins

A UI plugin is an external service that appears as a view in the Admin UI's view switcher, next to the AI Gateway view, rendered in an iframe. It suits internal tools that belong beside the gateway, such as a cost dashboard or an approval workflow, without those tools having to be built into the dashboard.

general_settings:
plugins:
- name: cost-review
display_name: Cost review
url: https://cost-review.internal.example.com
plugin_key: os.environ/COST_REVIEW_KEY
FieldMeaning
nameUnique kebab-case identifier.
display_nameLabel in the view switcher. Defaults to name.
urlBase URL of the plugin service, loaded in the iframe. It must be an absolute http:// or https:// URL. The gateway refuses any other scheme when you save it and skips a stored entry that has one.
plugin_keyThe plugin's own credential, sent as a bearer token only on reverse proxied calls. Never returned to the browser.

The registry is replaced from general_settings at startup and on config reload, so a plugin removed from the file becomes unreachable without a restart. The Plugins tab of the Admin Settings page shows the registered plugins and can also add, edit and delete them. A plugin saved there is stored in the database and every gateway picks it up on its next config reload, without a restart.

A real-world scenario​

A finance team has an internal cost review web app that shows each team's model spend next to its budget request. Platform admins kept switching between the gateway dashboard and that app. The operator registers the app as a plugin named cost-review, gives it the app's own API credential as plugin_key, and now the Admin UI view switcher offers Cost review beside AI Gateway. The app learns who is looking at it from the session claim the gateway issues, and when it needs gateway data it goes through /plugin-proxy/cost-review/..., where the gateway adds the app's credential and never hands it to the browser.

Identity for the plugin​

The UI asks GET /api/plugins/auth-token?plugin_name=cost-review for a session claim and passes it to the iframe. The claim holds the user id, user role, plugin name and an expiry 30 seconds out, encrypted with a key derived from SPANWAY_SALT_KEY and the plugin name. It carries no gateway credential, so a compromised plugin learns who the viewer is but cannot act as them. Each plugin can only decrypt its own claims, and the salt itself is never shared. Without SPANWAY_SALT_KEY the endpoint answers 503. GET /api/plugins lists the plugins with their names, display names and URLs for signed in users.

MethodPathSummary
GET/api/pluginsList the Admin UI plugins
GET/api/plugins/auth-tokenIssue a plugin session claim

Reverse proxy for admins​

/plugin-proxy/{name}/{path} forwards a request to the plugin service for proxy admins only. The caller's gateway credential headers and cookies are stripped, the plugin's plugin_key is injected as the Authorization header, and x-spanway-user-id and x-spanway-user-role are added as informational headers the plugin must not treat as credentials. Redirects are not followed, and a plugin that answers with a redirect gets the caller a 502 instead, so a plugin can neither steer the gateway into fetching internal addresses nor hand the admin's browser a link of its choosing. Every call that can change something, POST, PUT, PATCH and DELETE, writes an audit row on Spanway_Config with action invoked, the plugin name as object_id, the admin who made it and the method, path and status, never the body. Responses are returned with a sandboxing content security policy and nosniff, and the plugin's set-cookie headers are dropped, so plugin controlled bytes cannot run with the admin's session on the dashboard origin.

Step by step​

  1. In the Admin UI open Settings, then Admin Settings, the Plugins tab, and click Add Plugin. Fill in Name (identifier), Display Name, URL and, if the plugin needs one, Plugin Key, then click Save. The key is masked in the table and never shown again, so keep a copy where you manage the plugin. Or add the plugin under general_settings.plugins in config.yaml as shown above and restart or reload the gateway. A plugin set in the file cannot be changed from the tab.

  2. List the registered plugins with any signed in key:

    curl http://localhost:4000/api/plugins -H "Authorization: Bearer $SPANWAY_API_KEY"

    Expected result:

    [{"name": "cost-review", "display_name": "Cost review", "url": "https://cost-review.internal.example.com"}]
  3. Ask for a session claim the way the UI does:

    curl "http://localhost:4000/api/plugins/auth-token?plugin_name=cost-review" -H "Authorization: Bearer $SPANWAY_API_KEY"

    Expected result: {"session_claim": "gAAAA..."}, a token the plugin decrypts with the key derived from SPANWAY_SALT_KEY and its name, valid for 30 seconds.

  4. Back on the Plugins tab the plugin is listed, with Edit and Delete buttons on its row. Then use the view switcher at the top of the sidebar to open Cost review. The plugin loads in an iframe with the claim.

  5. As a proxy admin, call the plugin through the reverse proxy and confirm the plugin received its own credential and the x-spanway-user-id and x-spanway-user-role headers:

    curl http://localhost:4000/plugin-proxy/cost-review/api/summary -H "Authorization: Bearer $SPANWAY_API_KEY"

    The reverse proxy route forwards whatever the plugin serves, so it is not part of the published API reference.

Errors​

StatusRouteMeaningFix
503 SPANWAY_SALT_KEY is not configured; plugin iframe auth unavailable.GET /api/plugins/auth-tokenNo salt key, so no claim can be encrypted.Set SPANWAY_SALT_KEY.
404 Plugin '<name>' is not registered.GET /api/plugins/auth-tokenThe name is not in the registry, or its entry was skipped for an invalid URL.Check general_settings.plugins and the startup log.
404 Plugin '<name>' not registered (plain text)/plugin-proxy/...The same, on the reverse proxy.The same.
403 Plugin proxy access requires proxy_admin role. (plain text)/plugin-proxy/...The caller is not a proxy admin.Use a proxy admin key or session.
502 Cannot connect to plugin '<name>' at <url> (plain text)/plugin-proxy/...The plugin service did not answer.Check the plugin's URL and that the service is up.
502 Plugin '<name>' answered with a redirect, which the gateway does not follow (plain text)/plugin-proxy/...The plugin answered with a 3xx.Make the plugin answer the path directly, without redirecting.

If the plugin is missing from the switcher, its url is not an absolute http:// or https:// URL and the entry was refused on save or skipped on load. Fix the URL.

Logs​

LevelLineMeaningAction needed
WARNINGplugins: skipped a plugin entry with invalid fields <fields>A stored or configured plugin entry is invalid, for example its URL is not an absolute http:// or https:// URL, so it was left out of the registry.Fix the named fields in the Plugins tab or in config.yaml.

Audit​

Adding, editing and deleting plugins saves general_settings.plugins, which writes an audit row on Spanway_Config like every other setting change, with the plugin key masked. Calls through the reverse proxy that can change something are audited as described in reverse proxy for admins, see audit logs.