# Roles and RoleBindings

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


> The built-in roles, the bindings that carry a role to a subject, and the rules of a custom organization role.


A **role** is a set of rules that say which verbs a subject holds on which kinds, and a **binding** carries a role to a subject for one namespace, one organization or everywhere. This page lists the built-in roles, how far each kind of binding reaches and the rules of a custom organization role.

```text
apiVersion: core.ringleader.dev/v1
kind: RoleBinding
```

[Roles and grants](https://docs-stg.ringleader.dev/organizations-teams/accounts-access/roles-grants/) explains ownership, organization administrators and Grants, and shows how to give someone a role. [Grant](https://docs-stg.ringleader.dev/reference/resources/grant/) lists the fields of a Grant.

## Built-in roles

The built-in roles define what a subject may do. Ringleader predefines them, so their meaning is the same everywhere, and you do not write them.

The first four roles form a ladder. Each role contains every role above it in the table, so each row states only what it adds. `node-owner` and `public-info` are not part of the ladder, because every authenticated user holds both, and `global-admin` sits outside it entirely.

| Role | Who gets it | What it adds |
|------|-------------|----------------|
| **`namespace-reader`** | Shared-namespace members, where `Org.spec.defaultMemberRole` selects it | `get`, `list` and `watch` on everything in the namespace, and `create`, `update` and `delete` on your device-local `localbindings` and `sshkeys`. It creates nothing else, in particular no workstation, which on a cloud-backed organization is real spend. |
| **`namespace-member`** | You, in a shared namespace (the default role) | Owner-scoped `create`, `update` and `delete` on `workstations`, `secrets`, `workstationconfigs`, `configmaps`, `grants`, `serviceaccounts`, `integrations`, [`workstationpools`](https://docs-stg.ringleader.dev/reference/resources/workstationpool/) and `workstationpoolleases`, your own only. |
| **`namespace-admin`** | You, in your personal namespace, and the admins of a shared one | The same verbs for any owner, not just your own. They include these kinds of the namespace: `workstations`, `workstationconfigs`, `configmaps`, `secrets`, `grants`, `serviceaccounts`, `integrations`, `workstationpools`, `workstationpoolleases`, `cloudidentities`, [`edges`](https://docs-stg.ringleader.dev/reference/resources/edge/), [`policies`](https://docs-stg.ringleader.dev/reference/resources/policy/), [`storages`](https://docs-stg.ringleader.dev/reference/resources/storage/), `sshkeys`, `localbindings`, and the namespace's own `roles` and `rolebindings`. It is not a blanket wildcard. An admin also holds the `lease` right on every workstation pool in the namespace and the [The cloudconfig Grant](https://docs-stg.ringleader.dev/cloud-accounts/cloud-identities/placement-delegation/#the-cloudconfig-grant) on every workstation. It reads every cloud workstation's [connection records](https://docs-stg.ringleader.dev/security/outbound/connection-records/#record-access) in the namespace, and, through the `usage` verb on `workstations`, every owner's [usage](https://docs-stg.ringleader.dev/reference/cli/commands/usage/). A member reads only their own of either. |
| **`org-admin`** | An organization's administrators | Everything a namespace-admin has, in every namespace of their organization, plus that organization's own structure: its `namespaces`, `orgroles`, `orgrolebindings`, [CloudAccounts](https://docs-stg.ringleader.dev/reference/resources/cloudaccount/), `identityproviders` and `orgpolicies`, plus read-only access to its user roster. It also reads the [usage](https://docs-stg.ringleader.dev/reference/cli/commands/usage/) of the whole organization with `rl usage --org`. Confined to their own organization. Reading the organization and its domains is not one of these, because every authenticated user can read their own, through `public-info`. |
| **`node-owner`** | Every authenticated user | Owner-scoped management of your own device records (`nodeinfos`). |
| **`public-info`** | Every authenticated user | `get`, `list` and `watch` on namespaces, organizations and their domains, and role definitions and organization role bindings, so you can see who administers your organization. The user roster is not included. |
| **`global-admin`** | Ringleader operators (break-glass) | Full access to everything, everywhere. The only role that holds the wildcard. |

Two limits hold for every role below `global-admin`:

- **No built-in role below `global-admin` grants `access` on a Secret it does not own.** An administrator owns a Secret's object lifecycle and can delete it. Reading a plaintext they do not own still needs ownership, a Grant, or a custom role with the `access` verb on `secrets`.
- **No role can escalate itself.** You cannot bind a subject, yourself included, to permissions you do not already hold.

## Reach of a role binding

A role is a set of rules. The binding that carries it decides where it applies:

| Binding | Reaches |
|---|---|
| **`RoleBinding`** (namespaced) | One namespace. |
| **`OrgRoleBinding`** (cluster-scoped, carries `spec.org`) | Every namespace of one [organization](https://docs-stg.ringleader.dev/organizations-teams/accounts-access/organizations-domains/), including ones created later, plus that organization's own structure: its namespaces, organization roles, organization role bindings, organization policies, cloud accounts, identity providers and user roster. |
| **`GlobalRoleBinding`** (cluster-scoped) | Everywhere. Ringleader operators only. |

A binding may reference a built-in `GlobalRole`, a namespaced `Role`, or an organization-scoped `OrgRole`. An `OrgRoleBinding`'s reach over cluster-scoped objects is confined to the organization's own. It can never grant a verb on another organization's objects, or on global roles.

To see what you hold at each origin, run `rl auth status --show-access`.

## Custom organization roles

A custom organization role (`OrgRole`) is a set of rules that an `org-admin` writes for one organization. Each rule names API groups, resources and verbs. A resource is the plural kind name, such as `workstations`. Its API group is the part of the kind's `apiVersion` before the slash: `workstations.ringleader.dev` for a Workstation, `core.ringleader.dev` for a Secret. `"*"` matches any group, resource or verb.

A rule with `ownerScope: true` applies only to objects the subject owns, the way the built-in `namespace-member` role lets you change your own workstations and nobody else's. Both objects carry `spec.org`, and Ringleader accepts the role only because every rule in it is a subset of what its author already holds.

## Example: a RoleBinding

A `RoleBinding` in a namespace binds a person to a built-in role:

```yaml
apiVersion: core.ringleader.dev/v1
kind: RoleBinding
metadata: { name: bob-team-a, namespace: acmecorp-team-a }
spec:
  subjects: ["user:bob@acme.com"]
  roleRef: { kind: GlobalRole, name: namespace-member }
```

## Example: an OrgRoleBinding

An `OrgRoleBinding` makes someone an administrator of every namespace of the organization. Ringleader creates the first one for your organization.

```yaml
apiVersion: core.ringleader.dev/v1
kind: OrgRoleBinding
metadata:
  name: acmecorp-admins
spec:
  org: acmecorp
  subjects: ["user:alice@acme.com"]
  roleRef:
    kind: GlobalRole
    name: org-admin
```

## Example: a custom OrgRole

An `OrgRole` and an `OrgRoleBinding` that binds it:

```yaml
apiVersion: core.ringleader.dev/v1
kind: OrgRole
metadata:
  name: ci-bot
spec:
  org: acmecorp
  rules:
    - apiGroups: ["workstations.ringleader.dev"]
      resources: ["workstations"]
      verbs: ["get", "list", "watch"]
    - apiGroups: ["workstations.ringleader.dev"]
      resources: ["workstations"]
      verbs: ["create", "update", "delete"]
      ownerScope: true
---
apiVersion: core.ringleader.dev/v1
kind: OrgRoleBinding
metadata:
  name: acmecorp-ci
spec:
  org: acmecorp
  subjects: ["sa:acmecorp/ci"]
  roleRef:
    kind: OrgRole
    name: ci-bot
```

With this role, `sa:acmecorp/ci` reads every workstation in the organization, and creates, updates and deletes only the workstations it created.

## Next steps

- [Roles and grants](https://docs-stg.ringleader.dev/organizations-teams/accounts-access/roles-grants/): give someone a role, or write a custom organization 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.

