Fork me on GitHub

Teleport

Access Requests with Microsoft Teams

Improve

This guide will explain how to set up Microsoft Teams to receive Access Request messages from Teleport. 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.

Prerequisites

  • A running Teleport cluster, including the Auth Service and Proxy Service. For details on how to set this up, see our Enterprise Getting Started guide.

  • The tctl admin tool and tsh client tool version >= 11.0.3, which you can download by visiting the customer portal.

    tctl version

    Teleport v11.0.3 go1.19

    tsh version

    Teleport v11.0.3 go1.19

  • A Teleport Cloud account, which includes a running Auth Service and Proxy Service. If you do not have a Teleport Cloud account, visit the sign up page to begin your free trial.

  • The tctl admin tool and tsh client tool version >= 10.3.8. To download these tools, visit the Downloads page.

    tctl version

    Teleport v10.3.8 go1.19

    tsh version

    Teleport v10.3.8 go1.19

  • 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 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 the Azure Active Directory that will grant permissions to the plugin.
  • Someone with the Teams administrator role that can approve installation requests for Microsoft Teams Apps.

To connect to Teleport, log in to your cluster using tsh, then use tctl remotely:

tsh login --proxy=teleport.example.com [email protected]
tctl status

Cluster teleport.example.com

Version 11.0.3

CA pin sha256:abdc1245efgh5678abdc1245efgh5678abdc1245efgh5678abdc1245efgh5678

You can run subsequent tctl commands in this guide on your local machine.

For full privileges, you can also run tctl commands on your Auth Service host.

To connect to Teleport, log in to your cluster using tsh, then use tctl remotely:

tsh login --proxy=myinstance.teleport.sh [email protected]
tctl status

Cluster myinstance.teleport.sh

Version 10.3.8

CA pin sha256:sha-hash-here

You must run subsequent tctl commands in this guide on your local machine.

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: v5
metadata:
  name: editor-reviewer
spec:
  allow:
    review_requests:
      roles: ['editor']
---
kind: role
version: v5
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

Allow yourself to review requests by users with the editor-requester role by assigning yourself the editor-reviewer role. First, retrieve your user definition:

TELEPORT_USER=$(tsh status --format=json | jq -r .active.username)
tctl get user/${TELEPORT_USER?} > user.yaml

Edit user.yaml to add the editor-reviewer role:

 spec:
   roles:
   - access
   - editor
+  - editor-reviewer

Update your user definition:

tctl create -f user.yaml

Log out of Teleport and log in again. You will now have the ability to review requests for the editor 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. Install the Teleport Microsoft Teams plugin

We currently only provide linux-amd64 binaries. You can also compile these plugins from source. You can run the plugin from a remote host or your local development machine.

We recommend installing Teleport plugins on the same host as the Teleport Proxy Service. This is an ideal location as plugins have a low memory footprint and will require access to both the public internet and the Teleport Auth Service.

curl -L -O https://get.gravitational.com/teleport-access-msteams-v11.0.3-linux-amd64-bin.tar.gz
tar -xzf teleport-access-msteams-v11.0.3-linux-amd64-bin.tar.gz
./teleport-access-msteams/install

To install from source you need git and go >= 1.19 installed.

Check out the teleport-plugins repository

git clone https://github.com/gravitational/teleport-plugins.git
cd teleport-plugins/access/msteams
make

Place the teleport-msteams binary into an appropriate location within the system's PATH, e.g., /usr/local/bin:

mv ./build/teleport-msteams /usr/local/bin

Make sure the binary is installed:

teleport-msteams version

teleport-msteams v11.0.3 git:teleport-msteams-v11.0.3-fffffffff go1.19

Step 3/9. Create a user and role for the plugin

Teleport's Access Request plugins authenticate to your Teleport cluster as a user with permissions to list and read Access Requests. This way, plugins can retrieve Access Requests from the Teleport Auth Service and present them to reviewers.

Define a user and role called access-plugin by adding the following content to a file called access-plugin.yaml:

kind: role
version: v5
metadata:
  name: access-plugin
spec:
  allow:
    rules:
      - resources: ['access_request']
        verbs: ['list', 'read']
      - resources: ['access_plugin_data']
        verbs: ['update']
---
kind: user
metadata:
  name: access-plugin
spec:
  roles: ['access-plugin']
version: v2

Create the user and role:

tctl create -f access-plugin.yaml

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 using tctl from the Auth Service host, you will already have impersonation privileges.

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

kind: role
version: v5
metadata:
  name: access-plugin-impersonator
spec:
  allow:
    impersonate:
      roles:
      - access-plugin
      users:
      - access-plugin

Create the access-plugin-impersonator role:

tctl create -f access-plugin-impersonator.yaml

Retrieve your user definition:

TELEPORT_USER=$(tsh status --format=json | jq -r .active.username)
tctl get users/${TELEPORT_USER?} > myuser.yaml

Edit myuser.yaml to include the role you just created:

  roles:
   - access
   - auditor
   - editor
+  - access-plugin-impersonator

Apply your changes:

tctl create -f myuser.yaml

Log out of your Teleport cluster and log in again. You will now be able to generate signed certificates for the access-plugin role and user.

Step 4/9. Export the access plugin identity

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 for your plugin.

The format of the credentials depends on whether you have set up your network to give the plugin direct access to the Teleport Auth Service, or if all Teleport clients and services connect to the Teleport Proxy Service instead.

Environment type

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=auth.pem

