# Access Requests with Microsoft Teams

This guide will explain how to set up Microsoft Teams to receive Access Request messages from Teleport.

This integration is hosted on Teleport Enterprise (Cloud)

In Teleport Enterprise Cloud, Teleport manages the Microsoft Teams integration for you, and you can enroll the Microsoft Teams 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.

![Create Microsoft Teams Bot](/docs/assets/images/enroll-bot-a4707913d6aa153be4e831d980966f7c.png)

Once enrolled you can download the required `app.zip` file from the integrations status page.

![Download app.zip](/docs/assets/images/app-zip-734ee6372a221bdd95b3b28a19455ede.png)

## How it works

Teleport's Microsoft Teams integration notifies individuals of Access Requests. Users can then approve and deny Access Requests by following the message link, making it easier to implement security best practices without compromising productivity.

![The Microsoft Teams Access Request plugin](/docs/assets/images/msteams-5ef09ac55632303bb36b6fd5981691f9.png)

## Prerequisites

- A running Teleport Enterprise cluster. 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:

     ```
     $ TELEPORT_DOMAIN=teleport.example.com:443
     $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.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.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
     ```

**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.

- A Microsoft Teams License (Microsoft 365 Business).
- Azure console access in the organization/directory holding the Microsoft Teams License.
- An Azure resource group in the same directory. This will host resources for the Microsoft Teams Access Request plugin. You should have enough permissions to create and edit Azure Bot Services in this resource group.
- Someone with Global Admin rights on Microsoft Entra ID in order to grant permissions to the plugin.
- Someone with the `Teams administrator` role that can approve installation requests for Microsoft Teams Apps.
- Either an Azure virtual machine or Kubernetes cluster where you will run the Teleport Microsoft Teams plugin.

To check that you can connect to your Teleport cluster, sign in with `tsh login`, then verify that you can run `tctl` commands using your current credentials.

For example, run the following command, assigning teleport.example.com to the domain name of the Teleport Proxy Service in your cluster and email\@example.com to your Teleport username:

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

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.

## Step 1/9. Define RBAC resources

Before you set up the Microsoft Teams 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 by running the appropriate commands for your authentication provider:

**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.

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/9. Define a Teleport Microsoft Teams 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 by running the appropriate commands for your authentication provider:

**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.

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

## Step 3/9. 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-msteams-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-msteams-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/api-credentials
$ sudo mv identity /var/lib/teleport/plugins/api-credentials
```

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-msteams-identity
```

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

## Step 4/9. Install the Teleport Microsoft Teams plugin

Install the Microsoft Teams plugin on your workstation. If you are deploying the plugin on Kubernetes, you will still need to install the plugin locally in order to generate an application archive to upload later in this guide.

**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-msteams-v18.7.3-linux-ARCH-bin.tar.gz
$ tar -xzf teleport-access-msteams-v18.7.3-linux-ARCH-bin.tar.gz
$ cd teleport-access-msteams
$ sudo ./install
```

Make sure the binary is installed:

```
$ teleport-msteams version
teleport-msteams v18.7.3 git:teleport-msteams-v18.7.3-fffffffff go1.25.9
```

**Docker Image**

```
$ docker pull public.ecr.aws/gravitational/teleport-plugin-msteams:18.7.3
```

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

```
$ docker run public.ecr.aws/gravitational/teleport-plugin-msteams:18.7.3 version
teleport-msteams v18.7.3 1.25.9
```

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

**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/msteams
$ git checkout v18.7.3
$ make build/teleport-msteams
```

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

Make sure the binary is installed:

```
$ teleport-msteams version
teleport-msteams v18.7.3 git:teleport-msteams-v18.7.3-fffffffff go1.25.9
```

**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/9. Register an Azure Bot

The Access Request plugin for Microsoft Teams receives Access Request events from the Teleport Auth Service, formats them into Microsoft Teams messages, and sends them to the Microsoft Teams API to post them in your workspace. For this to work, you must register a new Azure Bot. Azure Bot is a managed service by Microsoft that allows to develop bots that interact with users through different channels, including Microsoft Teams.

### Register a new Azure bot

