# Injected credentials

> For the complete documentation index, see [llms.txt](https://docs-stg.ringleader.dev/llms.txt).


> Let the tools on a workstation call an API that needs a key, while the key stays off the workstation.


Let the tools on a workstation call an API that needs a key, while the key stays off the
workstation. You name a Secret and either a service preset or the host and header to use. When a
request to that host leaves the workstation, Ringleader adds the key from the Secret. The tools on
the workstation use the API as if they had signed in. Nothing running on the workstation can read
the key, print it or send it anywhere else. A key in an environment variable is different, as
[Secrets on the workstation](https://docs-stg.ringleader.dev/security/credentials/secret-handling/#secrets-on-the-workstation)
explains.

You declare injection as an [Integration](https://docs-stg.ringleader.dev/reference/resources/integration/) of
`type: httpProxy`. It works on cloud workstations, on local workstations on a Mac or a Linux
computer, and on hcs workstations on Windows.

## Prerequisites

- A Secret that holds the key, as [Create a Secret](https://docs-stg.ringleader.dev/security/credentials/secret-handling/#create-a-secret)
  shows. You must be able to read it, and
  [Places that name a Secret](https://docs-stg.ringleader.dev/reference/resources/secret/#places-that-name-a-secret)
  says who else must.
- For a cloud workstation, an Edge for its cloud and region. [Declare an Edge](https://docs-stg.ringleader.dev/security/outbound/edge-management/#declare-an-edge)
  shows how.
- If your organization has an OrgPolicy or a Policy ([Policy and OrgPolicy](https://docs-stg.ringleader.dev/reference/resources/policy/)) with
  `egressDestinations`, it must permit every host a rule names, and an MCP server's host. An
  Integration naming a host the policy does not permit is refused when you apply it. Excluded
  hosts are not checked.

## Providers and where the key is added

Where Ringleader adds the key depends on the workstation's provider:

| Provider | Where the key is added | What you declare |
|---|---|---|
| GCP, AWS, Azure | On an edge instance, the Edge's VM in your cloud account. | An Edge for the workstation's provider and region, in the workstation's namespace. |
| vz on a Mac, qemu on Linux, hcs on Windows | In the workstation's own network process on your computer, or on an edge VM when the namespace declares an Edge for the provider. | No Edge. |

## Keys on local workstations

On a local workstation the key is held on the computer that runs it, so whoever uses that computer
could read it. A rule's `allowDaemonPlacement` is a gate that says which local workstations may
hold its key:

- Unset, the default, opens the gate only on a workstation owned by the Integration's author, the
  person who first applied it. The author can already read the Secret.
- `true` opens the gate on every local workstation the Integration reaches, whoever owns it. Set
  it only when the people who own those workstations may be trusted with the key.
- `false` closes the gate on every local workstation, the author's own included. On your own
  workstation, removing the `false` is enough.

A rule that uses each workstation owner's own GitHub connection needs none of this. When the
Integration names a
[credential provider](https://docs-stg.ringleader.dev/reference/resources/credentialprovider/#the-credential-source)
with `userAuthorization: boxOwner`, each workstation gets its own owner's token, never the
author's. Its gate is open on every qemu, vz or hcs workstation the Integration reaches, whoever
owns it. A provider that hands out the app's token keeps the unset default above.

The field has no effect on a cloud workstation.

When a closed gate keeps a rule's key off a local workstation, the Integration still reaches the
workstation. Requests to the rule's host go out without the key. The workstation reports this
on its `EgressEnforced` condition, and [Check what is being injected](#check-what-is-being-injected)
shows where to read it.

Ringleader adds the key from a
[Ringleader-only Secret](https://docs-stg.ringleader.dev/security/credentials/secret-handling/#ringleader-only-secrets)
on a local workstation only when all of these hold:

- The workstation is [node-bound](https://docs-stg.ringleader.dev/workstations/basics/#node-bound-workstations)
  and runs on vz, qemu or hcs.
- The person who owns the workstation also owns the Secret. `rl secret access <name>` shows the
  Secret's owner.
- The rule's `allowDaemonPlacement` gate is open for the workstation.
- The Integration's author and the workstation's owner both have `access` to the Secret.

It adds that key on your computer the same way as an ordinary key, and nothing on the workstation
can read it.

Every other local workstation sends requests to the rule's host without the key. That includes one
stored only on your computer. It also includes one owned by anyone other than the Secret's owner,
even when that person has `access` to the Secret or the rule sets `allowDaemonPlacement: true`.

On a node-bound workstation, the host's reason says which condition failed.
`DaemonPlacementNotAllowed` is a closed gate, and `AccessDenied` or `OwnerAccessDenied` is missing
access, as for any key. `RingleaderOnly` means the workstation's provider or owner does not qualify.
[Inject a key on a local workstation](#inject-a-key-on-a-local-workstation) lists older
workstations that get no key, such as one created before its provider gave each workstation its own
address. That holds for a Ringleader-only key too.

## Inject a key on a cloud workstation

This example gives the workstations labeled `team: platform` authenticated access to GitHub.

1. Store the key in a Secret:

   ```bash
   rl secret create github-pat -n acme --from-string token=<your-token>
   ```

2. Make sure the namespace has an Edge for the workstation's cloud and region. An Edge is a small
   VM in your cloud account, and it is where the key is added. A namespace administrator declares
   it once for every workstation in that region and applies it with `rl apply -f edge.yaml`.
   [Declare an Edge](https://docs-stg.ringleader.dev/security/outbound/edge-management/#declare-an-edge) shows the file
   for each cloud.

3. Apply the GitHub preset with the Secret:

   ```yaml
   apiVersion: workstations.ringleader.dev/v1
   kind: Integration
   metadata:
     name: github
     namespace: acme
   spec:
     type: httpProxy
     selector:
       matchLabels:
         team: platform
     httpProxy:
       vendor: github
       credentialRef:
         name: github-pat
         key: token
   ```

   The preset adds the token to `github.com`, `api.github.com`, and
   `raw.githubusercontent.com`. Git over HTTPS uses GitHub's Basic authentication form.
   The API and raw-content hosts use Bearer authentication. The token stays at the Edge,
   not in the workstation configuration.

   To configure the GitHub CLI for the same route, add this under `httpProxy`:

   ```yaml
       toolconfigs:
         - name: gh
   ```

   Ringleader writes `gh` a placeholder token and uses HTTPS. The Edge adds the real token
   when `gh` sends a request.

   If a client cannot trust the interception certificate for a generated host,
   [exclude that host](https://docs-stg.ringleader.dev/security/credentials/host-inspection-exclusion/#exclude-a-host-from-decryption).

   An Integration you apply as a member reaches only your own workstations. For it to reach
   everyone's workstations with the label, a namespace administrator applies it.

4. Give the workstation the label, in its YAML:

   ```yaml
   metadata:
     labels:
       team: platform
   ```

5. Wait until `rl workstation describe <name>` shows the `EgressEnforced` condition as
   `True`. For a workstation with no egress policy the reason is `CredentialOnly`. Then,
   from a shell on the workstation, call the API with no key:

   ```bash
   curl https://api.github.com/user
   ```

   The response is your GitHub user, not a `401`.

If that is all you need, you are done. The sections below cover local workstations, other
headers, rotating a key, and how to check what is being injected.

## Inject a key on a local workstation

On vz, qemu and hcs, only the Integration is needed. The workstation's own network process adds the key, so you declare no Edge and no VM is built. A Mac with Apple Silicon and macOS 13 or later runs vz. The default is qemu on Linux, and hcs on Windows. On a Mac that can run
vz, a workstation that names no provider runs on vz, so it needs nothing more.

This Integration reaches the workstations you own that carry the label `project: billing`, and
injects your own key into them. Its rule leaves `allowDaemonPlacement` unset, because you own every
workstation it reaches:

1. Store the key in a Secret:

   ```bash
   rl secret create my-github-pat -n acme --from-string token=<your-token>
   ```

2. Apply the Integration:

   ```yaml
   apiVersion: workstations.ringleader.dev/v1
   kind: Integration
   metadata:
     name: my-github-api
     namespace: acme
   spec:
     type: httpProxy
     selector:
       ownerScope: true
       matchLabels:
         project: billing
     httpProxy:
       rules:
         - host: api.github.com
           inject:
             header: Authorization
             value: "Bearer ${secret:my-github-pat/token}"
   ```

3. Put the label in the `metadata.labels` of each workstation that should get the key. With no
   `matchLabels`, the Integration reaches every workstation you own in the namespace. In the
   `local` namespace that includes the
   [local runtime](https://docs-stg.ringleader.dev/workstations/configuration/configuration-layers/#layers-and-the-local-runtime), the workstation
   that runs Docker on your computer.

4. Wait for the key to be added. Until the network process serves the workstation, it reports
   `EgressEnforced` `False` with reason `GatewayNotServing`. The message says whether it
   reaches nothing or is still on the open network. It then reports `True`, with reason
   `CredentialOnly` when it has no egress policy.

A local workstation created before its provider gave each workstation its own address gets no key.
On qemu, so does one created before Ringleader could set up the network cards its network process
needs. With no Edge for the provider, such a workstation reports `EgressEnforced` `False` with
reason `NoEdge`, and it cannot sit behind an edge VM either. Delete it and create it again.

To add the key on an edge VM instead, a namespace administrator declares an Edge for the provider.
It takes no region and no size, and in your own personal namespace you are its administrator.
[Network processes and edge VMs](https://docs-stg.ringleader.dev/security/outbound/enforcement/#network-processes-and-edge-vms)
says what an edge VM changes. [qemu network cards](https://docs-stg.ringleader.dev/security/outbound/enforcement/#qemu-network-cards)
says which qemu workstations restart when a credential arrives. The
[Edge](https://docs-stg.ringleader.dev/reference/resources/edge/) reference says how to declare one.

## Inject an API key into a header

This example sets a custom header for an internal API:

1. Store the key in a Secret:

   ```bash
   rl secret create internal-api -n acme --from-string key=<your-key>
   ```

2. Apply the Integration. Any header name works except `Host`. Text around the Secret reference
   is kept, so a scheme prefix such as `Bearer ` goes in the value:

   ```yaml
   apiVersion: workstations.ringleader.dev/v1
   kind: Integration
   metadata:
     name: internal-api
     namespace: acme
   spec:
     type: httpProxy
     selector:
       matchLabels:
         team: platform
     httpProxy:
       rules:
         - host: api.internal.example.com
           inject:
             header: X-API-Key
             value: "${secret:internal-api/key}"
   ```

3. Check that the host reads `Injecting`, as
   [Check what is being injected](#check-what-is-being-injected) shows.

To inject the key of an MCP server, see
[Register an MCP server with the key kept off the workstation](https://docs-stg.ringleader.dev/workstations/coding-agents/mcp-servers/#register-an-mcp-server-with-the-key-kept-off-the-workstation).

## Inject a key for a service that takes Basic authentication

HTTP Basic authentication sends a user name and a password joined by a colon, encoded in
base64. Put that text inside `${base64:…}`. Ringleader fills in the Secret, then encodes the
whole text, so the Secret holds the token alone:

1. Store the token in a Secret:

   ```bash
   rl secret create git-token -n acme --from-string token=<your-token>
   ```

2. Apply the Integration:

   ```yaml
   apiVersion: workstations.ringleader.dev/v1
   kind: Integration
   metadata:
     name: git-basic
     namespace: acme
   spec:
     type: httpProxy
     selector:
       matchLabels:
         team: platform
     httpProxy:
       rules:
         - host: git.example.com
           inject:
             header: Authorization
             value: "Basic ${base64:ci-bot:${secret:git-token/token}}"
   ```

3. Check that the host reads `Injecting`, as
   [Check what is being injected](#check-what-is-being-injected) shows.

A value takes one `${base64:…}`. It holds plain text and at most the value's one Secret
reference, and nothing else in `${…}` form. An MCP server's `mcp.inject.value` accepts it too.
Where the key appears in a response, the encoded text is replaced by the `${base64:…}` text
from your rule.

Encoding makes the value about a third longer, and the 8192-character limit is checked twice.
When you apply the Integration, Ringleader checks the value as you wrote it. When a request
leaves the workstation, it checks the value again with the key filled in and encoded. A value
that fits as written but not once encoded applies with no error and is then never added: each
connection to the host is closed before any request is sent, and
[`rl workstation egress <name>`](https://docs-stg.ringleader.dev/reference/cli/commands/workstation-access/#rl-workstation-egress-workstation)
lists those connections with the reason `terminate-failed`.

## Rotate a key

1. Change the value in the Secret, as
   [Rotate a Secret](https://docs-stg.ringleader.dev/security/credentials/secret-handling/#rotate-a-secret) shows.
2. Run `rl workstation wait <name> --for=EgressApplied` for a workstation that uses the key, as
   [Check what is being injected](#check-what-is-being-injected) explains.

New connections use the new key once the Edge that serves the workstation has it. A connection
that is already open keeps the old key until it closes.

A network process that serves a local workstation gets a change to an Integration, a Secret or an
egress policy within five seconds. Ringleader also rereads everything every two minutes, as a
backstop. When the change removes or withholds a host's key, the open
connections to that host close. That includes deleting the key, or leaving its Secret missing or
empty. Rotating a key does not close them.

A cloud Edge and a local edge VM pick up changes on their own schedules, so neither has a
five-second limit. Removing someone's access through a role reaches a local workstation within a
few minutes.

## Check what is being injected

The Integration reports what each edge instance and edge VM is doing with its rules. To read it:

1. Run `rl integration describe <name> -n <namespace>` and read the **Credential injection**
   section. A host being injected reads:

   ```text
     Credential injection:
       Injecting: api.github.com (Integration github-api)
   ```

   A host that is not being injected reads, for example:

   ```text
     Credential injection:
       Not injecting: api.internal.example.com (Integration internal-api): the Secret internal-api does not exist, or has no such key
   ```

2. For a host that is not being injected, find its `reason` in `status.injection.outcomes`, which
   has one entry per host. [Reasons a host is not injected](https://docs-stg.ringleader.dev/reference/resources/integration/#reasons-a-host-is-not-injected)
   says what to do about each. A host with an `inspect: true` rule is not listed. When a key is
   not being added, the request still goes to the API without it, so the API's own answer is
   usually a `401`.
3. Run `rl workstation describe <name>` to see the `EgressEnforced` condition.
   [Conditions on the workstation](https://docs-stg.ringleader.dev/reference/resources/integration/#conditions-on-the-workstation)
   says what it reads for each provider.
4. After changing an Integration, Secret or egress policy, run
   `rl workstation wait <name> --for=EgressApplied`. `Applied` means that whatever serves the
   workstation holds the resulting rules and keys: its own network process, an edge VM or a cloud Edge.
   `InputsOutstanding` means it does not yet.

The `wait` command compares what was confirmed with the Integrations, Secrets and egress policy as they
are now, so it does not return on an `Applied` from before your change. A change to a Grant, a role or
an owner counts too, when it changes whether a key is added.

## Next steps

- [Host inspection and exclusion](https://docs-stg.ringleader.dev/security/credentials/host-inspection-exclusion/) checks a
  host's requests without adding a key, or keeps a host from being decrypted.
- [Effects of injection on a workstation](https://docs-stg.ringleader.dev/security/credentials/injection-effects/)
  says what a workstation does differently once a key is added to its requests.
- [Create a Secret](https://docs-stg.ringleader.dev/security/credentials/secret-handling/#create-a-secret) stores the key,
  and says who must be able to read it.
- [Lock down Claude Code for unattended runs](https://docs-stg.ringleader.dev/guides/lock-down-claude-code/)
  keeps the GitHub token and the model key off a workstation that runs Claude Code with nobody
  watching.
- [Run your own coding agent in Ringleader](https://docs-stg.ringleader.dev/guides/run-own-coding-agent/)
  keeps the key of any other agent off the workstation.
- [Injection fields](https://docs-stg.ringleader.dev/reference/resources/integration/#injection-fields) lists the rule fields and
  the reasons a host is not injected.
- [CredentialProvider](https://docs-stg.ringleader.dev/reference/resources/credentialprovider/) injects a short-lived
  token that Ringleader gets and renews, in place of a key in a Secret.
- [Use several GitHub identities on one workstation](https://docs-stg.ringleader.dev/guides/use-several-github-identities/)
  gives one workstation two GitHub tokens and chooses which one each request uses.

