InfoGrab DocsInfoGrab Docs

Elasticsearch에서 JWT 인증 사용하기

요약

이 가이드는 Teleport와 함께 Elasticsearch JWT 인증을 구성하는 데 도움을 줍니다. 실행 중인 Teleport 클러스터. tctl and tsh clients. Teleport 클러스터의 버전을 확인합니다.

이 가이드는 Teleport와 함께 Elasticsearch JWT 인증을 구성하는 데 도움을 줍니다.

사전 요구사항#

  • 실행 중인 Teleport 클러스터. Teleport를 시작하려면 무료 체험판에 가입하거나 데모 환경을 구성하세요.

  • tctl and tsh clients.

    Installing `tctl` and `tsh` clients
    1. Teleport 클러스터의 버전을 확인합니다. tctl and tsh clients는 Teleport 클러스터 버전보다 최대 한 개의 메이저 버전까지만 뒤처질 수 있습니다. Proxy Service의 /v1/webapi/find로 GET 요청을 보내고 JSON 쿼리 도구를 사용하여 클러스터 버전을 확인합니다. teleport.example.com:443를 Teleport Proxy Service의 웹 주소로 바꿉니다:

      $ TELEPORT_DOMAIN=teleport.example.com:443
      $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')"
      
    2. 사용 중인 플랫폼에 대한 지침에 따라 tctl and tsh clients를 설치합니다:

Mac

     `tctl` and `tsh` clients가 포함된, 서명된 Teleport macOS .pkg 설치 프로그램을 다운로드합니다:
 
     ```code
     $ curl -O https://cdn.teleport.dev/teleport-${TELEPORT_VERSION?}.pkg
     ```

     Finder에서 `pkg` 파일을 더블 클릭하여 설치를 시작합니다.
 
     
Warning
       Homebrew를 사용하여 Teleport를 설치하는 것은 지원되지 않습니다. Homebrew의
       Teleport 패키지는 Teleport에서 유지 관리하지 않으므로 신뢰성이나 보안을
       보장할 수 없습니다.
     

Windows - Powershell

     ```code
     $ curl.exe -O https://cdn.teleport.dev/teleport-v${TELEPORT_VERSION?}-windows-amd64-bin.zip
     # Unzip the archive and move the `tctl` and `tsh` clients to your %PATH%
     # NOTE: Do not place the `tctl` and `tsh` clients in the System32 directory, as this can cause issues when using WinSCP.
     # Use %SystemRoot% (C:\Windows) or %USERPROFILE% (C:\Users\<username>) instead.
     ```
 
   

 
   

Linux

     Linux 설치판의 모든 Teleport 바이너리에는 `tctl` and `tsh` clients가 포함되어 있습니다.  RPM/DEB
     패키지 및 i386/ARM/ARM64용 다운로드를 포함한 더 많은 옵션은
     [설치 페이지](../installation/installation.mdx)를 참조하세요.
 
     ```code
     $ curl -O https://cdn.teleport.dev/teleport-v${TELEPORT_VERSION?}-linux-amd64-bin.tar.gz
     $ tar -xzf teleport-v${TELEPORT_VERSION?}-linux-amd64-bin.tar.gz
     $ cd teleport
     $ sudo ./install
     # Teleport binaries have been copied to /usr/local/bin
     ```
   

 

Teleport cluster에 연결할 수 있는지 확인하려면 tsh login으로 로그인한 다음, 현재 자격 증명으로 tctl 명령을 실행할 수 있는지 확인합니다.

예를 들어, teleport.example.com에 cluster 내 Teleport Proxy Service의 도메인 이름을, email@example.com에 Teleport 사용자 이름을 지정하여 다음 명령을 실행합니다:

$ tsh login --proxy=teleport.example.com --user=email@example.com
$ tctl status
# Cluster  (=teleport.url=)
# Version  (=teleport.version=)
# CA pin   (=presets.ca_pin=)

cluster에 연결하여 tctl status 명령을 실행할 수 있다면, 현재 자격 증명을 사용하여 워크스테이션에서 이후의 tctl 명령을 실행할 수 있습니다. 자체 Teleport cluster를 호스팅하는 경우, 전체 권한을 얻기 위해 Teleport Auth Service를 호스팅하는 컴퓨터에서 tctl 명령을 실행할 수도 있습니다.

1/3단계. Elasticsearch에서 JWT 렐름 활성화#

Elasticsearch 설정 파일 elasticsearch.yaml을 업데이트하여 JWT 렐름을 활성화합니다:

