Slack 접근 요청 플러그인 실행
이 가이드는 Teleport에서 접근 요청 메시지를 받도록 Slack을 설정하는 방법을 설명합니다. In Teleport Enterprise Cloud, Teleport manages the Slack integration for you, and you can enroll the Slack integration from the Teleport Web UI.
이 가이드는 Teleport에서 접근 요청 메시지를 받도록 Slack을 설정하는 방법을 설명합니다.
이 통합은 Teleport Cloud에서 호스팅됩니다
In Teleport Enterprise Cloud, Teleport manages the Slack integration for you, and you can enroll the Slack 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의 Slack 통합은 개인 및 채널에 접근 요청을 알립니다. 사용자는 접근 요청을 승인하거나 거부할 수 있는 Teleport 클러스터에 로그인하도록 안내되어, 생산성을 저해하지 않고 보안 모범 사례를 구현하는 것이 더 쉬워집니다.

다음은 Teleport의 Slack 플러그인을 통해 접근 요청을 전송하는 예시입니다:
전제 조건#
-
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.
- 앱을 만들고 워크스페이스에 설치할 Slack 관리자 권한. Slack 프로필에 프로필 사진 아래 "Workspace Owner" 또는 "Workspace Admin" 배너가 있어야 합니다.
- Slack 플러그인을 실행할 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 리소스 정의#
Slack 플러그인을 설정하기 전에 Teleport 클러스터에서 역할 접근 요청을 활성화해야 합니다.
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 Slack 플러그인 사용자 정의#
플러그인에 필요한 권한은 프리셋 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단계. 접근 플러그인 아이덴티티 내보내기#
플러그인에 Teleport 아이덴티티 파일 접근 권한을 부여합니다. 유출되더라도 위험이 적은 단기 아이덴티티 파일을 생성하기 위해 Machine ID를 사용하는 것을 권장하지만, 데모 배포에서는 tctl로 더 오래 지속되는 아이덴티티 파일을 생성할 수 있습니다:
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-slack-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-slack-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-slack-identity
Once the Teleport credentials expire, you will need to renew them by running the
tctl auth sign command again.
4/8단계. Teleport Slack 플러그인 설치#
5/8단계. Slack 앱 등록#
Slack용 접근 요청 플러그인은 Teleport Auth Service에서 접근 요청 이벤트를 받아 이를 Slack 메시지로 형식화하고 Slack API로 전송하여 워크스페이스에 게시합니다. 이 작동을 위해 Slack API에 새 앱을 등록해야 합니다.
앱 만들기#
https://api.slack.com/apps를 방문하여 새 Slack 앱을 만듭니다. "Create an App"을 클릭한 다음 "From scratch"를 클릭합니다. 아래와 같이 양식을 작성합니다:

"App Name"은 "Teleport"여야 합니다. "Development Slack Workspace" 드롭다운을 클릭하고 접근 요청 메시지를 보고 싶은 워크스페이스를 선택합니다.
스코프가 있는 OAuth 토큰 생성#
다음으로 Slack API에 인증하도록 애플리케이션을 구성합니다. 플러그인이 Slack API에 제시할 OAuth 토큰을 생성하여 이 작업을 수행합니다.
OAuth 스코프를 사용하여 플러그인을 가능한 좁은 권한으로 제한합니다. Slack 플러그인은 워크스페이스에 메시지를 게시해야 합니다. 또한 Auth Service에서 적절한 Teleport 사용자에게 접근 요청 알림을 보내기 위해 사용자 이름과 이메일 주소를 읽어야 합니다.
앱을 만든 후 Slack 웹사이트에서 구성 옵션을 지정할 수 있는 콘솔이 열립니다. "Features" 아래 사이드바 메뉴에서 "OAuth & Permissions"을 클릭합니다.
"Scopes" 섹션으로 스크롤하고 다음 각 스코프에 대해 "Add an OAuth Scope"를 클릭합니다:
chat:writeincoming-webhookusers:readusers:read.email
결과는 다음과 같아야 합니다:

플러그인에 대한 스코프를 구성한 후 OAuth & Permissions 페이지 상단으로 스크롤하여 "OAuth Tokens for Your Workspace" 섹션을 찾고 "Install to Workspace"를 클릭합니다. 이전에 Slack 플러그인에 대해 구성한 권한 요약이 표시됩니다.
"Where should Teleport post?"에서 플러그인이 게시할 기본 채널로 "Slackbot"을 선택합니다. 플러그인은 직접 메시지를 보낼 때 여기에 게시합니다. 이 가이드 후반에 플러그인이 다른 채널에도 게시하도록 구성합니다.
이 양식을 제출하면 "Tokens for Your Workspace" 아래 "OAuth & Permissions" 탭에서 OAuth 토큰을 볼 수 있습니다:

