# Secret handling

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


> A Secret stores a key, password or token under a name, so that no YAML you write carries the value.


A Secret stores a key, password or token under a name, so that no YAML you write carries the
value. You store the value once. An Integration, a WorkstationConfig or a workstation then names
the Secret wherever it needs the value. Ringleader hides the value whenever it shows the Secret,
and checks who may use it.

## Read access

[Places that name a Secret](https://docs-stg.ringleader.dev/reference/resources/secret/#places-that-name-a-secret) lists each field that names a Secret and who must be able to read it there.

To read a Secret means one of three things:

- You own it. The person who creates a Secret owns it.
- A Grant gives you the `access` right.
  [`rl secret share <name>`](https://docs-stg.ringleader.dev/reference/cli/commands/shares-access/#rl-secret-share-name) writes one.
- A role you hold has the `access` verb on Secrets. No role below `global-admin` grants it on a
  Secret you do not own, not even a namespace administrator's.

Whoever applies an Integration, or a change to one, must be able to read the Secrets it names.
The Integration's author is the person who first applied it. Ringleader checks access again each
time it reads or delivers a value, so removing someone's access stops the delivery.
When the author loses access, or the Secret is deleted, Ringleader stops adding the key, or
stops delivering it. If someone other than the author changes an Integration to name a new
Secret, the author must be able to read that Secret too.

If a workstation's owner cannot read a Secret that Ringleader would deliver, Ringleader withholds
the value from the workstation. The owner's own stop, start or edit of the workstation can then be
refused. Give the owner access with `rl secret share`.

## Secrets on the workstation

A value that Ringleader delivers to a workstation is readable by every program there. That
includes an AI coding agent told to print it. It also leaves with every copy of the home
directory. To keep a key off the workstation, name it only where Ringleader adds it to a request.
[Injected credentials](https://docs-stg.ringleader.dev/security/credentials/injected-credentials/) shows how for any API, and
[Gateway keys held by Ringleader for Claude Code](https://docs-stg.ringleader.dev/workstations/coding-agents/llm-gateways/#gateway-keys-held-by-ringleader-for-claude-code)
shows it for Claude Code.

## Ringleader-only Secrets

Anyone who can read an ordinary Secret can read its value back with
`rl secret get <name> --reveal`. Nobody can read back the value of a Ringleader-only Secret, its
owner included. You write the value and you can replace it, and Ringleader uses it only to add it
to a request. Use one for a key that no person should be able to copy.

A Ringleader-only Secret differs from an ordinary one in four ways:

- Three places add its value to requests, and no workstation receives it. An edge instance adds it
  to requests from a cloud workstation. The endpoint your deployment runs for an `llm` Integration
  with `source: ringleader` adds it too, as
  [Gateway keys held by Ringleader for Claude Code](https://docs-stg.ringleader.dev/workstations/coding-agents/llm-gateways/#gateway-keys-held-by-ringleader-for-claude-code)
  describes. Your own computer can add it to requests from a
  [node-bound](https://docs-stg.ringleader.dev/workstations/basics/#node-bound-workstations) qemu, vz or hcs
  workstation when you own both the workstation and the Secret. Ringleader holds the value only in
  memory there, outside the workstation. The gate in
  [Keys on local workstations](https://docs-stg.ringleader.dev/security/credentials/injected-credentials/#keys-on-local-workstations)
  and the checks in [Read access](#read-access) still decide whether Ringleader adds the key for
  that workstation. Requests from every other local workstation go out without the key. That
  includes a workstation stored only on your computer, and one another person owns.
- You can name it only in the fields the table above marks as allowed. Naming it anywhere else is
  refused when you apply the object. The message says the field names a Ringleader-only Secret, and
  to name it in an Integration that injects it. A configuration that named the Secret before it was
  recreated as Ringleader-only is not delivered either. The workstation reports the cause
  `ringleader-only-secret`, as
  [Fields that report a problem](https://docs-stg.ringleader.dev/reference/resources/workstation/#fields-that-report-a-problem)
  lists.
- It stays at its home. A Ringleader-only Secret is stored only on the Ringleader that holds its
  namespace, never on your computer, even when your computer adds its value to requests. Create it
  while you are signed in, in a namespace other than `local`. Otherwise `rl` refuses with "a
  Ringleader-only Secret lives only at its namespace's remote origin; log in or use a namespace
  that has one".
- You choose it only when you create the Secret. A change to `ringleaderOnly` on an existing
  Secret is refused, so to change it, delete the Secret and create it again.

## Secret sharing

A Grant with the `access` right lets a person or a group read a Secret's value, and use it in an
object they apply. On a Ringleader-only Secret, the right lets them use the Secret in an
Integration that injects it, and never read the value.

A namespace administrator cannot read or share a Secret that a teammate owns. `--admin` shares
your own Secrets and those owned by a service account in the namespace. Naming a teammate's
existing Secret with `--admin` is refused when you create the Grant.

A `--all` share is accepted. So is a Grant you write by hand that selects by labels, and one that
names a Secret nobody has created yet. Each covers only your own Secrets and those of service
accounts. `rl secret access <name>` shows the owner and every Grant in force.

## Secret storage

Ringleader copies a Secret to every origin of its namespace. The origins are your computer and
the Ringleader that holds the namespace, so each can resolve a reference to it. A Secret in the
reserved `local` namespace stays on your computer. A Ringleader-only Secret is the exception, as
[Ringleader-only Secrets](#ringleader-only-secrets) explains.

## Create a Secret

Run `rl secret create` with the key. This example stores a GitHub token under the key `token`:

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

`--from-string` takes a literal value, and `--from-file <name>=<path>` takes a file's content.
A file that ends in a newline stores the newline as part of the value. Ringleader never sends an
injected value that holds a line break, a tab or another control character. It also never sends
one longer than 8192 characters once the key is filled in. Store a key with `--from-string`, or
check that a file you load has no trailing newline. Until you fix the Secret, each connection to the host is
closed before any request is sent, and `rl workstation egress <name>` lists those connections
with the reason `terminate-failed`.

[Imperative creation commands](https://docs-stg.ringleader.dev/reference/cli/commands/imperative-creation/#rl-secret-create-name) lists every flag.

## Create a Ringleader-only Secret

Add `--ringleader-only` when you create the Secret, while you are signed in to a namespace other
than `local`:

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

`rl secret get github-pat -n acme -o yaml` shows `ringleaderOnly: true` beside the key names.
Adding `--reveal` to `rl secret get` or `rl secret edit` is refused:

```text
Secret acme/github-pat is Ringleader-only; its value is never revealed
```

## Read a Secret's value

Every read shows fingerprints, yours included. To see the values, you must own the Secret or hold
the `access` right on it:

```bash
rl secret get db --reveal
```

## Rotate a Secret

Change a key's value with `rl secret edit <name>`. A Ringleader-only Secret edits the same way and
stays Ringleader-only. To see how a changed key reaches a request that Ringleader
adds, go to
[Rotate a key](https://docs-stg.ringleader.dev/security/credentials/injected-credentials/#rotate-a-key).

## Next steps

- [Injected credentials](https://docs-stg.ringleader.dev/security/credentials/injected-credentials/) adds a key from a Secret to a
  request as it leaves the workstation.
- [Imperative creation commands](https://docs-stg.ringleader.dev/reference/cli/commands/imperative-creation/#rl-secret-create-name) lists every flag of
  `rl secret create`.
- [`rl secret share <name>`](https://docs-stg.ringleader.dev/reference/cli/commands/shares-access/#rl-secret-share-name) gives
  other people access to a Secret.
- [Roles and grants](https://docs-stg.ringleader.dev/organizations-teams/accounts-access/roles-grants/) describes ownership, roles and Grants.
- [Integration](https://docs-stg.ringleader.dev/reference/resources/integration/) lists the fields that name a Secret.

