Teleport의 SAML 공급자를 사용하여 Grafana 인증하기
Grafana는 오픈 소스 관측성 플랫폼입니다. Teleport는 Teleport App Service 뒤에서 실행되는 서비스뿐만 아니라 SAML 호환 서비스에 대한 ID 공급자로 작동할 수 있습니다. Grafana를 통해 사용자는 SAML을 사용하여 인증할 수 있습니다.
Grafana는 오픈 소스 관측성 플랫폼입니다. 엔터프라이즈 버전은 SAML 인증을 지원합니다. 이 가이드는 Teleport를 SAML 공급자로 설정하고, Grafana가 Teleport가 제공하는 ID를 수용하도록 설정하는 방법을 안내합니다.
Teleport는 Teleport App Service 뒤에서 실행되는 서비스뿐만 아니라 SAML 호환 서비스에 대한 ID 공급자로 작동할 수 있습니다.
작동 방식#
Grafana를 통해 사용자는 SAML을 사용하여 인증할 수 있습니다. Teleport에서 SAML IdP 메타데이터를 내보낸 다음, Grafana 설정 파일에 제공하여 Grafana가 Teleport IdP의 인증 기관을 신뢰하도록 지시할 수 있습니다. 그런 다음 Teleport 클러스터는 SAML IdP 서비스 프로바이더 리소스를 사용하여 Teleport SAML IdP에 Grafana 배포에 대한 정보를 제공합니다.
사전 요구사항#
grafana.ini에 편집 접근 권한이 있는 Grafana Enterprise 인스턴스.- SAML 연결을 위한 TLS 인증서/키를 생성할 신뢰할 수 있는 인증 기관.
-
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:
-
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/3단계. SAML 서비스 프로바이더 객체 접근을 위한 Teleport 역할 설정#
먼저, saml_idp_service_provider 객체를 읽고 수정할 수 있는 권한이 있는 사용자로 Teleport에 로그인했는지 확인해야 합니다. 기본 editor 역할에는 이미 이 접근 권한이 있지만, 더 맞춤화된 설정을 사용하는 경우 다음 내용으로 sp-manager.yaml이라는 역할을 생성합니다:
kind: role
version: v7
metadata:
name: sp-manager
spec:
allow:
rules:
- resources: [saml_idp_service_provider]
verbs: [list, create, read, update, delete]
tctl로 생성합니다:
$ tctl create sp-manager.yaml
role 'sp-manager' has been created
Assign the saml_idp_service_provider role to your Teleport user by running the appropriate
commands for your authentication provider:
2/3단계. Teleport ID 공급자를 인식하도록 Grafana 설정#
Grafana SSO 설정의 첫 번째 단계는 Teleport의 SAML ID 공급자 메타데이터를 가져오는 것입니다. https://<proxy-address>/enterprise/saml-idp/metadata로 이동하여 이 메타데이터를 XML 형식으로 얻을 수 있습니다. teleport-metadata.xml과 같이 기억하기 쉬운 파일 이름으로 저장합니다.
Grafana 설정에 제공하기 위해 base64를 사용하여 메타데이터를 인코딩합니다:
$ cat teleport-metadata.xml | base64
Grafana 호스트에서 [auth.saml] 섹션을 추가하여 grafana.ini를 편집합니다:
[auth.saml]
enabled = true
auto_login = false
allow_idp_initiated = true
relay_state = ""
private_key_path = '/path/to/certs/grafana-host-key.pem'
certificate_path = '/path/to/certs/grafana-host.pem'
idp_metadata = 'PEVudGl0eURl.....'
assertion_attribute_name = uid
assertion_attribute_login = uid
assertion_attribute_email = uid
assertion_attribute_groups = eduPersonAffiliation
| 키 | 값 |
|---|---|
enabled |
SAML 인증을 활성화하려면 true로 설정합니다. |
auto_login |
true로 설정하면 SAML을 사용한 자동 로그인이 활성화됩니다. |
allow_idp_initiated |
IdP 시작 로그인을 허용하려면 true로 설정합니다. |
relay_state |
IdP 시작 로그인의 릴레이 상태. Teleport IdP와 함께 작동하려면 ""로 설정해야 합니다. |
private_key_path |
Grafana를 식별하는 데 사용되는 TLS 키 경로. |
certificate_path |
Grafana를 식별하는 데 사용되는 TLS 인증서 경로. |
idp_metadata |
Teleport 메타데이터 XML 파일의 base64로 인코딩된 내용. |
assertion_* |
SAML 어설션에 매핑될 다양한 Grafana 사용자 필드. |
SAML을 위한 grafana.ini 편집에 대한 자세한 내용은 Grafana의 Grafana에서 SAML 인증 설정 페이지를 확인할 수 있습니다.
3/3단계. Teleport에 서비스 프로바이더 메타데이터 추가#
편집된 설정으로 Grafana를 다시 시작한 후, /saml/metadata 경로에서 Grafana의 SAML 메타데이터를 다운로드합니다. entity_descriptor 값으로 다운로드한 메타데이터를 사용하여 이 서비스 프로바이더를 정의하는 grafana-sp.yaml 파일을 생성합니다:
kind: saml_idp_service_provider
metadata:
# 서비스 프로바이더의 친숙한 이름. 서비스 프로바이더 관리 및
# ID 공급자 시작 SSO에서 사용됩니다.
name: saml-grafana
spec:
# entity_descriptor는 서비스 프로바이더 XML입니다.
entity_descriptor: |
<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"...
version: v1
Teleport에 서비스 프로바이더 정의를 추가합니다:
$ tctl create grafana-sp.yaml
이제 Grafana 로그인 화면에 "Sign in with SAML" 버튼이 나타나며, 이를 클릭하면 Teleport 로그인 화면으로 이동합니다. 또는 auto_login = true로 설정한 경우 자동으로 리디렉션됩니다.