Teleport's Access Request plugins listen for new and updated Access Requests by connecting to the Teleport Auth Service's gRPC endpoint over TLS.

The identity file, auth.pem, includes both TLS and SSH credentials. Your Access Request 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.

You will refer to this file later when configuring the plugin.

If your network allows your plugin to access the Auth Service directly, e.g., you are running the plugin on the Auth Service host, the plugin uses TLS credentials to connect to the Auth Service's gRPC endpoint and listen for new and updated Access Requests.

You can generate TLS credentials with the following command:

tctl auth sign --format=tls --user=access-plugin --out=auth

This command should result in three PEM-encoded files: auth.crt, auth.key, and auth.cas (certificate, private key, and CA certs respectively). Later, you will configure the plugin to use these credentials to connect to the Auth Service directly.

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=auth

Then create a Kubernetes secret:

kubectl create secret generic teleport-mattermost-identity --from-file=auth_id=auth.pem

Teleport's Access Request plugins listen for new and updated Access Requests by connecting to the Teleport Auth Service's gRPC endpoint over TLS.

The identity file, auth.pem, includes both TLS and SSH credentials. Your Access Request 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.

You will refer to this file later when configuring the plugin.

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=auth

Then create a Kubernetes secret:

kubectl create secret generic teleport-mattermost-identity --from-file=auth_id=auth.pem

Teleport's Access Request plugins listen for new and updated Access Requests by connecting to the Teleport Auth Service's gRPC endpoint over TLS.

The identity file, auth.pem, includes both TLS and SSH credentials. Your Access Request 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.

The Helm chart only supports the file format.

You will refer to this file later when configuring the plugin.

Certificate Lifetime

By default, tctl auth sign produces certificates with a relatively short lifetime. For production deployments, you can use the --ttl flag to ensure a more practical certificate lifetime, e.g., --ttl=8760h to export a one-year certificate.

The rest of this guide assumes that you have placed any files generated by this command into /var/lib/teleport/plugins/msteams for later reference when configuring the plugin:

create a data directory to hold certificate files for the plugin.

sudo mkdir -p /var/lib/teleport/plugins/msteams
sudo mv auth.* /var/lib/teleport/plugins/msteams

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

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

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

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 nameReason
AppCatalog.Read.AllUsed to list Teams Apps and check the app is installed.
User.Read.AllUsed to get notification recipients.
TeamsAppInstallation.ReadWriteSelfForUser.AllUsed to initiate communication with a user that never interacted with the Teams App before.
TeamsAppInstallation.ReadWriteSelfForTeam.AllUsed 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

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

Granted App Permissions

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 config file and assets

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.

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/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/msteams/auth_id"    # Identity file
#
# When using --format=tls:
# client_key = "/var/lib/teleport/plugins/msteams/auth.key" # Teleport TLS secret key
# client_crt = "/var/lib/teleport/plugins/msteams/auth.crt" # Teleport TLS certificate
# root_cas = "/var/lib/teleport/plugins/msteams/auth.cas"   # Teleport CA certs
addr = "localhost:3025"
identity = "identity"

[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"
# "*" = ["[email protected]", "admin-msteams-channel"]
"*" = ["[email protected]"]

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

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.

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 config file

Copy 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/.

[teleport]

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

The address and credentials you configure depend on whether your plugin can access the Auth Service directly:

Set addr to the address and port of your Auth Service. This address must be reachable from the Teleport Microsoft Teams Plugin.

Set client_key, client_crt, and root_cas to the identity files generated earlier:

[teleport]
addr = "localhost:3025"
client_key = "/var/lib/teleport/plugins/msteams/auth.key" # Teleport GRPC client secret key
client_crt = "/var/lib/teleport/plugins/msteams/auth.crt" # Teleport GRPC client certificate
root_cas = "/var/lib/teleport/plugins/msteams/auth.cas"   # Teleport cluster CA certs

Set addr to your Proxy Service address with port 443.

Set identity to the identity file generated earlier:

[teleport]
addr = "mytenant.teleport.sh:443"
identity = "/var/lib/teleport/plugins/msteams/auth.pem"

[role_to_recipients]

The role_to_recipients map configure 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.

Here is an example of a role_to_recipients map:

[role_to_recipients]
"*" = "[email protected]"
"dev" = ["[email protected]", "[email protected]"]
"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. The value can be a single string or an array of strings. 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

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 [email protected].

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

tsh request create --roles=dbadmin [email protected],[email protected]

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 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):

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

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

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, searching "TeleBot", selecting it and choosing "Allow".

Upload Teams App

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

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 v10.0.2 go1.18.1

 - Checking application xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx status...
 - Application found in the team app store (internal ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
 - User [email protected] found: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
 - Application installation ID for user: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 - Chat ID for user: 19:xxxxxxxx-x[email protected]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

Create an Access Request

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

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

tctl request create myuser --roles=editor

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

tsh request new --roles=editor

Seeking request approval... (id: 8f77d2d1-2bbf-4031-a300-58926237a807)

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

Creating an Access Request using the Web UI

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

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

Replace REQUEST_ID with the id of the request

tctl request approve REQUEST_ID
tctl request deny REQUEST_ID

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 and access_request.review if reviewing the audit log on the Auth Service host.

Step 9/9. Set up systemd

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 supported by systemd.

Enable and start the plugin:

sudo systemctl enable teleport-msteams
sudo systemctl start teleport-msteams

Next steps

Feedback

If you have any issues with this plugin, please create a GitHub issue in our gravitational/teleport-plugins repo.