xpack.security.authc.realms.jwt.teleport:
  order: 1
  client_authentication.type: none
  pkc_jwkset_path: https://proxy.example.com/.well-known/jwks.json
  claims.principal: sub
  claims.groups: roles
  allowed_issuer: example-cluster
  allowed_audiences: ["https://elasticsearch.example.com:9200"]
Elastic Cloud

Elastic Cloud의 호스팅 배포의 경우, 배포를 편집하여 동일한 설정을 구성할 수 있습니다.

"Elasticsearch"의 "Manage user settings and extensions"로 이동한 다음, 위의 설정 스니펫을 "User Settings" 아래에 추가합니다. 1보다 큰 순서 번호를 사용해야 할 수도 있습니다.

Elastic Cloud Serverless 프로젝트는 외부 렐름 연결을 지원하지 않으므로 JWT 인증으로 구성할 수 없다는 점에 유의하십시오.

이제 파라미터와 그 값을 좀 더 자세히 살펴보겠습니다:

  • client_authentication.typenone으로 설정합니다. 그렇지 않으면 Elasticsearch는 클라이언트가 각 요청과 함께 공유 비밀 값을 전송하도록 요구합니다.
  • pkc_jwkset_path를 Teleport 프록시의 JWT 키 세트 파일 URL로 설정합니다. 이 URL은 https://<proxy>/.well-known/jwks.json 엔드포인트에서 사용할 수 있습니다. URL을 사용하는 대신 동일한 URL에서 JSON 파일을 다운로드하여 경로가 해당 파일을 직접 가리키게 할 수도 있습니다.
  • claims.principalclaims.groups를 각각 subroles로 설정합니다. 이는 Teleport가 JWT 토큰에서 사용자 및 역할 정보를 전달하는 데 사용하는 클레임입니다.
  • allowed_issuer를 Teleport 클러스터의 이름으로 설정합니다.
  • allowed_audiences를 Teleport 애플리케이션 서비스가 Elasticsearch에 연결하는 데 사용할 URL로 설정합니다.
Note

JWT 인증을 사용할 때는 표준 Elasticsearch role_mapping.yml 파일을 사용하여 사용자 역할을 매핑할 수 없다는 점에 유의하십시오. 대신 API를 사용하여 역할 매핑을 설정해야 합니다.

예를 들어, Teleport의 access 역할을 Elasticsearch의 superuser 역할에 매핑하려면 다음과 같은 매핑을 생성할 수 있습니다:

PUT /_security/role_mapping/teleport_access
{
  "roles": [ "superuser" ],
  "rules": {
    "all": [
      { "field": { "realm.name": "teleport" } },
      { "field": { "groups": "access" } }
    ]
  },
  "enabled": true
}

자세한 내용은 JWT 렐름 인가를 참조하십시오.

2/3단계. Teleport에 Elasticsearch 애플리케이션 등록#

Teleport 애플리케이션 서비스 설정 파일 teleport.yaml에서 Elasticsearch에 대한 항목을 등록합니다:

app_service:
  enabled: true
  apps:
  - name: "elastic"
    uri: https://elasticsearch.example.com:9200
    rewrite:
      headers:
      - "Authorization: Bearer {{internal.jwt}}"

Elasticsearch는 Authorization 헤더 내에 JWT 토큰이 전달되어야 합니다. 위의 헤더 재작성 설정은 각 요청에서 {{internal.jwt}} 템플릿 변수를 Teleport가 서명한 JWT 토큰으로 대체합니다.

3/3단계. ElasticSearch API에 연결#

tsh login으로 Teleport 클러스터에 로그인하고 Elasticsearch 애플리케이션이 사용 가능한지 확인합니다:

$ tsh apps ls
Application Description   Public Address               Labels
----------- ------------- ---------------------------- -------------------------------
elastic                   elastic.teleport.example.com

Elasticsearch용 단기 X.509 인증서를 가져옵니다:

$ tsh apps login elastic

그런 다음 curl 명령을 사용하여 Elasticsearch API와 통신할 수 있으며, 이때 Teleport 사용자로 인증됩니다:

$ curl \
  --cacert ~/.tsh/keys/teleport.example.com/cas/root.pem \
  --cert ~/.tsh/keys/teleport.example.com/alice-app/example-cluster/elastic-x509.pem \
  --key ~/.tsh/keys/teleport.example.com/alice \
  https://elastic.teleport.example.com/_security/_authenticate | jq

다음 단계#

  • Teleport JWT 토큰과의 통합에 대해 자세히 알아보세요.
  • 동적 등록 가이드를 참조하세요.
  • Teleport 애플리케이션 서비스로 API 접근하는 방법에 대해 자세히 알아보세요.
  • 애플리케이션 관련 접근 제어를 살펴보세요.

