Esc
Documentation
On this page

A connection field can hold a reference to a secret instead of the credential itself. A secret provider is what turns that reference into the value. DSUI asks the provider right before it calls the adapter, keeps the answer in memory for a few minutes, and never stores it. For the person’s side of this, see credentials from a secret manager.

The first-party secrets plugin already supports AWS Secrets Manager. Write your own plugin to support another manager.

Register a provider#

Call registry.secrets() in setup. A plugin can register several providers, and every provider ID must be unique across the plugins that are loaded. Unlike an authentication provider, a secret provider doesn’t need security: true.

ts
export default definePlugin({
  metadata: { id: "vault", name: "Vault", version: "0.1.0", apiVersion: 1 },
  configSchema: z.object({ address: z.string().url(), token: z.string() }),
  setup(registry, config) {
    registry.secrets({
      id: "vault",
      label: "HashiCorp Vault",
      reference: {
        label: "Path",
        placeholder: "kv/data/prod/airflow#password",
        hint: "A path, and #field to read one field.",
      },
      async resolve(reference, { signal }) {
        const [path, field] = reference.split("#");
        return readFromVault(config, path, field, signal);
      },
    });
  },
});

The id is what a reference names in provider. The reference object only describes the input in the connection form. DSUI never reads the reference string itself, so you choose its format.

Resolve a reference#

resolve(reference, { signal }) returns the secret’s value as a string. DSUI passes it to the adapter as if the person had typed it, so a number or a flag is returned as text and the adapter converts it as it does for typed values.

Throw an Error with a message that says what was asked for and why it failed. DSUI shows that message in the connection form and never logs the value. An error that contains a secret defeats the purpose, so never include one.

Honor signal. DSUI gives up on a provider that takes longer than 10 seconds.

Suggest secrets#

Add search(query, { signal }) so the form can offer a list while a person types. It returns entries with a reference, and optionally a label and a description:

ts
async search(query, { signal }) {
  const found = await listSecrets(config, query, signal);
  return found.map((secret) => ({
    reference: secret.path,
    description: secret.description,
  }));
},
  • Treat an empty query as “show the first ones”, and return no more than a few dozen entries. DSUI keeps 50.
  • Return only references and descriptions, never values.
  • Throw when the caller may not list. Listing often needs a broader permission than reading one secret. DSUI treats the failure as the answer, falls back to a plain input, and doesn’t ask again for 5 minutes.
  • Only the part of the reference before # is sent as query.

Suggestions are offered to people with the manage role, because a list of secret names tells them what exists.