Mattermost Access Request 플러그인 실행
이 가이드는 오픈 소스 메시징 플랫폼인 Mattermost와 Access Request를 통합하는 방법을 설명합니다. In Teleport Enterprise Cloud, Teleport manages the Mattermost integration for you, and you can enroll the Mattermost integration from the Teleport ...
이 가이드는 오픈 소스 메시징 플랫폼인 Mattermost와 Access Request를 통합하는 방법을 설명합니다.
이 통합은 Teleport Cloud에서 호스팅됩니다
In Teleport Enterprise Cloud, Teleport manages the Mattermost integration for you, and you can enroll the Mattermost integration from the Teleport Web UI.
Visit the Teleport Web UI and on the left sidebar, click Add New followed by Integration:

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.
작동 방식#
Teleport Mattermost 플러그인은 개인에게 Access Request를 알립니다. 사용자는 메시지 링크를 따라 Access Request를 승인하거나 거부할 수 있으므로, 생산성을 저해하지 않으면서 보안 모범 사례를 더 쉽게 구현할 수 있습니다.

사전 요구사항#
-
A running Teleport Enterprise cluster. If you want to get started with Teleport, sign up for a free trial or set up a demo environment.
-
The
tctlandtshclients.Installing `tctl` and `tsh` clients
-
Determine the version of your Teleport cluster. The
tctlandtshclients must be at most one major version behind your Teleport cluster version. Send a GET request to the Proxy Service at/v1/webapi/findand use a JSON query tool to obtain your cluster version. Replace with the web address of your Teleport Proxy Service:$ TELEPORT_DOMAIN= $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')" -
Follow the instructions for your platform to install
tctlandtshclients:
-
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
to run the tbot binary on your infrastructure.
- 관리자 권한이 있는 Mattermost 계정. 이 플러그인은 Mattermost v7.0.1과 테스트되었습니다.
- Teleport Mattermost 플러그인을 실행할 Linux 호스트 또는 Kubernetes 클러스터.
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 to the domain name of the Teleport Proxy Service in your cluster and to your Teleport username:
$ tsh login --proxy= --user=
$ tctl status
# Cluster (=teleport.url=)
# Version (=teleport.version=)
# CA pin (=presets.ca_pin=)
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.
1/8단계. RBAC 리소스 정의#
Mattermost 플러그인을 설정하기 전에, Teleport 클러스터에서 Role Access Request를 활성화해야 합니다.
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
(!docs/pages/includes/create-role-using-web.mdx!)
Allow yourself to review requests by users with the editor-requester role by
assigning yourself the editor-reviewer role.
(!docs/pages/includes/add-role-to-user.mdx role="editor-reviewer"!)
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.
2/8단계. Teleport Mattermost 플러그인 사용자 정의#
플러그인에 필요한 권한은 사전 설정된 access-plugin 역할에 구성되어 있습니다. 플러그인에 대한 자격 증명을 생성하려면, Machine ID 봇 사용자 또는 일반 Teleport 사용자를 정의합니다.
If you haven't set up a Machine ID bot yet, refer to the
deployment guide
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
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
(!docs/pages/includes/create-role-using-web.mdx!)
Assign this role to the user you plan to use to generate credentials for the
access-plugin role and user:
(!docs/pages/includes/add-role-to-user.mdx role="access-plugin-impersonator"!)
You will now be able to generate signed certificates for the access-plugin
role and user.
3/8단계. 액세스 플러그인 ID 내보내기#
플러그인에 Teleport ID 파일 접근 권한을 부여합니다. 유출 시 위험도가 낮은 단기 ID 파일을 생성하기 위해 Machine ID를 사용하는 것을 권장하지만, 데모 배포에서는 tctl로 장기 ID 파일을 생성할 수 있습니다:
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-mattermost-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-mattermost-identity. This contains the private key and signed
certificates needed by the plugin to authenticate with the Teleport Auth
Service.
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 to programmatically issue and renew
certificates for your plugin. See our Machine & Workload Identity getting started
guide 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-mattermost-identity
Once the Teleport credentials expire, you will need to renew them by running the
tctl auth sign command again.
4/8단계. Teleport Mattermost 플러그인 설치#
Teleport 플러그인은 메모리 사용량이 적고 공개 인터넷 접근과 Teleport Auth Service 접근이 모두 필요하므로, Teleport Proxy Service와 동일한 호스트에 설치하는 것을 권장합니다.
Teleport Proxy Service와 Mattermost 배포 모두에 접근할 수 있는 호스트에 Teleport Mattermost 플러그인을 설치합니다.
5/8단계. Mattermost 봇 등록#
이제 플러그인이 Teleport 클러스터에 연결하는 데 필요한 자격 증명을 생성했으므로, 플러그인을 Mattermost에 등록하여 워크스페이스에 Access Request 메시지를 보낼 수 있도록 합니다.
Mattermost에서 UI 왼쪽 상단의 메뉴 버튼을 클릭한 다음 시스템 콘솔 → 통합 → 봇 계정을 클릭합니다.
"봇 계정 생성 활성화"를 "true"로 설정합니다.