Elasticsearch에서 JWT 인증 사용하기

Teleport v18.9
원문 보기
요약

이 가이드는 Teleport와 함께 Elasticsearch JWT 인증을 구성하는 데 도움을 줍니다. 실행 중인 Teleport 클러스터. tctl and tsh clients. Teleport 클러스터의 버전을 확인합니다.

이 가이드는 Teleport와 함께 Elasticsearch JWT 인증을 구성하는 데 도움을 줍니다.

사전 요구사항#

  • 실행 중인 Teleport 클러스터. Teleport를 시작하려면 무료 체험판에 가입하거나 데모 환경을 구성하세요.

  • tctl and tsh clients.

    Installing `tctl` and `tsh` clients
    1. Teleport 클러스터의 버전을 확인합니다. tctl and tsh clients는 Teleport 클러스터 버전보다 최대 한 개의 메이저 버전까지만 뒤처질 수 있습니다. Proxy Service의 /v1/webapi/find로 GET 요청을 보내고 JSON 쿼리 도구를 사용하여 클러스터 버전을 확인합니다. teleport.example.com:443를 Teleport Proxy Service의 웹 주소로 바꿉니다:

      $ TELEPORT_DOMAIN=teleport.example.com:443
      $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')"
      
    2. 사용 중인 플랫폼에 대한 지침에 따라 tctl and tsh clients를 설치합니다:

Mac

     `tctl` and `tsh` clients가 포함된, 서명된 Teleport macOS .pkg 설치 프로그램을 다운로드합니다:
 
     ```code
     $ curl -O https://cdn.teleport.dev/teleport-${TELEPORT_VERSION?}.pkg
     ```

     Finder에서 `pkg` 파일을 더블 클릭하여 설치를 시작합니다.
 
     
Warning
       Homebrew를 사용하여 Teleport를 설치하는 것은 지원되지 않습니다. Homebrew의
       Teleport 패키지는 Teleport에서 유지 관리하지 않으므로 신뢰성이나 보안을
       보장할 수 없습니다.
     

Windows - Powershell

     ```code
     $ curl.exe -O https://cdn.teleport.dev/teleport-v${TELEPORT_VERSION?}-windows-amd64-bin.zip
     # Unzip the archive and move the `tctl` and `tsh` clients to your %PATH%
     # NOTE: Do not place the `tctl` and `tsh` clients in the System32 directory, as this can cause issues when using WinSCP.
     # Use %SystemRoot% (C:\Windows) or %USERPROFILE% (C:\Users\<username>) instead.
     ```
 
   

 
   

Linux

     Linux 설치판의 모든 Teleport 바이너리에는 `tctl` and `tsh` clients가 포함되어 있습니다.  RPM/DEB
     패키지 및 i386/ARM/ARM64용 다운로드를 포함한 더 많은 옵션은
     [설치 페이지](../installation/installation.mdx)를 참조하세요.
 
     ```code
     $ curl -O https://cdn.teleport.dev/teleport-v${TELEPORT_VERSION?}-linux-amd64-bin.tar.gz
     $ tar -xzf teleport-v${TELEPORT_VERSION?}-linux-amd64-bin.tar.gz
     $ cd teleport
     $ sudo ./install
     # Teleport binaries have been copied to /usr/local/bin
     ```
   

 

Teleport cluster에 연결할 수 있는지 확인하려면 tsh login으로 로그인한 다음, 현재 자격 증명으로 tctl 명령을 실행할 수 있는지 확인합니다.

예를 들어, teleport.example.com에 cluster 내 Teleport Proxy Service의 도메인 이름을, email@example.com에 Teleport 사용자 이름을 지정하여 다음 명령을 실행합니다:

$ tsh login --proxy=teleport.example.com --user=email@example.com
$ tctl status
# Cluster  (=teleport.url=)
# Version  (=teleport.version=)
# CA pin   (=presets.ca_pin=)

cluster에 연결하여 tctl status 명령을 실행할 수 있다면, 현재 자격 증명을 사용하여 워크스테이션에서 이후의 tctl 명령을 실행할 수 있습니다. 자체 Teleport cluster를 호스팅하는 경우, 전체 권한을 얻기 위해 Teleport Auth Service를 호스팅하는 컴퓨터에서 tctl 명령을 실행할 수도 있습니다.

1/3단계. Elasticsearch에서 JWT 렐름 활성화#

Elasticsearch 설정 파일 elasticsearch.yaml을 업데이트하여 JWT 렐름을 활성화합니다:

