{"token_count": 12099}

# Run the Discord Access Request Plugin

Identity Governance is available only with Teleport Enterprise.

This guide will explain how to set up Discord to receive Access Request messages from Teleport. Teleport's Discord integration notifies individuals and channels of Access Requests. Users can then approve and deny Access Requests from within Discord, making it easier to implement security best practices without compromising productivity.

![The Discord Access Request plugin](/docs/assets/images/discord-e8b9c1cebdfae5f0d9d17dcebbc88d9f.png)

This integration is hosted on Teleport Cloud

In Teleport Enterprise Cloud, Teleport manages the Discord integration for you, and you can enroll the Discord integration from the Teleport Web UI.

Visit the Teleport Web UI and on the left sidebar, click **Add New** followed by **Integration**:

![Enroll an Access Request plugin](/docs/assets/images/enroll-ee64e35054da594e264c55422bf39c7b.png)

On the "Select Integration Type" menu, click the tile for your integration. You will see a page with instructions to set up the integration, as well as a form that you can use to configure the integration.

## How it works

The Teleport Discord plugin authenticates to your Discord server as well as the Teleport Auth Service, and listens for audit events from the Teleport Auth Service related to Access Requests. When a user creates an Access Request, the plugin sends a message on Discord to reviewers of the request, including a link that each reviewer can follow in order to review the request in the Teleport Web UI. You can configure the reviewers the plugin will notify based on the role targeted by the Access Request.

## Prerequisites

