Skip to content

Fill HashiCorp Vault logins in a Steel session

View as Markdown

Set up your agent

Give your coding agent a Steel browser and the Steel skills, so that it browses and writes Steel code the right way. Learn more

Install the Steel CLI. It signs you in and installs the skills for your coding agents.

curl -fsS https://setup.steel.dev | sh

Or send this prompt to your coding agent, and it does the same:

Read https://setup.steel.dev/install.md and follow it to set up Steel for this coding client.
Then continue my requested task using the installed Steel skill.

Set up your agent →

HashiCorp Vault is a secret manager that you run or rent. With a Secret Connection, a Steel session fills a login from a Vault secret into a sign-in form. The login stays in HashiCorp Vault: Steel reads it when the session needs it and does not store a copy. Your code and your agent never get the password.

Steel reads the KV version 2 secrets engine only. It signs in with a token or an AppRole. A session can use only the secrets that you bind to it.

Before you begin

  • A HashiCorp Vault server with an HTTPS address that the public internet can reach. Steel does not connect to a private address, and it does not follow redirects.
  • A KV version 2 mount, such as secret.
  • A Steel API key in the STEEL_API_KEY environment variable, for the API, SDK and CLI steps. See API keys. Secret Connections says what the SDK and CLI examples need.

Set up the integration

Store the login as a secret

Steel reads a login from the keys of one secret:

Part of the loginKey
UsernameThe first of username, email, login and identifier that the secret has
Passwordpassword
One-time password secretotp, totp, authenticator, mfa or 2fa, alone or with _secret, _seed or _key at the end, such as totp_secret

Steel ignores the case of a key. Each value must be a string. Steel does not read a secret that has an object or an array as a value.

vault kv put secret/team/acme-billing username="$SITE_USERNAME" password="$SITE_PASSWORD"

Give Steel read access

Write a policy that lets Steel read the secrets. To bind a path prefix, Steel must also list the paths under it.

path "secret/data/team/*" {
  capabilities = ["read"]
}

path "secret/metadata/team/*" {
  capabilities = ["list"]
}

Then make a token with this policy, or an AppRole. With an AppRole, Steel signs in again when its Vault token expires, so do not limit the secret ID to one use.

Connect HashiCorp Vault

In the dashboard:

  1. Open Credentials in the sidebar, then the Connections tab.
  2. Click Connect provider.
  3. Type a Name, and choose HashiCorp Vault as the Provider.
  4. Type the Vault address, such as https://vault.example.com, with no path.
  5. If you need them, type the Vault namespace and paste the CA certificate in PEM format.
  6. Choose the Authentication method. For Token, paste the token. For AppRole, paste the Role ID and the Secret ID, and type the AppRole auth mount if it is not approle.
  7. Click Connect provider. With a token, you can click Test first.

With the API, an SDK or the CLI, and a token:

curl -X POST https://api.steel.dev/v1/secret-connections \
  -H "steel-api-key: $STEEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "production",
    "provider": "hashicorp_vault",
    "config": { "address": "https://vault.example.com" },
    "auth": { "type": "token", "token": "'"$VAULT_TOKEN"'" }
  }'

With an AppRole, send this auth instead. In Python, the keys are role_id and secret_id.

{ "type": "approle", "roleId": "ROLE_ID", "secretId": "SECRET_ID" }
FieldRequiredDescription
config.addressYesThe HTTPS address of the server.
config.namespaceNoThe Vault namespace.
config.caPemNoA CA certificate in PEM format, for a server whose certificate a public CA did not sign.
auth.mountNoThe mount of the AppRole auth method. The default is approle.

The response has the connection's id, name, provider and enabled. It never has the config or the auth.

Bind a secret to a session

A binding names what the session can use, and the origins where Steel can fill it. You write the secret as a reference:

ReferenceThe session can use
steel://connections/<connection>/kv/<mount>/<path>One secret
steel://connections/<connection>/kv/<mount>/<path>/Every secret under the path, at any depth. The reference ends with a slash

<connection> is the connection's name or ID. Percent-encode each part of the path on its own, and do not encode the slashes between the parts. Steel reads the latest version of a secret.

A secret does not say which website it is for, so you give the origins in allowedOrigins. Steel fills the secret only on a page whose origin is in the list: the same scheme, host and port. A binding can have up to 20 origins.

In the dashboard:

  1. Open Sessions, and click Start session.
  2. Under Credential access, choose Choose what this session can use.
  3. Under Binding type, choose External provider item, then choose the connection.
  4. Type the KV v2 mount and the Exact secret path.
  5. Type the Allowed origins.
  6. Click Start session.

The dashboard binds one secret. To bind a path prefix or more than one secret, use the API.

With the API or an SDK, pass each binding as an object in credentials.bindings when you create the session:

curl -X POST https://api.steel.dev/v1/sessions \
  -H "steel-api-key: $STEEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "credentials": {
      "bindings": [
        {
          "reference": "steel://connections/production/kv/secret/team/acme-billing",
          "allowedOrigins": ["https://app.example.com"]
        }
      ]
    }
  }'

You can add or remove a binding while the session runs, as Change what a running session can use shows.

Open the sign-in page

Open a sign-in page on one of the allowed origins. Steel fills the username, the password and, if the secret has a one-time password secret, the code. Steel makes the code itself. The one-time password secret never reaches the browser.

With a prefix binding, every secret under the path matches each allowed origin. When two secrets match one page, Steel does not choose between them and fills nothing. Bind one secret for each login where you can, or choose one with Steel.credentials.fill.

Check that it worked

List what the session can use:

curl https://api.steel.dev/v1/sessions/$SESSION_ID/credentials \
  -H "steel-api-key: $STEEL_API_KEY"

The response has "lookup": "explicit", and your binding in bindings with its allowedOrigins. Then open the sign-in page in the session's live view. Steel fills the form shortly after the page loads.

Troubleshooting

The sign-in form stays empty

Cause: The page's origin is not in the binding's allowedOrigins, or the secret has no key that Steel reads, or one of its values is not a string. Under a prefix, Steel keeps the list of paths for up to 30 seconds, so a new secret can take that long to appear.

Fix: Compare the page's scheme, host and port with allowedOrigins. Name the secret's keys as Store the login as a secret shows, and store each value as a string.

Verify: Steel fills the form.

credential_path_forbidden

Cause: The token's policy does not let Steel read the secret. Steel.credentials.fill fails with this code, and Steel fills nothing on its own.

Fix: Add read on the secret's data path to the policy, and list on the metadata path for a prefix binding.

Verify: Steel fills the form.

The connection does not save

Cause: Steel cannot reach the server. The address is not HTTPS, it has a path, it goes to a private network, or the server redirects.

Fix: Use the server's public HTTPS address with no path. If a private CA signed the server's certificate, add it as the CA certificate.

Verify: The connection's test returns 204.

Next steps

Was this page helpful?