xpack.security.authc.realms.jwt.teleport:
  order: 1
  client_authentication.type: none
  pkc_jwkset_path: https://proxy.example.com/.well-known/jwks.json
  claims.principal: sub
  claims.groups: roles
  allowed_issuer: example-cluster
  allowed_audiences: ["https://elasticsearch.example.com:9200"]
Elastic Cloud

Elastic Cloud의 호스팅 배포의 경우, 배포를 편집하여 동일한 설정을 구성할 수 있습니다.

"Elasticsearch"의 "Manage user settings and extensions"로 이동한 다음, 위의 설정 스니펫을 "User Settings" 아래에 추가합니다. 1보다 큰 순서 번호를 사용해야 할 수도 있습니다.

Elastic Cloud Serverless 프로젝트는 외부 렐름 연결을 지원하지 않으므로 JWT 인증으로 구성할 수 없다는 점에 유의하십시오.

이제 파라미터와 그 값을 좀 더 자세히 살펴보겠습니다:

  • client_authentication.typenone으로 설정합니다. 그렇지 않으면 Elasticsearch는 클라이언트가 각 요청과 함께 공유 비밀 값을 전송하도록 요구합니다.
  • pkc_jwkset_path를 Teleport 프록시의 JWT 키 세트 파일 URL로 설정합니다. 이 URL은 https://<proxy>/.well-known/jwks.json 엔드포인트에서 사용할 수 있습니다. URL을 사용하는 대신 동일한 URL에서 JSON 파일을 다운로드하여 경로가 해당 파일을 직접 가리키게 할 수도 있습니다.
  • claims.principalclaims.groups를 각각 subroles로 설정합니다. 이는 Teleport가 JWT 토큰에서 사용자 및 역할 정보를 전달하는 데 사용하는 클레임입니다.
  • allowed_issuer를 Teleport 클러스터의 이름으로 설정합니다.
  • allowed_audiences를 Teleport 애플리케이션 서비스가 Elasticsearch에 연결하는 데 사용할 URL로 설정합니다.
Note

JWT 인증을 사용할 때는 표준 Elasticsearch role_mapping.yml 파일을 사용하여 사용자 역할을 매핑할 수 없다는 점에 유의하십시오. 대신 API를 사용하여 역할 매핑을 설정해야 합니다.

예를 들어, Teleport의 access 역할을 Elasticsearch의 superuser 역할에 매핑하려면 다음과 같은 매핑을 생성할 수 있습니다:

PUT /_security/role_mapping/teleport_access
{
  "roles": [ "superuser" ],
  "rules": {
    "all": [
      { "field": { "realm.name": "teleport" } },
      { "field": { "groups": "access" } }
    ]
  },
  "enabled": true
}

자세한 내용은 JWT 렐름 인가를 참조하십시오.

2/3단계. Teleport에 Elasticsearch 애플리케이션 등록#

Teleport 애플리케이션 서비스 설정 파일 teleport.yaml에서 Elasticsearch에 대한 항목을 등록합니다:

app_service:
  enabled: true
  apps:
  - name: "elastic"
    uri: https://elasticsearch.example.com:9200
    rewrite:
      headers:
      - "Authorization: Bearer {{internal.jwt}}"

Elasticsearch는 Authorization 헤더 내에 JWT 토큰이 전달되어야 합니다. 위의 헤더 재작성 설정은 각 요청에서 {{internal.jwt}} 템플릿 변수를 Teleport가 서명한 JWT 토큰으로 대체합니다.

3/3단계. ElasticSearch API에 연결#

tsh login으로 Teleport 클러스터에 로그인하고 Elasticsearch 애플리케이션이 사용 가능한지 확인합니다:

$ tsh apps ls
Application Description   Public Address               Labels
----------- ------------- ---------------------------- -------------------------------
elastic                   elastic.teleport.example.com

Elasticsearch용 단기 X.509 인증서를 가져옵니다:

$ tsh apps login elastic

그런 다음 curl 명령을 사용하여 Elasticsearch API와 통신할 수 있으며, 이때 Teleport 사용자로 인증됩니다:

$ curl \
  --cacert ~/.tsh/keys/teleport.example.com/cas/root.pem \
  --cert ~/.tsh/keys/teleport.example.com/alice-app/example-cluster/elastic-x509.pem \
  --key ~/.tsh/keys/teleport.example.com/alice \
  https://elastic.teleport.example.com/_security/_authenticate | jq

다음 단계#

  • Teleport JWT 토큰과의 통합에 대해 자세히 알아보세요.
  • 동적 등록 가이드를 참조하세요.
  • Teleport 애플리케이션 서비스로 API 접근하는 방법에 대해 자세히 알아보세요.
  • 애플리케이션 관련 접근 제어를 살펴보세요.