이 토큰은 Slack 플러그인을 구성할 때 나중에 사용합니다.
6/8단계. Teleport Slack 플러그인 구성#
이 시점에서 Teleport Slack 플러그인은 Teleport 클러스터와 Slack API와 통신하는 데 필요한 자격 증명을 가지고 있습니다. 이 단계에서는 이러한 자격 증명을 사용하도록 Slack 플러그인을 구성합니다. 또한 접근 요청 업데이트를 받을 때 올바른 Slack 채널에 알리도록 플러그인을 구성합니다.
구성 파일 만들기#
Teleport Slack 플러그인은 TOML 형식의 구성 파일을 사용합니다. 다음 명령을 실행하여 기본 구성을 생성합니다(플러그인은 구성 파일이 /etc/teleport-slack.toml에 있지 않으면 실행되지 않습니다):
$ teleport-slack configure | sudo tee /etc/teleport-slack.toml > /dev/null
결과는 아래와 같은 구성 파일이어야 합니다:
<div class="admonition note"><div class="admonition-title">Note</div><p>이 섹션의 내용은 원문 문서를 참조하세요. (<code>teleport-slack.toml</code>)</p></div>
Slack Helm Chart는 YAML 값 파일을 사용하여 플러그인을 구성합니다.
로컬 워크스테이션에서 다음 예시를 기반으로 teleport-slack-helm.yaml 파일을 만듭니다:
<div class="admonition note"><div class="admonition-title">Note</div><p>이 섹션의 내용은 원문 문서를 참조하세요. (<code>teleport-slack-helm.yaml</code>)</p></div>
구성 파일 편집#
Teleport Slack 플러그인에 대해 만들어진 구성 파일을 열고 다음 필드를 업데이트합니다:
[teleport]
Slack 플러그인은 이 섹션을 사용하여 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
[slack]
token: https://api.slack.com/apps를 열고, 이전에 만든 Slack 앱을 찾아 "OAuth & Permissions" 탭으로 이동하여 "Bot User OAuth Token"을 복사하고 이 필드에 붙여넣습니다.
[role_to_recipients]
role_to_recipients 맵은 사용자가 특정 역할에 대한 접근을 요청할 때 Slack 플러그인이 알릴 채널을 구성합니다. Slack 플러그인이 Auth Service에서 접근 요청을 받으면 요청된 역할을 조회하고 알릴 Slack 채널을 식별합니다.
다음은 role_to_recipients 맵의 예시입니다. 각 값은 단일 문자열 또는 문자열 배열일 수 있습니다:
[role_to_recipients]
"*" = "admin-slack-channel"
"dev" = ["dev-slack-channel", "admin-slack-channel"]
"dba" = "alex@gmail.com"
Helm Chart에서 role_to_recipients 필드는 roleToRecipients라고 하며 키는 문자열이고 값은 문자열 배열인 다음 형식을 사용합니다:
roleToRecipients:
"*": ["admin-slack-channel"]
"dev":
- "dev-slack-channel"
- "admin-slack-channel"
"dba": ["alex@gmail.com"]
role_to_recipients 맵에서 각 키는 Teleport 역할 이름입니다. 각 값은 알릴 Slack 채널(또는 채널들)을 구성합니다. 각 문자열은 Slack 채널 이름(사용자의 직접 메시지 채널 포함) 또는 Slack 사용자의 이메일 주소여야 합니다. 수신자가 이메일 주소인 경우 Slack 플러그인은 해당 이메일 주소를 사용하여 직접 메시지 채널을 조회합니다.
role_to_recipients 맵에는 "*" 항목도 포함되어야 합니다. 주어진 역할 이름과 일치하는 다른 항목이 없는 경우 플러그인이 이를 조회합니다. 위의 예에서 dev와 dba 외의 역할 요청은 admin-slack-channel 채널에 알립니다.
제안된 검토자
사용자는 접근 요청을 만들 때 검토자를 제안할 수 있습니다:
$ tsh request create --roles=dbadmin --reviewers=alice@example.com,ivan@example.com
접근 요청에 제안된 검토자가 포함된 경우 Slack 플러그인은 이를 알릴 채널 목록에 추가합니다. 제안된 검토자가 이메일 주소인 경우 플러그인은 해당 주소의 직접 메시지 채널을 조회하여 해당 채널에 메시지를 게시합니다.
role_to_recipients 구성에 다음을 추가하여 사용자가 editor 역할을 요청할 때 알리도록 Slack 플러그인을 구성합니다(TELEPORT_USERNAME을 이전에 editor-reviewer 역할을 할당한 사용자로 교체):
[role_to_recipients]
"*" = "access-requests"
"editor" = "TELEPORT_USERNAME"
roleToRecipients:
"*": "access-requests"
"editor": "TELEPORT_USERNAME"
Slack 워크스페이스에 access-requests 채널을 만들거나 "*" 키의 값을 기존 채널로 변경합니다.
Slack 앱 초대#
접근 요청을 받을 때 Slack 플러그인이 알릴 채널을 구성한 후 플러그인이 해당 채널에 게시할 수 있도록 해야 합니다.
이미 플러그인이 Slackbot으로 직접 메시지를 보내도록 구성했습니다. role_to_recipients 맵에 언급된 다른 채널의 경우 해당 채널에 플러그인을 초대해야 합니다. 각 채널로 이동하여 메시지 상자에 /invite @teleport를 입력합니다.
7/8단계. Slack 앱 테스트#
Teleport가 실행 중이고 Slack 앱을 만들었으며 플러그인이 구성된 후 플러그인을 실행하고 워크플로를 테스트할 수 있습니다.
플러그인을 시작합니다:
$ teleport-slack start
모든 것이 정상적으로 작동하면 로그 출력은 다음과 같아야 합니다:
$ teleport-slack start
INFO Starting Teleport Access Slack Plugin 7.2.1: slack/app.go:80
INFO Plugin is ready slack/app.go:101
플러그인을 실행합니다:
$ docker run -v <path-to-config>:/etc/teleport-slack.toml public.ecr.aws/gravitational/teleport-plugin-slack:(=teleport.version=) start
플러그인을 설치합니다:
$ helm upgrade --install teleport-plugin-slack teleport/teleport-plugin-slack --values teleport-slack-helm.yaml
플러그인 로그를 확인하려면 다음 명령을 사용합니다:
$ kubectl logs deploy/teleport-plugin-slack
teleport-slack-helm.yaml에서 log.severity를 DEBUG로 설정하고 위의 helm upgrade ... 명령을 다시 실행하여 디버그 로그를 활성화할 수 있습니다. 그런 다음 다음 명령으로 플러그인을 재시작할 수 있습니다:
$ kubectl rollout restart deployment teleport-plugin-slack
다음 단계에 따라 접근 요청을 만들고 플러그인이 예상대로 작동하는지 확인합니다.
접근 요청 만들기#
이전에 요청을 검토하도록 구성한 사용자는 Slack에서 "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:
요청이 해결되면 Slack 봇은 요청이 승인되었는지 거부되었는지에 따라 접근 요청의 Slack 메시지에 ✅ 또는 ❌ 이모지 반응을 추가합니다.
Slack 플러그인이 채널에 접근 요청 알림을 게시하면 채널에 접근할 수 있는 누구든지 알림을 보고 링크를 따라갈 수 있습니다. 사용자가 접근 요청을 검토하려면 Teleport 역할을 통해 권한이 부여되어야 하지만, 올바른 사용자가 올바른 요청을 검토하고 있는지 확인하기 위해 Teleport 감사 로그를 확인해야 합니다.
접근 요청 검토를 감사할 때 Teleport Web UI에서 Access Request Reviewed 유형의 이벤트를 확인합니다.
8/8단계. systemd 설정#
이 섹션은 Linux 호스트에서 Teleport Slack 플러그인을 실행하는 경우에만 관련이 있습니다.
프로덕션에서는 systemd와 같은 init 시스템을 통해 Teleport 플러그인 데몬을 시작하는 것이 좋습니다. 다음은 systemd용 권장 Teleport 플러그인 서비스 유닛 파일입니다:
<div class="admonition note"><div class="admonition-title">Note</div><p>이 섹션의 내용은 원문 문서를 참조하세요. (<code>teleport-slack.service</code>)</p></div>
이 파일을 /usr/lib/systemd/system/ 또는 systemd에서 지원하는 다른 유닛 파일 로드 경로에 teleport-slack.service로 저장합니다.
플러그인을 활성화하고 시작합니다:
$ sudo systemctl enable teleport-slack
$ sudo systemctl start teleport-slack
문제 해결#
이 섹션의 내용은 원문 문서를 참조하세요. (access-plugin-troubleshooting.mdx)