- A running Teleport Enterprise cluster accessible at a hostname with a valid TLS certificate. If you want to get started with Teleport, [sign up](https://goteleport.com/signup) for a free trial or [set up a demo environment](https://goteleport.com/docs/get-started/deploy-community.md).

- The `tctl` and `tsh` clients.

  Installing `tctl` and `tsh` clients

  1. Determine the version of your Teleport cluster. The `tctl` and `tsh` clients must be at most one major version behind your Teleport cluster version. Send a GET request to the Proxy Service at `/v1/webapi/find` and use a JSON query tool to obtain your cluster version. Replace teleport.example.com:443 with the web address of your Teleport Proxy Service:

     **Mac/Linux**

     ```
     $ TELEPORT_DOMAIN=teleport.example.com:443
     $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')"
     ```

     **Windows - Powershell**

     ```
     $ $TELEPORT_DOMAIN = "teleport.example.com:443"
     $ $TELEPORT_VERSION = (Invoke-RestMethod -Uri "https://${TELEPORT_DOMAIN}/v1/webapi/find").server_version
     ```

  2. Follow the instructions for your platform to install `tctl` and `tsh` clients:

     **Mac**

     Download the signed macOS .pkg installer for Teleport, which includes the `tctl` and `tsh` clients:

     ```
     $ curl -O https://cdn.teleport.dev/teleport-${TELEPORT_VERSION?}.pkg
     ```

     In Finder double-click the `pkg` file to begin installation.

     ---

     DANGER

     Using Homebrew to install Teleport is not supported. The Teleport package in Homebrew is not maintained by Teleport and we can't guarantee its reliability or security.

     ---

     **Windows - Powershell**

     ```
     $ curl.exe -O https://cdn.teleport.dev/teleport-v$TELEPORT_VERSION-windows-amd64-bin.zip
     Unzip the archive and move the `tctl` and `tsh` clients to your %PATH%
     NOTE: Do not place the `tctl` and `tsh` clients in the System32 directory, as this can cause issues when using WinSCP.
     Use %SystemRoot% (C:\Windows) or %USERPROFILE% (C:\Users\<username>) instead.
     ```

     **Linux**

     All of the Teleport binaries in Linux installations include the `tctl` and `tsh` clients. For more options (including RPM/DEB packages and downloads for i386/ARM/ARM64) see our [installation page](https://goteleport.com/docs/installation/single-machine.md).

     ```
     $ curl -O https://cdn.teleport.dev/teleport-v${TELEPORT_VERSION?}-linux-amd64-bin.tar.gz
     $ tar -xzf teleport-v${TELEPORT_VERSION?}-linux-amd64-bin.tar.gz
     $ cd teleport
     $ sudo ./install
     Teleport binaries have been copied to /usr/local/bin
     ```

  Connecting with TLS routing disabled

  This guide's commands assume your Teleport cluster uses TLS routing (`proxy_listener_mode: multiplex`), where the `tctl` and `tsh` clients reach every Teleport service through the Proxy Service's web address on port `443`. If you're not sure whether this applies to your cluster, check with whoever manages it.

  If your cluster uses separate listener ports instead, adjust ports as follows:

  - **`tsh` commands** (e.g., `tsh login --proxy=...`): continue using the Proxy Service web address on port `3080` (or `443` if behind a load balancer). Do not change these to port `3025`.

  - **Direct `tctl` or Auth Service API commands**: use port `3025` for the Auth Service gRPC listener:

    ```
    $ tctl status --auth-server=teleport.example.com:3025
    ```

**Recommended:** Configure Machine & Workload Identity to provide short-lived Teleport credentials to the plugin. Before following this guide, follow a Machine & Workload Identity [deployment guide](https://goteleport.com/docs/machine-workload-identity/deployment.md) to run the `tbot` binary on your infrastructure.

- Admin account on your Discord server. Installing a bot requires at least the "manager server" permission.

- Either a Linux host or Kubernetes cluster where you will run the Discord plugin.

- Check that you can connect to your Teleport cluster and verify that you can run `tctl` and `tsh` commands using your current credentials.

  1. Assign teleport.example.com to the domain name of the Teleport Proxy Service in your cluster and email\@example.com to your Teleport username.

  2. Authenticate to your Teleport cluster. This depends on whether your shell is interactive or not.

     **In an interactive shell:** Run the following command. By default, this triggers a multi-factor authentication prompt:

     ```
     $ tsh login --proxy=teleport.example.com --user=email@example.com
     $ tctl status
     Cluster  teleport.example.com
     Version  18.10.0
     CA pin   sha256:abdc1245efgh5678abdc1245efgh5678abdc1245efgh5678abdc1245efgh5678
     ```

     **On non-interactive environments:** If you are running `tsh` and `tctl` as an AI agent, in a CI/CD environment, or similar, make sure the `TELEPORT_IDENTITY_FILE` environment variable is assigned to a valid file path with credentials for your cluster. `tsh` and `tctl` read the file path from the environment variable and do not require a separate authentication step. If there is no identity file available, we recommend that you [set up Machine ID](https://goteleport.com/docs/machine-workload-identity/getting-started.md) to provision one automatically.

     When executing `tctl` commands with an identity file, you must pass the `--auth-server` flag to provide the Teleport Auth Service address, which is not included in the identity file. If you provide the Proxy Service address, `tctl` connects to the Proxy Service, which forwards traffic to and from the Teleport Auth Service. Update 443 to `3025` if you are contacting the Auth Service directly with `tctl`:

     ```
     $ tctl status --auth-server=teleport.example.com:443
     ```

     For `tsh` commands that read an identity file, you must pass the `--proxy` flag, which points `tsh` to the address of the Teleport Proxy Service:

     ```
     $ tsh status --proxy=teleport.example.com
     ```

     Ensure client commands can access your identity file. Replace path/to/identity/file with the path to your identity file:

     ```
     $ export TELEPORT_IDENTITY_FILE="${TELEPORT_IDENTITY_FILE:-path/to/identity/file}"
     ```

     Add the `--auth-server` or `--proxy` flags to all subsequent `tctl` and `tsh` commands.

  If you can connect to the cluster and run the `tctl status` command, you can use your current credentials to run subsequent `tctl` commands from your workstation. If you host your own Teleport cluster, you can also run `tctl` commands on the computer that hosts the Teleport Auth Service for full permissions.

- An app registered with Discord to represent the Access Request plugin. This requires manually creating the app in the Discord Web UI.

  Follow the [Discord Getting Started guide](https://docs.discord.com/developers/quick-start/getting-started) to create an app and add it to your Discord servers. Make sure the bot is only available to your Discord servers and is not a public bot.

  The app must grant the following OAuth2 scopes:

  - bot
  - View Channels
  - Send Messages

  ---

  TIP

  Copy the token for use later in this guide.

  ---

  When registering the app, you can use the [Teleport icon](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAMAAADDpiTIAAAACXBIWXMAAAWJAAAFiQFtaJ36AAAAM1BMVEUAAABRL8lRL8lRL8lRL8lRL8lRL8lRL8lRL8lRL8lRL8lRL8lRL8lRL8lRL8lRL8lRL8mm7AnDAAAAEHRSTlMAECAwQFBgcICPn6+/z9/vIxqCigAAFEVJREFUGBnswVly5CAUBMACJIQQgrr/aWci/OFZbPcK/eioTIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIPJ9bfktfWH5zkPfkl5hSKZUX1VJSiouHvAW/pL1U3qGWPS0eMiu3pHzyYWdOi4PMxW2l8onqsTnINFLj07UEmURmFxkyhZ2d7JAJLOxmgdh3sJsDYh87gpgX2FGAWBfZUYRYt7OjHWJdYUcFYh27ghgX2FWA2BbZVYTYltjVDrGtsKsCsa2xL4hpnp15iGUrO1shliV2liCWFXZWIJY1dtYghnl25yF2LexuhdiV2F2C2HWwuwKxq7K7CjHLcQAHsWrhAAvEqsQBEsSqgwMcEKsqB6gQoxyHcBCbFg6xQGzaOESC2JQ5xAGx6eQQJ8QmDgIxaeEgC8SijYNsEIsyB8kQi04OckIs4jAQgwKHWSD2RA6zQezZOcwOsadwmAKxhwNBzAkcKECsiRwoQqzZOdAOsaZwoAKxpnEkiDGeQ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ar_logo-d25baa82e83316fe798e3778c6c729cb.png).

## Step 1/7. Define RBAC resources

Before you set up the Discord plugin, you will need to enable Role Access Requests in your Teleport cluster.

For the purpose of this guide, we will define an `editor-requester` role, which can request the built-in `editor` role, and an `editor-reviewer` role that can review requests for the `editor` role.

Create a file called `editor-request-rbac.yaml` with the following content:

```
kind: role
version: v7
metadata:
  name: editor-reviewer
spec:
  allow:
    review_requests:
      roles: ['editor']
---
kind: role
version: v7
metadata:
  name: editor-requester
spec:
  allow:
    request:
      roles: ['editor']
      thresholds:
        - approve: 1
          deny: 1

```

Create the roles you defined:

```
$ tctl create -f editor-request-rbac.yaml
role 'editor-reviewer' has been created
role 'editor-requester' has been created
```

---

TIP

You can also create and edit roles using the Web UI. Go to **Access -> Roles** and click **Create New Role** or pick an existing role to edit.

---

Allow yourself to review requests by users with the `editor-requester` role by assigning yourself the `editor-reviewer` role.

Assign the `editor-reviewer` role to your Teleport user. The commands to run depend on how you authenticate to Teleport, that is, whether you have a local Teleport user, a single sign-on authentication connector, or a non-interactive user:

**Local User**

1. Retrieve your local user's roles as a comma-separated list:

   ```
   $ ROLES=$(tsh status -f json | jq -r '.active.roles | join(",")')
   ```

2. Edit your local user to add the new role:

   ```
   $ tctl users update $(tsh status -f json | jq -r '.active.username') \
     --set-roles "${ROLES?},editor-reviewer"
   ```

3. Sign out of the Teleport cluster and sign in again to assume the new role.

**GitHub**

1. Open your `github` authentication connector in a text editor:

   ```
   $ tctl edit github/github
   ```

2. Edit the `github` connector, adding `editor-reviewer` to the `teams_to_roles` section.

   The team you should map to this role depends on how you have designed your organization's role-based access controls (RBAC). However, the team must include your user account and should be the smallest team possible within your organization.

   Here is an example:

   ```
     teams_to_roles:
       - organization: octocats
         team: admins
         roles:
           - access
   +       - editor-reviewer

   ```

3. Apply your changes by saving and closing the file in your editor.

4. Sign out of the Teleport cluster and sign in again to assume the new role.

**SAML**

1. Retrieve your `saml` configuration resource:

   ```
   $ tctl get --with-secrets saml/mysaml > saml.yaml
   ```

   Note that the `--with-secrets` flag adds the value of `spec.signing_key_pair.private_key` to the `saml.yaml` file. Because this key contains a sensitive value, you should remove the saml.yaml file immediately after updating the resource.

2. Edit `saml.yaml`, adding `editor-reviewer` to the `attributes_to_roles` section.

   The attribute you should map to this role depends on how you have designed your organization's role-based access controls (RBAC). However, the group must include your user account and should be the smallest group possible within your organization.

   Here is an example:

   ```
     attributes_to_roles:
       - name: "groups"
         value: "my-group"
         roles:
           - access
   +       - editor-reviewer

   ```

3. Apply your changes:

   ```
   $ tctl create -f saml.yaml
   ```

4. Sign out of the Teleport cluster and sign in again to assume the new role.

**OIDC**

1. Retrieve your `oidc` configuration resource:

   ```
   $ tctl get oidc/myoidc --with-secrets > oidc.yaml
   ```

   Note that the `--with-secrets` flag adds the value of `spec.signing_key_pair.private_key` to the `oidc.yaml` file. Because this key contains a sensitive value, you should remove the oidc.yaml file immediately after updating the resource.

2. Edit `oidc.yaml`, adding `editor-reviewer` to the `claims_to_roles` section.

   The claim you should map to this role depends on how you have designed your organization's role-based access controls (RBAC). However, the group must include your user account and should be the smallest group possible within your organization.

   Here is an example:

   ```
     claims_to_roles:
       - name: "groups"
         value: "my-group"
         roles:
           - access
   +       - editor-reviewer

   ```

3. Apply your changes:

   ```
   $ tctl create -f oidc.yaml
   ```

4. Sign out of the Teleport cluster and sign in again to assume the new role.

**Non-Interactive**

For non-interactive users such as AI agents and CI/CD runners, follow these steps.

If you are using Machine ID to issue identity files to your user:

1. Add the new role to your bot. Assign mybot to the name of the Machine ID bot that issues your certificate:

   ```
   $ tctl bots update mybot --add-roles editor-reviewer
   ```

2. Force `tbot` to regenerate the certificate:

   ```
   $ pkill -HUP tbot
   ```

   The bot will also generate a certificate with the new role on its next renewal.

Otherwise, update your user and regenerate your identity file:

1. Retrieve your local user's roles as a comma-separated list. Make sure username is the Teleport user you want to assign the new role to.

   ```
   $ ROLES=$(tctl get user/username --format=json | jq -r '.[].spec.roles | join(",")')
   ```

2. Edit your local user to add the new role:

   ```
   $ tctl users update username \
     --set-roles "${ROLES?},editor-reviewer"
   ```

3. Regenerate the identity file. Make sure path/to/identity/file corresponds to the correct output path:

   ```
   $ tctl auth sign \
     --user=username \
     --out=path/to/identity/file \
     --overwrite
   ```

Create a user called `myuser` who has the `editor-requester` role. This user cannot edit your cluster configuration unless they request the `editor` role:

```
$ tctl users add myuser --roles=editor-requester
```

`tctl` will print an invitation URL to your terminal. Visit the URL and log in as `myuser` for the first time, registering credentials as configured for your Teleport cluster.

Later in this guide, you will have `myuser` request the `editor` role so you can review the request using the Teleport plugin.

## Step 2/7. Define a Teleport Discord plugin user

The required permissions for the plugin are configured in the preset `access-plugin` role. To generate credentials for the plugin, define either a Machine ID bot user or a regular Teleport user.

**Machine & Workload Identity**

If you haven't set up a Machine ID bot yet, refer to the [deployment guide](https://goteleport.com/docs/machine-workload-identity/deployment.md) to run the `tbot` binary on your infrastructure.

Next, allow the Machine ID bot to generate credentials for the `access-plugin` role. You can do this using `tctl`, replacing `my-bot` with the name of your bot:

```
$ tctl bots update my-bot --add-roles access-plugin
```

**Long-lived identity files**

As with all Teleport users, the Teleport Auth Service authenticates the `access-plugin` user by issuing short-lived TLS credentials. In this case, we will need to request the credentials manually by *impersonating* the `access-plugin` role and user.

If you are running a self-hosted Teleport Enterprise deployment and are using `tctl` from the Auth Service host, you will already have impersonation privileges.

To grant your user impersonation privileges for `access-plugin`, define a user named `access-plugin` and a role named `access-plugin-impersonator` by adding the following YAML document into a file called `access-plugin-impersonator.yaml`:

```
kind: user
metadata:
  name: access-plugin
spec:
  roles: ['access-plugin']
version: v2
---
kind: role
version: v7
metadata:
  name: access-plugin-impersonator
spec:
  allow:
    impersonate:
      roles:
      - access-plugin
      users:
      - access-plugin

```

Create the user and role:

```
$ tctl create -f access-plugin-impersonator.yaml
user "access-plugin" has been created
role "access-plugin-impersonator" has been created
```

---

TIP

You can also create and edit roles using the Web UI. Go to **Access -> Roles** and click **Create New Role** or pick an existing role to edit.

---

Assign this role to the user you plan to use to generate credentials for the `access-plugin` role and user:

Assign the `access-plugin-impersonator` role to your Teleport user. The commands to run depend on how you authenticate to Teleport, that is, whether you have a local Teleport user, a single sign-on authentication connector, or a non-interactive user:

**Local User**

1. Retrieve your local user's roles as a comma-separated list:

   ```
   $ ROLES=$(tsh status -f json | jq -r '.active.roles | join(",")')
   ```

2. Edit your local user to add the new role:

   ```
   $ tctl users update $(tsh status -f json | jq -r '.active.username') \
     --set-roles "${ROLES?},access-plugin-impersonator"
   ```

3. Sign out of the Teleport cluster and sign in again to assume the new role.

**GitHub**

1. Open your `github` authentication connector in a text editor:

   ```
   $ tctl edit github/github
   ```

2. Edit the `github` connector, adding `access-plugin-impersonator` to the `teams_to_roles` section.

   The team you should map to this role depends on how you have designed your organization's role-based access controls (RBAC). However, the team must include your user account and should be the smallest team possible within your organization.

   Here is an example:

   ```
     teams_to_roles:
       - organization: octocats
         team: admins
         roles:
           - access
   +       - access-plugin-impersonator

   ```

3. Apply your changes by saving and closing the file in your editor.

4. Sign out of the Teleport cluster and sign in again to assume the new role.

**SAML**

1. Retrieve your `saml` configuration resource:

   ```
   $ tctl get --with-secrets saml/mysaml > saml.yaml
   ```

   Note that the `--with-secrets` flag adds the value of `spec.signing_key_pair.private_key` to the `saml.yaml` file. Because this key contains a sensitive value, you should remove the saml.yaml file immediately after updating the resource.

2. Edit `saml.yaml`, adding `access-plugin-impersonator` to the `attributes_to_roles` section.

   The attribute you should map to this role depends on how you have designed your organization's role-based access controls (RBAC). However, the group must include your user account and should be the smallest group possible within your organization.

   Here is an example:

   ```
     attributes_to_roles:
       - name: "groups"
         value: "my-group"
         roles:
           - access
   +       - access-plugin-impersonator

   ```

3. Apply your changes:

   ```
   $ tctl create -f saml.yaml
   ```

4. Sign out of the Teleport cluster and sign in again to assume the new role.

**OIDC**

1. Retrieve your `oidc` configuration resource:

   ```
   $ tctl get oidc/myoidc --with-secrets > oidc.yaml
   ```

   Note that the `--with-secrets` flag adds the value of `spec.signing_key_pair.private_key` to the `oidc.yaml` file. Because this key contains a sensitive value, you should remove the oidc.yaml file immediately after updating the resource.

2. Edit `oidc.yaml`, adding `access-plugin-impersonator` to the `claims_to_roles` section.

   The claim you should map to this role depends on how you have designed your organization's role-based access controls (RBAC). However, the group must include your user account and should be the smallest group possible within your organization.

   Here is an example:

   ```
     claims_to_roles:
       - name: "groups"
         value: "my-group"
         roles:
           - access
   +       - access-plugin-impersonator

   ```

3. Apply your changes:

   ```
   $ tctl create -f oidc.yaml
   ```

4. Sign out of the Teleport cluster and sign in again to assume the new role.

**Non-Interactive**

For non-interactive users such as AI agents and CI/CD runners, follow these steps.

If you are using Machine ID to issue identity files to your user:

1. Add the new role to your bot. Assign mybot to the name of the Machine ID bot that issues your certificate:

   ```
   $ tctl bots update mybot --add-roles access-plugin-impersonator
   ```

2. Force `tbot` to regenerate the certificate:

   ```
   $ pkill -HUP tbot
   ```

   The bot will also generate a certificate with the new role on its next renewal.

Otherwise, update your user and regenerate your identity file:

1. Retrieve your local user's roles as a comma-separated list. Make sure username is the Teleport user you want to assign the new role to.

   ```
   $ ROLES=$(tctl get user/username --format=json | jq -r '.[].spec.roles | join(",")')
   ```

2. Edit your local user to add the new role:

   ```
   $ tctl users update username \
     --set-roles "${ROLES?},access-plugin-impersonator"
   ```

3. Regenerate the identity file. Make sure path/to/identity/file corresponds to the correct output path:

   ```
   $ tctl auth sign \
     --user=username \
     --out=path/to/identity/file \
     --overwrite
   ```

You will now be able to generate signed certificates for the `access-plugin` role and user.

## Step 3/7. Export the access plugin identity

Give the plugin access to a Teleport identity file. We recommend using Machine ID for this in order to produce short-lived identity files that are less dangerous if exfiltrated, though in demo deployments, you can generate longer-lived identity files with `tctl`:

**Machine & Workload Identity**

Configure `tbot` with an output that will produce the credentials needed by the plugin. As the plugin will be accessing the Teleport API, the correct output type to use is `identity`.

For this guide, the `directory` destination will be used. This will write these credentials to a specified directory on disk. Ensure that this directory can be written to by the Linux user that `tbot` runs as, and that it can be read by the Linux user that the plugin will run as.

Modify your `tbot` configuration to add an `identity` output.

If running `tbot` on a Linux server, use the `directory` output to write identity files to the `/opt/machine-id` directory:

```
services:
- type: identity
  destination:
    type: directory
    # For this guide, /opt/machine-id is used as the destination directory.
    # You may wish to customize this. Multiple outputs cannot share the same
    # destination.
    path: /opt/machine-id

```

If running `tbot` on Kubernetes, write the identity file to Kubernetes secret instead:

```
services:
  - type: identity
    destination:
      type: kubernetes_secret
      name: teleport-plugin-discord-identity

```

If operating `tbot` as a background service, restart it. If running `tbot` in one-shot mode, execute it now.

You should now see an `identity` file under `/opt/machine-id` or a Kubernetes secret named `teleport-plugin-discord-identity`. This contains the private key and signed certificates needed by the plugin to authenticate with the Teleport Auth Service.

**Long-lived identity files**

Like all Teleport users, `access-plugin` needs signed credentials in order to connect to your Teleport cluster. You will use the `tctl auth sign` command to request these credentials.

The following `tctl auth sign` command impersonates the `access-plugin` user, generates signed credentials, and writes an identity file to the local directory:

```
$ tctl auth sign --user=access-plugin --out=identity
```

The plugin connects to the Teleport Auth Service's gRPC endpoint over TLS.

The identity file, `identity`, includes both TLS and SSH credentials. The plugin uses the SSH credentials to connect to the Proxy Service, which establishes a reverse tunnel connection to the Auth Service. The plugin uses this reverse tunnel, along with your TLS credentials, to connect to the Auth Service's gRPC endpoint.

Certificate Lifetime

By default, `tctl auth sign` produces certificates with a relatively short lifetime. For production deployments, we suggest using [Machine & Workload Identity](https://goteleport.com/docs/machine-workload-identity/introduction.md) to programmatically issue and renew certificates for your plugin. See our Machine & Workload Identity [getting started guide](https://goteleport.com/docs/machine-workload-identity/getting-started.md) to learn more.

Note that you cannot issue certificates that are valid longer than your existing credentials. For example, to issue certificates with a 1000-hour TTL, you must be logged in with a session that is valid for at least 1000 hours. This means your user must have a role allowing a `max_session_ttl` of at least 1000 hours (60000 minutes), and you must specify a `--ttl` when logging in:

```
$ tsh login --proxy=teleport.example.com --ttl=60060
```

If you are running the plugin on a Linux server, create a data directory to hold certificate files for the plugin:

```
$ sudo mkdir -p /var/lib/teleport/plugins/discord
$ sudo mv identity /var/lib/teleport/plugins/discord
```

If you are running the plugin on Kubernetes, create a Kubernetes secret that contains the Teleport identity file:

```
$ kubectl -n teleport create secret generic --from-file=identity teleport-plugin-discord-identity
```

Once the Teleport credentials expire, you will need to renew them by running the `tctl auth sign` command again.

## Step 4/7. Install the Teleport Discord plugin

**Download**

Access Request Plugins are available as `amd64` and `arm64` Linux binaries for downloading. Replace `ARCH` with your required version.

```
$ curl -L -O https://cdn.teleport.dev/teleport-access-discord-v18.10.0-linux-ARCH-bin.tar.gz
$ tar -xzf teleport-access-discord-v18.10.0-linux-ARCH-bin.tar.gz
$ cd teleport-access-discord
$ sudo ./install
```

Make sure the binary is installed:

```
$ teleport-discord version
teleport-discord v18.10.0 git:teleport-discord-v18.10.0-fffffffff go1.25.12
```

**Docker Image**

```
$ docker pull public.ecr.aws/gravitational/teleport-plugin-discord:18.10.0
```

Make sure the plugin is installed by running the following command:

```
$ docker run public.ecr.aws/gravitational/teleport-plugin-discord:18.10.0 version
teleport-discord v18.10.0 1.25.12
```

For a list of available tags, visit [Amazon ECR Public Gallery](https://gallery.ecr.aws/gravitational/teleport-plugin-discord).

**From Source**

To install from source you need `git` and `go` installed. If you do not have Go installed, visit the Go [downloads page](https://go.dev/dl/).

```
$ git clone https://github.com/gravitational/teleport -b branch/v18
$ cd teleport/integrations/access/discord
$ git checkout v18.10.0
$ make build/teleport-discord
```

Move the `teleport-discord` binary into your PATH.

Make sure the binary is installed:

```
$ teleport-discord version
teleport-discord v18.10.0 git:teleport-discord-v18.10.0-fffffffff go1.25.12
```

**Helm Chart**

Allow Helm to install charts that are hosted in the Teleport Helm repository:

```
$ helm repo add teleport https://charts.releases.teleport.dev
```

Update the cache of charts from the remote repository:

```
$ helm repo update
```

## Step 5/7. Configure the Teleport Discord plugin

At this point, the Teleport Discord plugin has the credentials it needs to communicate with your Teleport cluster and the Discord API. In this step, you will configure the Discord plugin to use these credentials. You will also configure the plugin to notify the right Discord channels when it receives an Access Request update.

### Create a config file

**Executable or Docker**

The Teleport Discord plugin uses a config file in TOML format. Generate a boilerplate config by running the following command (the plugin will not run unless the config file is in `/etc/teleport-discord.toml`):

```
$ teleport-discord configure | sudo tee /etc/teleport-discord.toml > /dev/null
```

This should result in a config file like the one below:

```
# Example Discord plugin configuration TOML file

[teleport]
# Teleport Auth/Proxy Server address.
# addr = "example.com:3025"
#
# Should be port 3025 for Auth Server and 3080 or 443 for Proxy.
# For Teleport Cloud, should be in the form "your-account.teleport.sh:443".

# Credentials generated with `tctl auth sign`.
#
# When using --format=file:
# identity = "/var/lib/teleport/plugins/discord/identity"    # Identity file
# refresh_identity = true                                    # Refresh identity file on a periodic basis.
#
# When using --format=tls:
# client_key = "/var/lib/teleport/plugins/discord/auth.key" # Teleport TLS secret key
# client_crt = "/var/lib/teleport/plugins/discord/auth.crt" # Teleport TLS certificate
# root_cas = "/var/lib/teleport/plugins/discord/auth.cas"   # Teleport CA certs

[discord]
# Discord Bot OAuth token
token = "XXXXXXXXX"

[role_to_recipients]
# Map roles to recipients.
#
# Provide Discord channel ID recipients for access requests for specific roles.
# "*" must be provided to match non-specified roles.
#
# "dev" = "1234567890"
# "*" = ["0987654321"]

[log]
output = "stderr" # Logger output. Could be "stdout", "stderr" or "/var/lib/teleport/discord.log"
severity = "INFO" # Logger severity. Could be "INFO", "ERROR", "DEBUG" or "WARN".


```

**Helm Chart**

The Discord Helm chart uses a YAML values file to configure the plugin. On your local workstation, create a file called `teleport-discord-helm.yaml` based on the following example:

```
teleport:
  # Teleport HTTPS Proxy web address, for Teleport Enterprise Cloud should be in the form "your-account.teleport.sh:443"
  address: ""
  # Secret containing identity, e.g., teleport-plugin-discord-identity
  identitySecretName: "" 
  # Path within the secret containing the identity file, e.g., identity
  identitySecretPath: ""

discord:
  token: "XXXXXXXX"  # Discord Bot OAuth token

# Mapping from role to recipients
roleToRecipients: {}
#  "*":
#    - "1234567890"  # security-team
#  "dev":
#    - "0987654321"  # dev-team-channel
#    - "1212121212"  # admin-team-channel


```

### Edit the config file

Open the configuration file created for the Teleport Discord plugin and update the following fields:

**`[teleport]`**

The Discord plugin uses this section to connect to the Teleport Auth Service.

**Executable**

**`addr`**: Include the hostname and HTTPS port of your Teleport Proxy Service or Teleport Enterprise Cloud account (e.g., `teleport.example.com:443` or `mytenant.teleport.sh:443`).

**`identity`**: Fill this in with the path to the identity file you exported earlier.

**`client_key`**, **`client_crt`**, **`root_cas`**: Comment these out, since we are not using them in this configuration.

**Helm Chart**

**`address`**: Include the hostname and HTTPS port of your Teleport Proxy Service or Teleport Enterprise Cloud tenant (e.g., `teleport.example.com:443` or `mytenant.teleport.sh:443`).

**`identitySecretName`**: Fill in the `identitySecretName` field with the name of the Kubernetes secret you created earlier.

**`identitySecretPath`**: Fill in the `identitySecretPath` field with the path of the identity file within the Kubernetes secret. If you have followed the instructions above, this will be `identity`.

If you are providing credentials to the plugin using a `tbot` binary that runs on a Linux server, make sure the value of `identity` is the same as the path of the identity file you configured `tbot` to generate, `/opt/machine-id/identity`.

Configure the plugin to periodically reload the identity file, ensuring that it does not attempt to connect to the Teleport Auth Service with expired credentials.

Add the following to the `teleport` section of the configuration:

```
refresh_identity = true

```

**`[discord]`**

`token`: Paste the bot token saved previously in this field.

**`[role_to_recipients]`**

The `role_to_recipients` map configures the channels that the Discord plugin will notify when a user requests access to a specific role. When the Discord plugin receives an Access Request from the Auth Service, it will look up the role being requested and identify the Discord channels to notify.

Each channel is represented by a numeric ID. Channels can be public, private or direct messages between a user and the bot. To determine the numeric ID of a channel for the bot to notify, follow the instructions below:

**Public Channel**

Open Discord in a web browser and navigate to the desired channel.

The web browser URL should look like:

```
https://discord.com/channels/<guild ID>/<channel ID>

```

Copy the last part of the URL (everything after the last `/`), which is the channel ID.

**Private Channel**

Open Discord in a web browser and navigate to the desired channel.

In the channel list choose "Create invite", type "teleport" in the search field and invite your Discord Teleport bot. The bot should now appear in the channel member list.

The web browser URL should look like:

```
https://discord.com/channels/<guild ID>/<channel ID>

```

Copy the last part of the URL (everything after the last `/`), which is the channel ID.

**Direct Message**

To retrieve the channel ID of the private discussion between User A and the Teleport bot, have User A send a direct message to the Teleport bot. This will open a conversation between the user and the bot. Once the conversation is initiated, the user can open the discussion page.

The web browser URL should look like:

```
https://discord.com/channels/@me/<channel ID>

```

Copy the last part of the URL (everything after the last `/`), which is the channel ID.

In the `role_to_recipients` map, each key is the name of a Teleport role. Each value configures the Discord channel (or channels) to notify.

The `role_to_recipients` map must also include an entry for `"*"`, which the plugin looks up if no other entry matches a given role name. In the example above, requests for roles aside from `dev` will notify the `security-team` channel.

Configure the Discord plugin to notify you when a user requests the `editor` role by adding the following to your `role_to_recipients` config (replace `YOUR-CHANNEL-ID` with a valid channel ID):

**Executable or Docker**

Here is an example of a `role_to_recipients` map. Each value can be a single string or an array of strings:

```
[role_to_recipients]
"*" = "YOUR-CHANNEL-ID"
"editor" = "YOUR-CHANNEL-ID"

```

**Helm Chart**

In the Helm chart, the `role_to_recipients` field is called `roleToRecipients` and uses the following format, where keys are strings and values are arrays of strings:

```
roleToRecipients:
  "*": ["YOUR-CHANNEL-ID"]
  "editor": ["YOUR-CHANNEL-ID"]

```

The final configuration file should resemble the following:

**Executable or Docker**

```
# Example Discord plugin configuration TOML file

[teleport]
# Teleport Auth/Proxy Server address.
# addr = "example.com:3025"
#
# Should be port 3025 for Auth Server and 3080 or 443 for Proxy.
# For Teleport Cloud, should be in the form "your-account.teleport.sh:443".

# Credentials generated with `tctl auth sign`.
#
# When using --format=file:
# identity = "/var/lib/teleport/plugins/discord/identity"    # Identity file
# refresh_identity = true                                    # Refresh identity file on a periodic basis.
#
# When using --format=tls:
# client_key = "/var/lib/teleport/plugins/discord/auth.key" # Teleport TLS secret key
# client_crt = "/var/lib/teleport/plugins/discord/auth.crt" # Teleport TLS certificate
# root_cas = "/var/lib/teleport/plugins/discord/auth.cas"   # Teleport CA certs

[discord]
# Discord Bot OAuth token
token = "XXXXXXXXX"

[role_to_recipients]
# Map roles to recipients.
#
# Provide Discord channel ID recipients for access requests for specific roles.
# "*" must be provided to match non-specified roles.
#
# "dev" = "1234567890"
# "*" = ["0987654321"]

[log]
output = "stderr" # Logger output. Could be "stdout", "stderr" or "/var/lib/teleport/discord.log"
severity = "INFO" # Logger severity. Could be "INFO", "ERROR", "DEBUG" or "WARN".


```

**Helm Chart**

```
teleport:
  # Teleport HTTPS Proxy web address, for Teleport Enterprise Cloud should be in the form "your-account.teleport.sh:443"
  address: ""
  # Secret containing identity, e.g., teleport-plugin-discord-identity
  identitySecretName: "" 
  # Path within the secret containing the identity file, e.g., identity
  identitySecretPath: ""

discord:
  token: "XXXXXXXX"  # Discord Bot OAuth token

# Mapping from role to recipients
roleToRecipients: {}
#  "*":
#    - "1234567890"  # security-team
#  "dev":
#    - "0987654321"  # dev-team-channel
#    - "1212121212"  # admin-team-channel


```

## Step 6/7. Test your Discord app

Once Teleport is running, you've created the Discord app, and the plugin is configured, you can now run the plugin and test the workflow.

**Executable**

Start the plugin:

```
$ teleport-discord start
```

If everything works fine, the log output should look like this:

```
$ teleport-discord start
INFO   Starting Teleport Access Discord Plugin 18.10.0: discord/app.go:80
INFO   Plugin is ready discord/app.go:101
```

**Docker**

Start the plugin:

```
$ docker run -v <path-to-config>:/etc/teleport-discord.toml public.ecr.aws/gravitational/teleport-plugin-discord:18.10.0 start
```

**Helm Chart**

Install the plugin:

```
$ helm upgrade --install teleport-plugin-discord teleport/teleport-plugin-discord --values teleport-discord-helm.yaml
```

To inspect the plugin's logs, use the following command:

```
$ kubectl logs deploy/teleport-plugin-discord
```

Debug logs can be enabled by setting `log.severity` to `DEBUG` in `teleport-discord-helm.yaml` and executing the `helm upgrade ...` command above again. Then you can restart the plugin with the following command:

```
$ kubectl rollout restart deployment teleport-plugin-discord
```

Create an Access Request and check if the plugin works as expected with the following steps.

### Create an Access Request

**As an Admin**

A Teleport admin can create an Access Request for another user with `tctl`:

```
$ tctl request create myuser --roles=editor
```

**As a User**

Users can use `tsh` to create an Access Request and log in with approved roles:

```
$ tsh request create --roles=editor
Seeking request approval... (id: 8f77d2d1-2bbf-4031-a300-58926237a807)
```

**From the Web UI**

Users can request access using the Web UI by visiting "Identity", clicking "Access Requests" and then "New Request":

![Creating an Access Request using the Web UI](/docs/assets/images/request-access-be784784ab25db7e651c87817044f082.png)

The channel you configured earlier to review the request should receive a message from "Teleport" in Discord allowing them to visit a link in the Teleport Web UI and either approve or deny the request.

### Resolve the request

Once you receive an Access Request message, click the link to visit Teleport and approve or deny the request:

![Reviewing a request](/docs/assets/images/review-request-51dc06eae57234cbbfea4e13f0879884.png)

Reviewing from the command line

You can also review an Access Request from the command line:

**As an Admin**

```
Replace REQUEST_ID with the id of the request
$ tctl request approve REQUEST_ID
$ tctl request deny REQUEST_ID
```

**As a User**

```
Replace REQUEST_ID with the id of the request
$ tsh request review --approve REQUEST_ID
$ tsh request review --deny REQUEST_ID
```

Once the request is resolved, the Discord bot will update the Access Request message with ✅ or ❌, depending on whether the request was approved or denied.

---

AUDITING ACCESS REQUESTS

When the Discord plugin posts an Access Request notification to a channel, anyone with access to the channel can view the notification and follow the link. While users must be authorized via their Teleport roles to review Access Requests, you should still check the Teleport audit log to ensure that the right users are reviewing the right requests.

When auditing Access Request reviews, check for events with the type `Access Request Reviewed` in the Teleport Web UI.

---

## Step 7/7. Set up systemd

This section is only relevant if you are running the Teleport Discord plugin on a Linux host.

In production, we recommend starting the Teleport plugin daemon via an init system like systemd. Here's the recommended Teleport plugin service unit file for systemd:

```
[Unit]
Description=Teleport Discord Plugin
After=network.target

[Service]
Type=simple
Restart=on-failure
ExecStart=/usr/local/bin/teleport-discord start --config=/etc/teleport-discord.toml
ExecReload=/bin/kill -HUP $MAINPID
PIDFile=/run/teleport-discord.pid

[Install]
WantedBy=multi-user.target


```

Save this as `teleport-discord.service` in either `/usr/lib/systemd/system/` or another [unit file load path](https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Unit%20File%20Load%20Path) supported by systemd.

Enable and start the plugin:

```
$ sudo systemctl enable teleport-discord
$ sudo systemctl start teleport-discord
```

## Troubleshooting

Access Request plugins need permissions to list and read any Teleport resource types included in a request. This is because, when the plugin receives a resource request, it queries the Teleport Auth Service API for data about the requested resources.

If you receive an error message similar to the following, the Teleport roles for the Access Request plugin's identity do not have permissions to perform one or more operations against the Teleport API. In the example below, the Access Request plugin needs `list` and `read` permissions on the `user_group` resource:

```
ERRO   Failed to process request error:[
ERROR REPORT:
Original Error: *interceptors.RemoteError access denied to perform action "list" on "user_group", access denied to perform action "read" on "user_group"

```

Make sure the Teleport roles for the Access Request plugin's identity include permissions to list requested resources. To resolve the error above, for example, you could grant the following role to the Access Request plugin's identity:

```
kind: role
version: v7
metadata:
  name: read-user-groups
spec:
  allow:
    rules:
      - resources: [user_group]
        verbs: [list, read]

```

## Next steps

- Read our guides to configuring [Resource Access Requests](https://goteleport.com/docs/identity-governance/access-requests/resource-requests.md) and [Role Access Requests](https://goteleport.com/docs/identity-governance/access-requests/role-requests.md) so you can get the most out of your Access Request plugins.
- To see all of the options you can set in the values file for the `teleport-plugin-discord` Helm chart, consult our [Helm chart reference guide](https://goteleport.com/docs/reference/helm-reference/teleport-plugin-discord.md).