Visit [https://portal.azure.com/#create/Microsoft.AzureBot](https://portal.azure.com/#create/microsoft.azurebot) to create a new bot. Choose the bot handle so you can find the bot later in the Azure console (the bot handle will not be displayed to the user or used to configure the Microsoft Teams plugin). Also edit the Azure subscription, the resource group and the bot pricing tier.

In the "Microsoft App ID" section choose "Single Tenant" and "Create new Microsoft App ID".

![Create Azure Bot](/docs/assets/images/create-azure-bot-e6889116c5e490f5e2ad2424118a687d.png)

### Connect the bot to Microsoft Teams

Once the bot is created, open its resource page on the Azure console and navigate to the "Channels" tab. Click "Microsoft Teams" and add the Microsoft Teams channel.

The result should be as follows:

![Add Bot Channel](/docs/assets/images/add-bot-channel-1371834b9f352d6472da23c787b23ef5.png)

### Obtain information about your Microsoft App

On the bot's "Configuration" tab, copy and keep in a safe place the values of "Microsoft App ID" and "App Tenant ID". Those two UUIDs will be used in the plugin configuration.

Click the "Manage" link next to "Microsoft App ID". This will open the app management view.

![Manage Bot App](/docs/assets/images/manage-bot-app-9490b2f3a1704955c6d0369a8af1bb3e.png)

Then, go to the "Certificates & Secrets" section and choose to create a "New client secret". Use the "Copy" icon to copy the newly created secret and keep it with the previously recovered App ID and Tenant ID.

The client secret will be used by the Teleport plugin to authenticate as the bot's app when searching users and posting messages.

### Specify the permissions used by the app

Still in the app management view ("Configuration", then "Manage" the Microsoft App ID), go to the "API permissions" tab.

Add the following Microsoft Graph Application permissions:

| Permission name                                 | Reason                                                                                      |
| ----------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `AppCatalog.Read.All`                           | Used to list Teams Apps and check the app is installed.                                     |
| `User.Read.All`                                 | Used to get notification recipients.                                                        |
| `TeamsAppInstallation.ReadWriteSelfForUser.All` | Used to initiate communication with a user that never interacted with the Teams App before. |
| `TeamsAppInstallation.ReadWriteSelfForTeam.All` | Used to discover if the app is installed in the Team.                                       |

At this point the app declares the required permissions but those have not been granted.

If you are an admin, click "Grant admin consent for \<directory name>". If you are not an admin, contact an admin user to grant the permissions.

![Specify App Permissions](/docs/assets/images/specify-app-permissions-1799dcd6ac71e51e7f7c5000dc47cb8f.png)

Once permissions have been approved, refresh the page and check the approval status. The result should be as follows:

![Granted App Permissions](/docs/assets/images/granted-app-permissions-8fad6a3e011168be8892684d8d32ac97.png)

## Step 6/9. Configure the Teleport Microsoft Teams plugin

At this point, the Teleport Microsoft Teams plugin has the credentials it needs to communicate with your Teleport cluster and Azure APIs, but the app has not been installed to Microsoft Teams yet.

In this step, you will configure the Microsoft Teams plugin to use the Azure credentials and generate the Teams App package that will be used to install the Microsoft Teams App. You will also configure the plugin to notify the right Microsoft Teams users when it receives an Access Request update.

### Generate a configuration file and assets

Generate a configuration file for the plugin. The instructions depend on whether you are deploying the plugin on a virtual machine or Kubernetes:

**Virtual Machine**

The Teleport Microsoft Teams plugin uses a config file in TOML format. The `configure` subcommand generates the directory `/var/lib/teleport/plugins/msteams/assets` containing the TOML configuration file and an `app.zip` file that will be used later to add the Teams App into the organization catalog.

Run the following command on your virtual machine:

```
$ export AZURE_APPID="your-appid"
$ export AZURE_TENANTID="your-tenantid"
$ export AZURE_APPSECRET="your-appsecret"
$ teleport-msteams configure /var/lib/teleport/plugins/msteams/assets --appID "$AZURE_APPID" --tenantID "$AZURE_TENANTID" --appSecret "$AZURE_APPSECRET"
```

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

```
# Example Microsoft Teams plugin configuration TOML file

# If true, channels and users existence is checked on plugin start. When a
# user is checked, the app is installed for the user if it was not
# already. Installation can take up to 10 seconds per user. It is
# advised to enable preloading unless you are sure all users already got
# the app installed to avoid possible timeouts when treating an access request.
preload = true

[teleport]
# Teleport Auth Service or Proxy Service address.
# Example: examples/resources/plugins/teleport-msteams.toml
# addr = ""
#
# Should be port 3025 for the Auth Service and 3080 or 443 for the Proxy
# Service.
# For Teleport Cloud, should be in the form "your-account.teleport.sh:443".

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

[msapi]
# MS API IDs. Please, check the documentation.
app_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
# Either contains the app secret or the path of a file containing the secret
app_secret = "XXXXXXXXXXXXXXXXXXXXXX"
tenant_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
teams_app_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

[role_to_recipients]
# Map roles to recipients.
#
# Provide msteams user email/id or channel URL recipients for access requests for specific roles.
# role.suggested_reviewers will automatically be treated as additional email recipients.
# "*" must be provided to match non-specified roles.
#
# "dev" = "devs-msteams-channel"
# "*" = ["admin@email.com", "admin-msteams-channel"]
"*" = []

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


```

Copy the `/var/lib/teleport/plugins/msteams/assets/app.zip` file to your local computer. You will have to upload it to Microsoft Teams later.

On the host where you will run the Microsoft Teams plugin, move the file `/var/lib/teleport/plugins/msteams/assets/teleport-msteams.toml` to `/etc/teleport-msteams.toml`. You can then edit the copy located in `/etc/`.

**Kubernetes**

Run the following command on your local machine:

```
$ export AZURE_APPID="your-appid"
$ export AZURE_TENANTID="your-tenantid"
$ export AZURE_APPSECRET="your-appsecret"
$ teleport-msteams configure /var/lib/teleport/plugins/msteams/assets --appID "$AZURE_APPID" --tenantID "$AZURE_TENANTID" --appSecret "$AZURE_APPSECRET"
```

This command generates an application archive at `/var/lib/teleport/plugins/msteams/assets/app.zip`. You will upload it to Microsoft Teams later in this guide.

Create a file on your workstation called `teleport-msteams-helm.yaml` with the following content:

```
# Default values for msteams.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

#
# Plugin specific options
#
teleport:
  address: ""            # e.g., teleport.example.com:443
  identitySecretName: "" # e.g., teleport-plugin-msteams-identity
  identitySecretPath: "" # e.g., identity

msTeams:
  appID: ""
  tenantID: ""
  teamsAppID: ""

roleToRecipients: {}
  # "*": "admin@example.com"
  # dev:
  #  - "https://teams.microsoft.com/l/channel/19%3ae06a7383ed98468f90217a35fa1980d7%40thread.tacv2/Approval%2520Channel%25202?groupId=f2b3c8ed-5502-4449-b76f-dc3acea81f1c&tenantId=ff882432-09b0-437b-bd22-ca13c0037ded"
  #  - "devops@example.com"

log:
  output: stdout
  severity: INFO


```

You will edit this file in the next section.

---

CONFIGURE COMMAND

The `configure` command is not idempotent. It generates a new Microsoft Teams application UUID with each execution. It is not possible to use an `app.zip` and a TOML configuration generated by two different executions.

---

### Edit the configuration file

Edit the configuration file according to the instructions below.

#### `[teleport]`

The Microsoft Teams plugin uses this section to connect to your Teleport cluster.

**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

```

#### `[msapi]`/`msTeams`

**Executable or Docker**

Make sure the `app_id`, `app_secret`, `tenant_id`, and `teams_app_id` fields are filled in with the correct information, which you obtained earlier in this guide.

**Helm Chart**

Make sure the `appID`, `tenantID`, and `teamsAppID` fields are filled in with the correct information, which you obtained earlier in this guide.

#### `[role_to_recipients]`

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

**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]
"*" = "alice@example.com"
"dev" = ["alice@example.com", "bob@example.com"]
"dba" = "https://teams.microsoft.com/l/channel/19%3somerandomid%40thread.tacv2/ChannelName?groupId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&tenantId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

```

**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:
  "*": "alice@example.com"
  "dev": ["alice@example.com", "bob@example.com"]
  "dba": "https://teams.microsoft.com/l/channel/19%3somerandomid%40thread.tacv2/ChannelName?groupId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&tenantId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

```

In the `role_to_recipients` map, each key is the name of a Teleport role. Each value configures the Teams user (or users) to notify. Each string must be either the email address of a Microsoft Teams user or a channel URL.

You can find the URL of a channel by opening the channel and clicking the button "Get link to channel":

![Copy Teams Channel](/docs/assets/images/copy-teams-channel-e50ce55084c69e170d590250b8d9230e.png)

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` and `dba` will notify `alice@example.com`.

Suggested reviewers

Users can suggest reviewers when they create an Access Request, e.g.,:

```
$ tsh request create --roles=dbadmin --reviewers=alice@example.com,ivan@example.com
```

If an Access Request includes suggested reviewers, the Microsoft Teams plugin will add these to the list of channels to notify. If a suggested reviewer is an email address, the plugin will look up the direct message channel for that address and post a message in that channel.

Configure the Microsoft Teams plugin to notify you when a user requests the `editor` role by adding the following to your `role_to_recipients` config (replace `TELEPORT_USERNAME` with the email of the user you assigned the `editor-reviewer` role earlier):

**Executable or Docker**

```
[role_to_recipients]
"*" = "TELEPORT_USERNAME"
"editor" = "TELEPORT_USERNAME"

```

**Helm Chart**

```
roleToRecipients:
  "*": "TELEPORT_USERNAME"
  "editor": "TELEPORT_USERNAME"

```

The final configuration file should resemble the following:

**Executable or Docker**

```
# Example Microsoft Teams plugin configuration TOML file

# If true, channels and users existence is checked on plugin start. When a
# user is checked, the app is installed for the user if it was not
# already. Installation can take up to 10 seconds per user. It is
# advised to enable preloading unless you are sure all users already got
# the app installed to avoid possible timeouts when treating an access request.
preload = true

[teleport]
# Teleport Auth Service or Proxy Service address.
# Example: examples/resources/plugins/teleport-msteams.toml
# addr = ""
#
# Should be port 3025 for the Auth Service and 3080 or 443 for the Proxy
# Service.
# For Teleport Cloud, should be in the form "your-account.teleport.sh:443".

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

[msapi]
# MS API IDs. Please, check the documentation.
app_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
# Either contains the app secret or the path of a file containing the secret
app_secret = "XXXXXXXXXXXXXXXXXXXXXX"
tenant_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
teams_app_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

[role_to_recipients]
# Map roles to recipients.
#
# Provide msteams user email/id or channel URL recipients for access requests for specific roles.
# role.suggested_reviewers will automatically be treated as additional email recipients.
# "*" must be provided to match non-specified roles.
#
# "dev" = "devs-msteams-channel"
# "*" = ["admin@email.com", "admin-msteams-channel"]
"*" = []

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


```

**Helm Chart**

```
# Default values for msteams.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

#
# Plugin specific options
#
teleport:
  address: ""            # e.g., teleport.example.com:443
  identitySecretName: "" # e.g., teleport-plugin-msteams-identity
  identitySecretPath: "" # e.g., identity

msTeams:
  appID: ""
  tenantID: ""
  teamsAppID: ""

roleToRecipients: {}
  # "*": "admin@example.com"
  # dev:
  #  - "https://teams.microsoft.com/l/channel/19%3ae06a7383ed98468f90217a35fa1980d7%40thread.tacv2/Approval%2520Channel%25202?groupId=f2b3c8ed-5502-4449-b76f-dc3acea81f1c&tenantId=ff882432-09b0-437b-bd22-ca13c0037ded"
  #  - "devops@example.com"

log:
  output: stdout
  severity: INFO


```

## Step 7/9. Add and configure the Teams App

### Upload the Teams App

Open Microsoft Teams and go to "Apps", "Manage your apps", then in the additional choices menu choose "Upload an App".

![Upload Teams App](/docs/assets/images/upload-teams-app-7b3173d3b0202a86701b279c11797e7b.png)

If you're a Teams admin, choose "Upload an app to your org's app catalog". This will allow you to skip the approval step. If you're not a Microsoft Teams admin, choose "Submit an app to your org".

Upload the `app.zip` file you generated earlier.

### Approve the Teams App

If you are not a Teams admin and chose "Submit an app to your org", you will have to ask a Teams admin to approve it.

They can do so by connecting to the [Teams admin dashboard](https://admin.teams.microsoft.com/policies/manage-apps), searching "TeleBot", selecting it and choosing "Allow".

![Upload Teams App](/docs/assets/images/allowed-teams-app-9fdc43b8fccd369e78deaf3687ef7ee8.png)

### Add the Teams App to a Team

Once the app is approved it should appear in the "Apps built for your org" section. Add the newly uploaded app to a team. Open the app, click "Add to a team", choose the "General" channel of your team and click "Set up a bot".

![Add Teams App](/docs/assets/images/add-teams-app-6e7a1fbaefad2698e9bfa72b857f0317.png)

Note: Once an app is added to a team, it can post on all channels.

## Step 8/9. Test the Teams App

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

### Test Microsoft Teams connectivity

Start the plugin in validation mode:

```
$ teleport-msteams validate <email of your teams account>
```

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

```
teleport-msteams v18.7.3 go1.25.9

 - Checking application xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx status...
 - Application found in the team app store (internal ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
 - User xxxxxx@xxxxxxxxx.xxx found: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
 - Application installation ID for user: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 - Chat ID for user: 19:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx@unq.gbl.spaces
 - Chat web URL: https://teams.microsoft.com/l/chat/19%3Axxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx%40unq.gbl.spaces/0?tenantId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
 - Hailing the user...
 - Message sent, ID: XXXXXXXXXXXXX

Check your MS Teams!

```

The plugin should exit and you should have received two messages through Microsoft Teams.

![Validate Bot Message](/docs/assets/images/validate-bot-message-966d1424a04f36885ef542f040f1fed9.png)

### Start the MS Teams Plugin

After you configured and validated the MS Teams plugin, you can now run the plugin and test the workflow.

**Executable**

Run the following command to start the Teleport MS Teams plugin. The `-d` flag will provide debug information to ensure that the plugin can connect to MS Teams and your Teleport cluster:

```
$ teleport-msteams start -d
DEBU   DEBUG logging enabled msteams/main.go:120
INFO   Starting Teleport MS Teams Plugin 18.7.3: msteams/app.go:74
DEBU   Attempting GET teleport.example.com:443/webapi/find webclient/webclient.go:129
DEBU   Checking Teleport server version msteams/app.go:242
INFO   MS Teams app found in org app store id:292e2881-38ab-7777-8aa7-cefed1404a63 name:TeleBot msteams/app.go:179
INFO   Preloading recipient data... msteams/app.go:185
INFO   Recipient found, chat found chat_id:19:a8c06deb-aa2b-4db5-9c78-96e48f625aef_a36aec2e-f11c-4219-b79a-19UUUU57de70@unq.gbl.spaces kind:user recipient:jeff@example.com msteams/app.go:195
INFO   Recipient data preloaded and cached. msteams/app.go:198
DEBU   Watcher connected watcherjob/watcherjob.go:121
INFO   Plugin is ready msteams/app.go:227
```

**Docker**

Run the plugin:

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

**Helm Chart**

Install the plugin:

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

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

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

Debug logs can be enabled by setting `log.severity` to `DEBUG` in `teleport-msteams-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-msteams
```

### Create an Access Request

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

**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 user you configured earlier to review the request should receive a direct message from "TeleBot" in Microsoft Teams 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 Microsoft Teams bot will update the Access Request message to reflect its new status.

---

AUDITING ACCESS REQUESTS

When the Microsoft Teams 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 9/9. Set up systemd

This section is only relevant if you are running the Teleport Microsoft Teams plugin on a virtual machine.

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 MsTeams Plugin
After=network.target

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

[Install]
WantedBy=multi-user.target


```

Save this as `teleport-msteams.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-msteams
$ sudo systemctl start teleport-msteams
```

## 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.
