# Roles and grants

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


> Ownership, roles and Grants decide who can see, change, connect to and read what is in a namespace.


Ringleader's access model has three layers. Namespaces are the tenancy boundary, ownership lets you control what you create, and Grants open specific objects to specific people. Roles decide which verbs you hold in a namespace, ownership narrows the write verbs to your own objects, and Grants widen access to chosen peers.

The fields of a Grant are in the [Grant](https://docs-stg.ringleader.dev/reference/resources/grant/#grant-spec) reference. The built-in roles, the reach of each kind of role binding and the rules of a custom organization role are in [Roles and RoleBindings](https://docs-stg.ringleader.dev/reference/resources/roles/).

## Ownership

`Workstation`, `Secret`, `WorkstationConfig`, [`ConfigMap`](https://docs-stg.ringleader.dev/reference/resources/configmap/), `Grant`, `ServiceAccount`, [`Integration`](https://docs-stg.ringleader.dev/reference/resources/integration/), [`WorkstationPool`](https://docs-stg.ringleader.dev/reference/resources/workstationpool/) and `WorkstationPoolLease` are owner-scoped personal kinds. Like a Unix file, you own what you create. On every write, Ringleader stamps the owner from your verified identity, and a client cannot forge it. For a `namespace-member`, that has these consequences:

- You may create, update and delete your own objects of those kinds.
- Peers may `get` and `list` them, because reads are open within the namespace. They cannot update or delete them.
- A `Secret` is the exception, in the stricter direction. Every read returns its redacted projection, yours included. Seeing the values takes `--reveal`, which needs ownership, the `access` verb or a Grant.
- Owning something does not stop a peer from referencing what they can already read. A workstation that names a `WorkstationConfig` in `spec.configs`, or a `scripts` or `files` entry that names a `ConfigMap`, gets those bytes whoever wrote them.
- Where a configuration applies by selector rather than by name, ownership decides reach. One an admin wrote applies to every matching workstation in the namespace. One a member wrote applies only to workstations that member owns, and stops applying to a workstation they lose. An admin who loses their admin rights does not stop: their configuration narrows to the workstations they own, like any member's. A member's `ConfigMap` likewise supplies content to a selector-applied configuration only where that member wrote the configuration.
- A `ServiceAccount` is an identity rather than something a workstation consumes, so it has a rule of its own. [Suspension](https://docs-stg.ringleader.dev/organizations-teams/policies-identities/service-accounts-ci/#suspension) says when it stops working.

A `namespace-admin` is not restricted by ownership. That covers your personal namespace and the admins of a shared one. They manage every object in the namespace, whoever created it.

Either way, you can read your teammates' resources but cannot modify or delete them. As a `namespace-member` you fully control your own. As a `namespace-reader` you create nothing in the namespace except your own device-local SSH keys and port-forward bindings, and never a workstation, Secret or configuration.

## Organization administrators

`org-admin` is a built-in role that an `OrgRoleBinding` binds to a subject for one organization. It is the root of its organization and nothing more. One binding makes someone an administrator of every namespace of the organization, including ones created later, so there is no setup to maintain per namespace.

An `org-admin` may:

- **Create and manage the organization's namespaces.** Their `spec.org` must be the administrator's own organization, which makes the boundary structural rather than a convention.
- **Administer membership across every namespace of the organization.** They bind and unbind users to `namespace-reader`, `namespace-member` or `namespace-admin`.
- **Write organization-scoped roles** (`OrgRole` and `OrgRoleBinding`), bounded by the escalation guard: every rule they grant must be one they already hold.
- **Write the organization's [CloudAccounts](https://docs-stg.ringleader.dev/reference/resources/cloudaccount/)**, which say which cloud identity to use for cloud federation.
- **Write the organization's policies (`OrgPolicy`)**, which say what a workstation file may name anywhere in the organization. A namespace's own policies can narrow that, and cannot widen it. [Policy and OrgPolicy](https://docs-stg.ringleader.dev/reference/resources/policy/) has the fields.
- **List the organization's members** with `rl user get`. The list is limited to their own organization. A normal member gets a `403`, and another organization's users are invisible, not merely filtered.

An `org-admin` may not grant themselves more than they hold, write global roles, or reach any other organization. They are not a wildcard.

## The access verb

Reading a Secret's values, not just its redacted projection, is gated by a distinct `access` verb. It is the same verb that admits objects which consume the Secret. [Places that name a Secret](https://docs-stg.ringleader.dev/reference/resources/secret/#places-that-name-a-secret) lists the fields that consume one, including an Integration's `credentialRef`, `inject.value` and `mcp.credentialRef`. You hold `access` on your own Secrets automatically, and a Grant with `rights: [access]` extends it to a peer. To read a Secret's values, run `rl secret get db --reveal`, which requires the access right.

## Grants

A Grant is a namespaced object that opens an object to specific subjects. It is the only way a peer gains one of these:

- **SSH access** to a workstation you own (`rights: [ssh]`).
- **Value access** to a Secret you own (`rights: [access]`).
- **The right to lease** a workstation from a [pool](https://docs-stg.ringleader.dev/reference/resources/workstationpool/) you own (`rights: [lease]`).
- **The right to place one workstation**, which is to set the [`providerConfig` keys a member may not set](https://docs-stg.ringleader.dev/reference/providers/images-keys/#keys-a-namespace-member-may-set). Only an admin can grant it (`rights: [cloudconfig]`).
- **The right to build workstations through a [Restricted cloud identities](https://docs-stg.ringleader.dev/cloud-accounts/cloud-identities/restricted-identities/) that sets `requireUse`** (`rights: [use]`). Only someone who holds the `use` verb can grant it.

There is no namespace-wide SSH fan-out. SSH to a workstation is ownership, which is automatic, plus Grants, which are explicit. A `lease` Grant opens the pool, never its members, because a member is reached through the lease that holds it. [Access for a lease holder](https://docs-stg.ringleader.dev/workstations/lifecycle/pools-leases/#access-for-a-lease-holder) says what the right lets a holder do.

No Grant reaches a [node-bound workstation](https://docs-stg.ringleader.dev/workstations/basics/#node-bound-workstations), which runs on its owner's computer where no other device can reach it. A Grant that names one is refused, and a Grant that selects by label or `*` leaves it out.

Create and revoke Grants with the `share` and `unshare` commands rather than writing them by hand. [Workstation and Secret sharing](https://docs-stg.ringleader.dev/organizations-teams/accounts-access/workstation-secret-sharing/) shows how.

### Grant scope

Every Grant carries a scope. Ringleader sets it from the rights you held when you created the Grant, and never trusts it from the client:

- **`owner`:** created by `share` and `unshare`. It reaches your own objects and those of any service account you own in the namespace, only while you still own them or the account. A Grant can therefore never hand out more than you could yourself. If the account gets a new owner or is deleted, the Grant stops reaching its objects.
- **`admin`:** created with `--admin`, which needs namespace-admin rights. For SSH it reaches any workstation in the namespace. For every other right it reaches your own objects and those owned by any service account in the namespace, and never an object a teammate owns. An admin can share a service account's Secrets and pools. An admin-scope Grant on a teammate's Secret does nothing, because an admin has no authority over a teammate's plaintext. The same holds for a teammate's pool.

[Secret sharing](https://docs-stg.ringleader.dev/security/credentials/secret-handling/#secret-sharing) says what an admin-scope Grant on a teammate's Secret does, and which shapes of Grant are refused or accepted.

Two rights have no owner scope, `cloudconfig` and `use`, and a member's Grant of either is refused. [The cloudconfig Grant](https://docs-stg.ringleader.dev/cloud-accounts/cloud-identities/placement-delegation/#the-cloudconfig-grant) shows how an admin writes one.

Ringleader checks that a Grant never grants more than its creator could grant directly each time it decides access. An owner-scope Grant stops applying once you no longer own its target, or no longer own the service account that owns it. An admin-scope Grant does not depend on your rights today. It keeps applying after you lose your admin rights, to any workstation for SSH, and to service accounts' objects for every other right.

## Give someone a role

Give someone a role in one namespace when you are a `namespace-admin` or an `org-admin`. A new member's first role comes from the organization's default. You need this to move someone between roles or to put them in another team's namespace.

1. Write a `RoleBinding` in the namespace, naming the person and a built-in role, as [Example: a RoleBinding](https://docs-stg.ringleader.dev/reference/resources/roles/#example-a-rolebinding) shows. The [built-in roles](https://docs-stg.ringleader.dev/reference/resources/roles/#built-in-roles) are listed in the reference.
2. Save the file as `bob-team-a.yaml` and run `rl apply -f bob-team-a.yaml`.

To make someone an administrator of every namespace of the organization, write an `OrgRoleBinding` instead, as [Example: an OrgRoleBinding](https://docs-stg.ringleader.dev/reference/resources/roles/#example-an-orgrolebinding) shows.

## Create a custom organization role

Create a custom role when the built-in roles give a person or a service account too much or too little. You must be an `org-admin`, and you can only grant rules you already hold.

1. Write an `OrgRole` and an `OrgRoleBinding` that binds it, as [Example: a custom OrgRole](https://docs-stg.ringleader.dev/reference/resources/roles/#example-a-custom-orgrole) shows. Each rule names API groups, resources and verbs, as [Custom organization roles](https://docs-stg.ringleader.dev/reference/resources/roles/#custom-organization-roles) explains.
2. Save the file as `ci-bot.yaml` and run `rl apply -f ci-bot.yaml`.

## Next steps

- [Workstation and Secret sharing](https://docs-stg.ringleader.dev/organizations-teams/accounts-access/workstation-secret-sharing/): open a workstation or a Secret to a teammate with a Grant.
- [Organizations and domains](https://docs-stg.ringleader.dev/organizations-teams/accounts-access/organizations-domains/): how people get their first role.
- [Roles and RoleBindings](https://docs-stg.ringleader.dev/reference/resources/roles/): the built-in roles, how far a binding reaches and the rules of a custom role.
- [Grant](https://docs-stg.ringleader.dev/reference/resources/grant/): the fields of a Grant, and the `cloudconfig` right.
- [ServiceAccount and IdentityProvider](https://docs-stg.ringleader.dev/reference/resources/serviceaccount/): the non-human identities you bind these same roles to.

