title | description |
---|---|
Access Requests with Mattermost |
How to set up Teleport's Mattermost plugin for privilege elevation approvals. |
This guide will explain how to set up Teleport with Mattermost, an open source messaging platform. Teleport's Mattermost 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.
(!docs/pages/includes/commercial-prereqs-tabs.mdx!)
- A Mattermost account with admin privileges. This plugin has been tested with Mattermost v7.0.1.
- Either a Linux host or Kubernetes cluster where you will run the Mattermost plugin.
(!docs/pages/includes/tctl.mdx!)
Before you set up the Mattermost plugin, you will need to enable Role Access Requests in the Proxy or Auth Service.
(!/docs/pages/includes/plugins/editor-request-rbac.mdx!)
<ScopedBlock scope={["enterprise", "oss"]}>
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 both public internet access and Teleport Auth Service access.
Install the Teleport Mattermost plugin on a host that can access both your Teleport Proxy Service and your Mattermost deployment.
```code $ curl -L -O https://get.gravitational.com/teleport-access-mattermost-v(=teleport.plugin.version=)-linux-amd64-bin.tar.gz $ tar -xzf teleport-access-mattermost-v(=teleport.plugin.version=)-linux-amd64-bin.tar.gz $ cd teleport-access-mattermost $ ./install ``` 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/).# Checkout teleport-plugins
$ git clone https://github.com/gravitational/teleport-plugins.git
$ cd teleport-plugins/access/mattermost
$ make
Run ./install
from teleport-mattermost
or place the executable in the appropriate /usr/bin
or /usr/local/bin
on the server installation.
$ docker pull public.ecr.aws/gravitational/teleport-plugin-mattermost:(=teleport.plugin.version=)
(!docs/pages/includes/plugins/rbac.mdx!)
(!docs/pages/includes/plugins/identity-export.mdx!)
Now that you have generated the credentials your plugin needs to connect to your Teleport cluster, register your plugin with Mattermost so it can send Access Request messages to your workspace.
In Mattermost, click the menu button in the upper left of the UI, then click System Console → Integrations → Bot Accounts.
Set "Enable Bot Account Creation" to "true".
This will allow you to create a new bot account for the Mattermost plugin.
Go back to your team. In the menu on the upper left of the UI, click Integrations → Bot Accounts → Add Bot Account.
Set the "Username", "Display Name", and "Description" fields according to how you would like the Mattermost plugin bot to appear in your workspace. Set "Role" to "Member".
You can download our avatar to set as your Bot Icon.
Set "post:all" to "Enabled".
Click "Create Bot Account". We will use the resulting OAuth 2.0 token when we configure the Mattermost plugin.
At this point, you have generated credentials that the Mattermost plugin will use to connect to Teleport and Mattermost. You will now configure the Mattermost plugin to use these credentials and post messages in the right channels for your workspace.
The Mattermost plugin uses a config file in TOML format. On the host where you will run the Mattermost plugin, generate a boilerplate config by running the following commands:$ teleport-mattermost configure > teleport-mattermost.toml
$ sudo mv teleport-mattermost.toml /etc
(!examples/resources/plugins/teleport-mattermost-helm-self.yaml!)
(!examples/resources/plugins/teleport-mattermost-helm-cloud.yaml!)
Edit the configuration as explained below:
addr
: Include the hostname and HTTPS port of your Teleport Proxy Service
(e.g., teleport.example.com:443
). If you are configuring your plugin to
connect directly to the Teleport Auth Service, use your Auth Service's gRPC
endpoint (e.g., teleport.example.com:3025
).
identity
, client_key
, client_crt
, root_cas
: The values
you will use for these fields depend on whether the Mattermost plugin will
connect to the Proxy Service or the Auth Service.
If you exported an identity file earlier, fill in the identity
field with the
path to the file and comment out the other fields.
If you exported a client key, client certificate, and root CAs earlier, fill in
the client_key
, client_crt
, and root_cas
fields with the paths to these
files and leave identity
commented out.
addr
: Include the hostname and HTTPS port of your Teleport Cloud tenant
(e.g., teleport.example.com:443
).
identity
, client_key
, client_crt
, root_cas
: Fill in the
identity
field with the path to the identity file you exported earlier and
comment out the other fields.
address
: Include the hostname and HTTPS port of your Teleport Cloud tenant
(e.g., teleport.example.com:443
).
identitySecretName
: Fill in the identitySecretName
field with the name
of the Kubernetes secret you created earlier.
address
: Include the hostname and HTTPS port of your Teleport Cloud tenant
(e.g., teleport.example.com:443
).
identitySecretName
: Fill in the identitySecretName
field with the name
of the Kubernetes secret you created earlier.
url
: Include the scheme (https://
) and fully qualified domain name of
your Mattermost deployment.
token
: Find your Mattermost bot's OAuth 2.0 token. To do so, visit
Mattermost. In the menu on the upper left of the UI, go to Integrations → Bot
Accounts. Find the listing for the Teleport plugin and click "Create New Token".
After you save the token, you will see a message with text in the format,
"Access Token: TOKEN". Copy the token and paste it here.
recipients
: This field configures the channels that the Mattermost plugin
will notify when it receives an Access Request message. The value is an array of
strings, where each element is either:
- The email address of a Mattermost user to notify via a direct message when the plugin receives an Access Request event
- A channel name in the format
team/channel
, where/
separates the name of the team and the name of the channel
For example, this configuration will notify [email protected]
and
the Town Square
channel in the myteam
team of any Access Request events:
recipients = [
"myteam/Town Square",
"[email protected]"
]
url
: Include the scheme (https://
) and fully qualified domain name of
your Mattermost deployment.
token
: Find your Mattermost bot's OAuth 2.0 token. To do so, visit
Mattermost. In the menu on the upper left of the UI, go to Integrations → Bot
Accounts. Find the listing for the Teleport plugin and click "Create New Token".
After you save the token, you will see a message with text in the format,
"Access Token: TOKEN". Copy the token and paste it here.
recipients
: This field configures the channels that the Mattermost plugin
will notify when it receives an Access Request message. The value is an array of
strings, where each element is either:
- The email address of a Mattermost user to notify via a direct message when the plugin receives an Access Request event
- A channel name in the format
team/channel
, where/
separates the name of the team and the name of the channel
For example, this configuration will notify [email protected]
and
the Town Square
channel in the myteam
team of any Access Request events:
recipients:
- "myteam/Town Square"
- [email protected]
You will need to invite your Teleport plugin to any channel you add to the
recipients
list (aside from direct message channels). Visit Mattermost,
navigate to each channel you want to invite the plugin to, and enter /invite @teleport
(or the name of the bot you configured) into the message box.
Users can also 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 Mattermost 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.
If recipients
is empty, and the user requesting elevated privileges has not
suggested any reviewers, the plugin will skip forwarding the Access Request to
Mattermost.
The final configuration should look similar to this:
```yaml # example mattermost configuration TOML file [teleport] auth_server = "myinstance.teleport.sh:443" # Teleport Cloud proxy HTTPS address identity = "/var/lib/teleport/plugins/mattermost/auth.pem" # Identity file path[mattermost] url = "https://mattermost.example.com" # Mattermost Server URL token = "api-token" # Mattermost Bot OAuth token recipients = [ "myteam/general", "[email protected]" ]
[log] output = "stderr" # Logger output. Could be "stdout", "stderr" or "/var/lib/teleport/mattermost.log" severity = "INFO" # Logger severity. Could be "INFO", "ERROR", "DEBUG" or "WARN".
</TabItem>
<TabItem scopes={["oss", "enterprise"]} label="Connect to the Auth Service" options="Executable">
```yaml
# example mattermost configuration TOML file
[teleport]
auth_server = "example.com:3025" # Teleport Auth Server GRPC API address
client_key = "/var/lib/teleport/plugins/mattermost/auth.key" # Teleport GRPC client secret key
client_crt = "/var/lib/teleport/plugins/mattermost/auth.crt" # Teleport GRPC client certificate
root_cas = "/var/lib/teleport/plugins/mattermost/auth.cas" # Teleport cluster CA certs
[mattermost]
url = "https://mattermost.example.com" # Mattermost Server URL
token = "api-token" # Mattermost Bot OAuth token
recipients = [
"myteam/general",
"[email protected]"
]
[log]
output = "stderr" # Logger output. Could be "stdout", "stderr" or "/var/lib/teleport/mattermost.log"
severity = "INFO" # Logger severity. Could be "INFO", "ERROR", "DEBUG" or "WARN".
$ teleport-mattermost start -d
The -d
flag provides debug information to make sure the bot can connect to
Mattermost, e.g.:
DEBU Checking Teleport server version mattermost/main.go:234
DEBU Starting a request watcher... mattermost/main.go:296
DEBU Starting Mattermost API health check... mattermost/main.go:186
DEBU Starting secure HTTPS server on :8081 utils/http.go:146
DEBU Watcher connected mattermost/main.go:260
DEBU Mattermost API health check finished ok mattermost/main.go:19
$ helm upgrade --install teleport-plugin-mattermost teleport/teleport-plugin-mattermost --values teleport-mattermost-helm.yaml
To inspect the plugin's logs, use the following command:
$ kubectl logs deploy/teleport-plugin-mattermost
Debug logs can be enabled by setting log.severity
to DEBUG
in
teleport-mattermost-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-mattermost
(!docs/pages/includes/plugins/create-request.mdx!)
The users and channels you configured earlier to review the request should receive a message from "Teleport" in Mattermost allowing them to visit a link in the Teleport Web UI and either approve or deny the request.
(!docs/pages/includes/plugins/resolve-request.mdx!)
When the Mattermost 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 <ScopedBlock scope={["oss",
"enterprise"]}>and access_request.review
if reviewing the audit log on the
Auth Service 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:
(!examples/systemd/plugins/teleport-mattermost.service!)
Save this as teleport-mattermost.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-mattermost
$ sudo systemctl start teleport-mattermost
If you have any issues with this plugin, please create an issue on GitHub.