# Restricted cloud identities

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


> A CloudIdentity that sets requireUse builds workstations only for owners who hold the use right on it.


A CloudIdentity that sets `requireUse: true` builds workstations only for owners who hold the `use`
right on it. Without it, any workstation in the namespace whose labels match the identity may use it.
Use `requireUse` to limit an identity to the people you choose, such as a production account that only
release engineers should build workstations in.

## The use right

A workstation uses a restricted identity only if the workstation's **owner** holds the `use` right on it.
Who last edited the workstation does not matter. The owner holds the right in one of two ways:

- A role grants them the `use` verb on `cloudidentities` in the namespace. That covers every identity in
  the namespace that sets `requireUse`. Of the
  [built-in roles](https://docs-stg.ringleader.dev/reference/resources/roles/#built-in-roles),
  only `global-admin` holds it, so a global administrator has to bind it first.
- A Grant with `rights: [use]` targets the CloudIdentity by name or by label. Only someone who holds the
  `use` verb can write one, and a Grant that a namespace member writes on a CloudIdentity is refused.

## Restricted and open identities together

When several identities match a workstation, Ringleader skips the ones its owner may not use. The
highest-priority identity left wins. One namespace can therefore hold an open identity at a low
priority and a restricted one at a high priority. Owners with the right get the restricted identity,
and everyone else gets the open one.

An identity without `requireUse` is open to every workstation it matches. An
[Edge](https://docs-stg.ringleader.dev/reference/resources/edge/) has no owner to hold the `use` right, so it never selects an
identity that sets `requireUse`. The one exception is deleting an Edge. The delete may still use the identity the Edge's VM was
built under, so setting `requireUse` later cannot strand the VM.

## Refusal by a restricted identity

If the owner may use none of the matching identities, the workstation does not start. Its status names
the identity it was refused and asks for the `use` right. Ringleader does not fall back to any other
identity.

Deleting a workstation still works after its owner loses the right, because the delete may use the
identity the workstation was built under. If the delete needs another identity that the owner may not
use, it is held. The workstation's status then names three ways out:

- Grant the owner `use`.
- Remove `requireUse` from the identity.
- Delete the workstation in your cloud account, and ask an administrator to release the workstation's
  finalizer.

## Restrict an identity to chosen people

Set `requireUse: true` on the CloudIdentity:

```yaml
apiVersion: core.ringleader.dev/v1
kind: CloudIdentity
metadata:
  name: prod-azure
  namespace: platform
  labels:
    tier: prod
spec:
  provider: azure
  priority: 100
  cloudAccountRef: acme-prod
  requireUse: true
```

Only owners who hold the `use` right can then use `prod-azure`.

## Grant the use right

A role binding covers every restricted identity in the namespace. To cover chosen identities and people
only, write a Grant. This Grant lets two people use every CloudIdentity in `platform` that carries the
label `tier: prod`, which includes `prod-azure`:

```yaml
apiVersion: core.ringleader.dev/v1
kind: Grant
metadata:
  name: prod-azure-users
  namespace: platform
spec:
  target:
    kind: CloudIdentity
    matchLabels:
      tier: prod
  subjects: ["user:alice@acme.com", "user:carol@acme.com"]
  rights: [use]
```

The [Grant](https://docs-stg.ringleader.dev/reference/resources/grant/) reference lists the fields of a Grant.

## Next steps

- [Identity selection and workstation defaults](https://docs-stg.ringleader.dev/cloud-accounts/cloud-identities/selection-defaults/):
  how Ringleader picks among the identities that match.
- [Roles and grants](https://docs-stg.ringleader.dev/organizations-teams/accounts-access/roles-grants/):
  the built-in roles and how a role reaches a person.