이렇게 하면 Mattermost 플러그인을 위한 새 봇 계정을 생성할 수 있습니다.
팀으로 돌아갑니다. UI 왼쪽 상단의 메뉴에서 통합 → 봇 계정 → 봇 계정 추가를 클릭합니다.
Mattermost 플러그인 봇이 워크스페이스에 표시되길 원하는 방식에 따라 "사용자 이름", "표시 이름" 및 "설명" 필드를 설정합니다. "역할"을 "구성원"으로 설정합니다.
봇 아이콘으로 설정할 아바타를 다운로드할 수 있습니다.
"post:all"을 "활성화"로 설정합니다.

"봇 계정 생성"을 클릭합니다. 결과로 생성된 OAuth 2.0 토큰은 Mattermost 플러그인을 설정할 때 사용합니다.
6/8단계. Mattermost 플러그인 설정#
이 시점에서 Mattermost 플러그인이 Teleport와 Mattermost에 연결하는 데 사용할 자격 증명을 생성했습니다. 이제 이 자격 증명을 사용하고 워크스페이스에 적합한 채널에 메시지를 게시하도록 Mattermost 플러그인을 설정합니다.
Mattermost 플러그인은 TOML 형식의 설정 파일을 사용합니다. Mattermost 플러그인을 실행할 호스트에서 다음 명령을 실행하여 기본 설정을 생성합니다:
$ teleport-mattermost configure > teleport-mattermost.toml
$ sudo mv teleport-mattermost.toml /etc
Mattermost Helm Chart는 플러그인을 설정하기 위해 YAML 값 파일을 사용합니다. Helm이 설치된 호스트에서 다음 예시를 기반으로 teleport-mattermost-helm.yaml 파일을 생성합니다:
<div class="admonition note"><div class="admonition-title">Note</div><p>이 섹션의 내용은 원문 문서를 참조하세요. (<code>teleport-mattermost-helm-cloud.yaml</code>)</p></div>
아래 설명에 따라 설정을 편집합니다:
[teleport]#
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
[mattermost]#
url: Mattermost 배포의 스킴(https://)과 완전한 도메인 이름을 포함합니다.
token: Mattermost 봇의 OAuth 2.0 토큰을 찾습니다. 이를 위해 Mattermost를 방문합니다. UI 왼쪽 상단 메뉴에서 통합 → 봇 계정으로 이동합니다. Teleport 플러그인 목록을 찾아 "새 토큰 생성"을 클릭합니다. 토큰을 저장하면 "액세스 토큰: TOKEN" 형식의 텍스트가 있는 메시지가 표시됩니다. 토큰을 복사하여 여기에 붙여넣습니다.
recipients: 이 필드는 Mattermost 플러그인이 Access Request 메시지를 수신할 때 알릴 채널을 설정합니다. 값은 문자열 배열이며, 각 요소는 다음 중 하나입니다:
- 플러그인이 Access Request 이벤트를 수신할 때 직접 메시지로 알릴 Mattermost 사용자의 이메일 주소
team/channel형식의 채널 이름. 여기서/는 팀 이름과 채널 이름을 구분합니다
예를 들어 이 설정은 Access Request 이벤트가 있을 때 first.last@example.com과 myteam 팀의 Town Square 채널에 알림을 보냅니다:
recipients = [
"myteam/Town Square",
"first.last@example.com"
]
recipients:
- "myteam/Town Square"
- first.last@example.com
recipients 목록에 추가하는 모든 채널(직접 메시지 채널 제외)에 Teleport 플러그인을 초대해야 합니다. Mattermost를 방문하여 플러그인을 초대할 각 채널로 이동하고 메시지 박스에 /invite @teleport(또는 설정한 봇 이름)를 입력합니다.

제안된 검토자
사용자는 Access Request를 생성할 때 검토자를 제안할 수도 있습니다. 예를 들어:
$ tsh request create --roles=dbadmin --reviewers=alice@example.com,ivan@example.com
Access Request에 제안된 검토자가 포함된 경우, Mattermost 플러그인은 이들을 알릴 채널 목록에 추가합니다. 제안된 검토자가 이메일 주소인 경우, 플러그인은 해당 주소의 직접 메시지 채널을 조회하고 해당 채널에 메시지를 게시합니다.
recipients가 비어 있고 상승된 권한을 요청하는 사용자가 검토자를 제안하지 않은 경우, 플러그인은 Mattermost로 Access Request 전달을 건너뜁니다.
최종 설정은 다음과 유사해야 합니다:
# 예시 mattermost 설정 TOML 파일
[teleport]
auth_server = "myinstance.teleport.sh:443" # Teleport Cloud 프록시 HTTPS 주소
identity = "/var/lib/teleport/plugins/mattermost/identity" # ID 파일 경로
refresh_identity = true # 주기적으로 ID 파일 갱신
[mattermost]
url = "https://mattermost.example.com" # Mattermost 서버 URL
token = "api-token" # Mattermost 봇 OAuth 토큰
recipients = [
"myteam/general",
"first.last@example.com"
]
[log]
output = "stderr" # 로거 출력. "stdout", "stderr" 또는 "/var/lib/teleport/mattermost.log"가 될 수 있습니다
severity = "INFO" # 로거 심각도. "INFO", "ERROR", "DEBUG" 또는 "WARN"이 될 수 있습니다.
<div class="admonition note"><div class="admonition-title">Note</div><p>이 섹션의 내용은 원문 문서를 참조하세요. (<code>teleport-mattermost-helm-cloud.yaml</code>)</p></div>
7/8단계. Mattermost 봇 테스트#
설정을 수정한 후, 다음 명령으로 봇을 실행합니다:
$ teleport-mattermost start -d
-d 플래그는 봇이 Mattermost에 연결할 수 있는지 확인하기 위한 디버그 정보를 제공합니다. 예를 들어:
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
플러그인 실행:
$ docker run -v <path-to-config>:/etc/teleport-mattermost.toml public.ecr.aws/gravitational/teleport-plugin-mattermost:(=teleport.version=) start
설정을 수정한 후, 다음 명령으로 봇을 실행합니다:
$ helm upgrade --install teleport-plugin-mattermost teleport/teleport-plugin-mattermost --values teleport-mattermost-helm.yaml
플러그인의 로그를 검사하려면, 다음 명령을 사용합니다:
$ kubectl logs deploy/teleport-plugin-mattermost
teleport-mattermost-helm.yaml에서 log.severity를 DEBUG로 설정하고 위의 helm upgrade ... 명령을 다시 실행하여 디버그 로그를 활성화할 수 있습니다. 그런 다음 다음 명령으로 플러그인을 재시작할 수 있습니다:
$ kubectl rollout restart deployment teleport-plugin-mattermost
Access Request 생성#
요청을 검토하도록 이전에 설정한 사용자와 채널은 Mattermost에서 "Teleport"로부터 Teleport Web UI의 링크를 방문하여 요청을 승인하거나 거부할 수 있는 메시지를 받아야 합니다.
요청 해결#
Once you receive an Access Request message, click the link to visit Teleport and approve or deny the request:

Reviewing from the command line
You can also review an Access Request from the command line:
Mattermost 플러그인이 채널에 Access Request 알림을 게시하면, 채널에 접근할 수 있는 모든 사람이 알림을 보고 링크를 따라갈 수 있습니다. 사용자가 Teleport 역할을 통해 Access Request를 검토하도록 권한을 받아야 하지만, 올바른 사용자가 올바른 요청을 검토하고 있는지 확인하기 위해 Teleport 감사 로그를 확인해야 합니다.
Access Request 검토를 감사할 때, Teleport Web UI에서 Access Request Reviewed 유형의 이벤트를 확인합니다.
8/8단계. systemd 설정#
이 섹션은 Linux 호스트에서 Teleport Mattermost 플러그인을 실행하는 경우에만 해당됩니다.
프로덕션 환경에서는 systemd와 같은 init 시스템을 통해 Teleport 플러그인 데몬을 시작하는 것을 권장합니다. systemd를 위한 권장 Teleport 플러그인 서비스 유닛 파일은 다음과 같습니다:
<div class="admonition note"><div class="admonition-title">Note</div><p>이 섹션의 내용은 원문 문서를 참조하세요. (<code>teleport-mattermost.service</code>)</p></div>
이를 /usr/lib/systemd/system/ 또는 systemd가 지원하는 다른 유닛 파일 로드 경로에 teleport-mattermost.service로 저장합니다.
플러그인을 활성화하고 시작합니다:
$ sudo systemctl enable teleport-mattermost
$ sudo systemctl start teleport-mattermost
문제 해결#
이 섹션의 내용은 원문 문서를 참조하세요. (access-plugin-troubleshooting.mdx)
