# Access control

How Teleport roles decide what users, beams and agents can access, with links to the full Teleport RBAC reference.

Teleport Beams uses Teleport role-based access control (RBAC). It doesn't add a separate permission system. Every user, beam and agent signs in with a Teleport identity that holds roles. Teleport checks those roles on every SSH session, app and MCP request, database connection and GitHub operation.

This page covers the parts of Teleport roles that the Beams guides use. For every other field, see the [Teleport role reference](https://goteleport.com/docs/reference/access-controls/roles/).



## How roles work

A role is a Teleport resource with `allow` and `deny` conditions and a set of `options`:

```yaml
kind: role
version: v8
metadata:
  name: example-agent
spec:
  allow:
    # Which resources the role covers, matched by their labels
    app_labels:
      env: staging
    # Which Teleport resources the role can read or change
    rules:
      - resources: [beam]
        verbs: [list, read]
  deny:
    app_labels:
      team: payments
  options:
    max_session_ttl: 8h
```

An identity's access is the union of the `allow` conditions in all its roles, minus anything a `deny` condition in any role matches. A deny always wins. Some options restrict the whole identity no matter which role sets them. For example, any one role can turn off SSH file copying.

To view, create and assign roles, use `tctl` from a terminal signed in as an administrator. `tctl users update --set-roles` replaces the user's whole role list, so include the roles the user already has:

**Admin terminal**

```sh
tctl get roles/beam-user
tctl create -f example-agent.yaml
tctl get users/alice@example.com --format=json | jq -r '.[0].spec.roles | join(",")'
tctl users update alice@example.com --set-roles=access,beam-user,example-agent
```

New roles take effect after the user signs in again. If you use SSO, map roles from your identity provider instead of assigning them to users. See [Teleport RBAC](https://goteleport.com/docs/zero-trust-access/rbac-get-started/).

## Choose resources with labels

Each kind of resource has its own label field. A role covers a resource when the resource's labels match. Multiple labels in one field must all match, and a list of values matches any one of them:

| Field | What it covers | Used in |
| --- | --- | --- |
| `app_labels` | HTTP and TCP apps, MCP servers and LLM endpoints | [Internal services](/docs/mcp/internal-services/), [OAuth](/docs/mcp/oauth/), [BYOI](/docs/llm/byoi/) |
| `db_labels` | Databases | [PostgreSQL](/docs/guides/postgres/), [Databases](/docs/mcp/databases/) |
| `node_labels` | SSH servers, including beams | [Preset roles](#preset-roles-and-beam-ownership) |
| `beam_labels` | Beams, for `tsh beams` commands | [Preset roles](#preset-roles-and-beam-ownership) |

Some resources also need the principal to use on them:

- `logins`: the Linux users you can SSH in as. Beams use the `beams` login.
- `db_users` and `db_names`: the database users and database names you can connect with.
- `github_permissions`: the GitHub organizations you can use through Teleport, as in [GitHub](/docs/connectivity/github/).

For example, this role allows only the demo database, only as `readonly`, plus your cluster's LLM endpoints:

```yaml
kind: role
version: v8
metadata:
  name: read-only-demo-postgres
spec:
  allow:
    db_labels:
      service: beams-postgres
    db_users: [readonly]
    db_names: [postgres]
    app_labels:
      teleport.internal/beams/app-type: llm
```

A label value of `'*'` matches any value, and `'*': '*'` matches every resource of that kind. Use wildcards only for roles you give to trusted people, not to agents.

When one label match isn't enough, use the `_labels_expression` form of the field, such as `app_labels_expression`. It accepts a predicate expression that can combine conditions with `||` and `&&` and compare labels with the user's name or traits:

```yaml
app_labels_expression: |
  labels["teleport.internal/beams/app-type"] == "llm" ||
  labels["env"] == "staging"
```

See [extended label matching](https://goteleport.com/docs/reference/access-controls/roles/#extended-label-matching-syntax) and [label expressions](https://goteleport.com/docs/reference/access-controls/roles/#label-expressions) in the reference.

## Limit MCP tools

`app_labels` decides which MCP servers a role reaches. `mcp.tools` decides which tools on those servers it can call. Teleport hides other tools from the tool list and rejects calls to them:

```yaml
kind: role
version: v8
metadata:
  name: mcp-demo-limited
spec:
  allow:
    app_labels:
      teleport.internal/app-sub-kind: mcp
    mcp:
      tools: [teleport_user_info]
```

Tool names are case-sensitive. Entries can be exact names, globs such as `teleport_*`, or regular expressions that start with `^` and end with `$`. A role with no `mcp.tools` allows no tools. The preset `mcp-user` role allows `"*"`. Use `deny.mcp.tools` to block specific tools even when another role allows them. See [Limit the tools](/docs/mcp/internal-services/#limit-the-tools).

## Manage Teleport resources with rules

`rules` grant verbs on Teleport's own resources, such as beams, phases and join tokens. The verbs are `list`, `read`, `create`, `update`, `delete` and `"*"` for all of them.

These are the resources the Beams guides use:

| Resource | Used for |
| --- | --- |
| `beam`, `phase` | Creating and managing beams and phases |
| `token` | Letting a phase create the join token for its own Teleport service, as in [Internal services](/docs/mcp/internal-services/) |
| `database_certificate` | Letting a database beam sign its database server certificate, as in [PostgreSQL](/docs/guides/postgres/) |
| `session` | Reading session and audit records |

A rule can add a `where` clause that narrows which items it covers. The preset `beam-user` role uses one to show users only their own ended beams:

```yaml
rules:
  - resources: [session]
    verbs: [list, read]
    where: equals(session.event, "beam.destroyed") && equals(session.user, user.metadata.name)
```

**Warning**

**Token rules are privileged.** A role that can create join tokens can enroll new Teleport services. Delegate it only to the beam that runs that service, and never to a general-purpose agent beam.

See [RBAC for dynamic Teleport resources](https://goteleport.com/docs/reference/access-controls/roles/#rbac-for-dynamic-teleport-resources) for every resource and verb.

## Use traits in roles

Role templates fill in values from the user's traits when Teleport checks access. The Beams guides mostly use fixed values. The preset `access` role uses templates for principals:

```yaml
logins: ["{{internal.logins}}"]
db_users: ["{{internal.db_users}}"]
db_names: ["{{internal.db_names}}"]
```

If a user has no `db_users` trait, `access` grants no database users, even when the database labels match. That's why the database guides use a role with fixed `db_users` and `db_names`. In label expressions, `user.metadata.name` is the user's name and `user.spec.traits["name"]` is a trait.

For external traits from your identity provider and template functions, see [Role templates](https://goteleport.com/docs/reference/access-controls/roles/#role-templates).

## Preset roles and beam ownership

Clusters with Teleport Beams enabled include these roles:

| Role | Who has it | What it allows |
| --- | --- | --- |
| `beam-user` | Every user | Create and manage your own beams and phases, SSH into them as `beams`, use your LLM endpoints and delegate roles to beams |
| `beam-admin` | Administrators | See and manage everyone's beams and the Beams configuration |
| `beam` | Each beam's host | Get its host certificate and workload identity. You don't assign this role. |

A beam belongs to the user who created it. Teleport labels the beam's resources with the owner and with the users who delegated access to it. `beam-user` matches those labels against the signed-in user, so only you can see your beams, connect to them and use their published apps. An abridged copy of the preset:

```yaml
kind: role
version: v8
metadata:
  name: beam-user
spec:
  allow:
    logins: [beams]
    beam_labels_expression: |
      labels["teleport.internal/beams/owner"] == user.metadata.name ||
      contains(labels_matching("teleport.internal/beams/delegator/*"), user.metadata.name)
    node_labels_expression: |
      labels["teleport.internal/beams/owner"] == user.metadata.name ||
      contains(labels_matching("teleport.internal/beams/delegator/*"), user.metadata.name)
    app_labels_expression: |
      labels["teleport.internal/beams/app-type"] == "llm" ||
      labels["teleport.internal/beams/owner"] == user.metadata.name ||
      contains(labels_matching("teleport.internal/beams/delegator/*"), user.metadata.name)
    delegation:
      roles: ["*"]
    rules:
      - resources: [beam]
        verbs: ["*"]
      - resources: [phase]
        verbs: ["*"]
```

To see the full preset on your cluster, run `tctl get roles/beam-user`. Don't edit preset roles; create your own roles alongside them.

## Delegate roles to beams

A beam signs in with its own Teleport identity. That identity holds only the roles you choose when you create the beam, and only roles you have yourself:

**Local terminal**

```sh
tsh beams add --roles=beam-user,read-only-demo-postgres
```

Inside the beam, `tsh status` shows the roles and the delegation chain back to you:

**Inside the beam**

```sh
tsh status
```

`delegation.roles` on your own roles decides which roles you can delegate. The preset `beam-user` allows `"*"`, so you can delegate any role you hold. Add a `deny` rule to keep sensitive roles out of beams:

```yaml
kind: role
version: v8
metadata:
  name: no-admin-delegation
spec:
  deny:
    delegation:
      roles: [editor, auditor]
```

Give agents small task roles, like the ones in the guides, rather than your full role set. See [Delegation](/docs/identity/delegation/) for the full walkthrough.

## Request access to resources

An agent that needs more than its standing roles can request access to a single resource, instead of being given a broader role. Two role fields control this:

- `request.search_as_roles` lists the roles Teleport uses to search for requestable resources with `tsh request search`. A search result means the identity can ask for the resource, not that it can use it.
- `review_requests.roles` lists the roles a reviewer can approve requests for.

```yaml
kind: role
version: v8
metadata:
  name: staging-requester
spec:
  allow:
    request:
      search_as_roles: [staging-access]
      max_duration: 1h
```

After a reviewer approves a request, the requester gets access to only the requested resources until the request expires. Every cluster includes preset `requester` and `reviewer` roles you can start from.

See [Access requests](/docs/identity/access-requests/) for the walkthrough from a beam. For review thresholds, request reasons and other fields, see [Access Request configuration](https://goteleport.com/docs/identity-governance/access-requests/access-request-configuration/).

## More in the Teleport reference

These topics aren't covered here. See the [Teleport role reference](https://goteleport.com/docs/reference/access-controls/roles/) for:

- [Role options](https://goteleport.com/docs/reference/access-controls/roles/#role-options), such as session TTL, recording and file copy.
- [Preset roles](https://goteleport.com/docs/reference/access-controls/roles/#preset-roles) and [role versions](https://goteleport.com/docs/reference/access-controls/roles/#role-versions).
- [Session recordings](https://goteleport.com/docs/reference/access-controls/roles/#rbac-for-session-recordings) and [active sessions](https://goteleport.com/docs/reference/access-controls/roles/#rbac-for-active-sessions).
- Kubernetes, desktops, cloud provider roles and other resource kinds.
- [The predicate language](https://goteleport.com/docs/reference/access-controls/predicate-language/) used in label expressions and `where` clauses.
