Skip to content

Secrets, passwords, and OpenBao: Secrets in workflows

Back to Secrets, passwords, and OpenBao.

Workflows can send credentials from a module with the Secrets capability without the value ever appearing in the workflow definition, the system’s Git repository, workflow variables, logs, or outputs. Currently the api/http element supports this.

{
"name": "switch_plug",
"type": "api/http",
"options": {
"uri": "https://shelly-59-eu.shelly.cloud/device/relay/control",
"method": "POST",
"response_type": "json",
"request": {
"query": "{'auth_key': secret('Shelly Cloud')}",
"headers": "{'Authorization': 'Bearer ' + secret('Billing API'), 'Accept': 'application/json'}",
"form_params": "{'id': $device_id, 'turn': 'on'}"
}
}
}
secret("Name")
secret("Name", "username")
  • Name is the value of the secret’s name field. It must be unique across all secret modules of the system.
  • The optional second argument selects a field of the stored value. Without it, login secrets send password; api_key and generic secrets send value.
  • Only static types (login, api_key, generic, ssh_static, database_static) have a value a workflow can send.

secret() does not return the value. It returns a random placeholder, which also works inside strings, for example 'Bearer ' + secret('Billing API'). The api/http element replaces it right before the request is sent.

Write secret() directly in the options of the api/http element (uri, params, request, json, body). The element replaces only placeholders created while evaluating its own options. A placeholder passed on through set, another element, an entity field, or a webhook payload stays a placeholder. This prevents data from outside the workflow from requesting a secret.

A workflow uses the secrets of the person responsible for it. Responsible is whoever last saved the workflow in the workflow editor or put a draft containing it live. When an agent puts a draft live from a chat, the person in that chat is responsible. AI users never become responsible. bakery apply without a person (deployments, CLI) keeps the existing responsible person.

The workflow can use a secret if that person can use it: root users, the creator of the secret, and people or roles listed in human_grantees or role_grantees. It does not matter what triggers the run (an event, a cron, a webhook, or another user).

Saving a workflow or putting it live is refused if the person may not use every secret the workflow names. The workflow editor answers with HTTP 422 workflow_secret_access; a draft fails with the same message, and the agent that created it is told. Someone with access has to put it live, or the secret has to be shared with that person.

If the responsible person later loses access, or the workflow has no responsible person yet (for example a workflow from before this feature that nobody has saved since), the request is not sent and the element continues on its error port. Saving the workflow as a person with access fixes this.

The secret’s URL field restricts where its value may go. Enter one address per line:

https://shelly.cloud
https://api.example.com
http://legacy-device.local
  • A listed host also allows its subdomains (shelly.cloud allows shelly-59-eu.shelly.cloud).
  • Without an explicit http://, only HTTPS is allowed.
  • Redirects are checked too. A redirect to another host is blocked before anything is sent there.
  • An empty URL field allows every host. Fill it in for every secret used by workflows.

A blocked request continues on the error port with a message such as Blocked: the secret "Shelly Cloud" may only be sent to shelly.cloud, not to https://example.org.

  • The workflow definition and its Git history contain only secret('Name').
  • If the API echoes the value in its response or error, the default and error outputs contain [secret] instead.
  • Each use is recorded in the secret broker’s audit log as workflow_use, with the workflow identifier and the responsible person, never with the value.

Workflow tests never fetch secret values. The recorded request shows readable placeholders such as {{secret:Shelly Cloud}} or {{secret:Shelly Cloud.username}}, so a test can assert that the secret is used:

{"type": "http_request_sent", "url": "https://*.shelly.cloud/*", "body_contains": "{{secret:Shelly Cloud}}"}

Previews of drafts have no access to the live system’s secrets, so real calls with secret() fail there.

  • api/sftp, api/db, IMAP, and the other elements still take credentials as plain options.
  • The legacy source/getSecret and action/putSecret elements use the old SQL repository, not this mechanism.