InfoGrab DocsInfoGrab Docs

토큰 폐기 API

요약

Token Revocation API는 GitLab과 인터페이스하여 GitLab 시크릿 탐지가 감지한 API 토큰 및 기타 시크릿을 수신하고 폐기하는 외부 배포형 HTTP API입니다. GitLab.com은 내부적으로 유지 관리되는 Secret Revocation Service (팀 멤버 전용)를 Token Revocation API로 사용합니다.

Token Revocation API는 GitLab과 인터페이스하여 GitLab 시크릿 탐지가 감지한 API 토큰 및 기타 시크릿을 수신하고 폐기하는 외부 배포형 HTTP API입니다. 시크릿 탐지 후처리 및 폐기 흐름을 이해하려면 고수준 아키텍처를 참조하세요.

GitLab.com은 내부적으로 유지 관리되는 Secret Revocation Service (팀 멤버 전용)를 Token Revocation API로 사용합니다. GitLab Self-Managed의 경우, 자체 API를 생성하고 이를 사용하도록 GitLab을 구성할 수 있습니다.

GitLab Self-Managed용 Token Revocation API 구현#

폐기 기능을 사용하려는 GitLab Self-Managed 인스턴스는 다음을 수행해야 합니다:

  • 자체 Token Revocation API를 구현하고 배포합니다.

  • GitLab 인스턴스가 Token Revocation API를 사용하도록 구성합니다.

서비스는 다음 조건을 충족해야 합니다:

  • 아래 API 명세와 일치해야 합니다.

  • 두 가지 엔드포인트를 제공해야 합니다:

폐기 가능한 토큰 유형 조회.

  • 유출된 토큰 폐기.

  • 속도 제한이 있어야 하며 멱등성을 가져야 합니다.

문서화된 엔드포인트에 대한 요청은 Authorization 헤더에 전달되는 API 토큰을 사용하여 인증됩니다. 요청 및 응답 본문(있는 경우)의 콘텐츠 타입은 application/json이어야 합니다.

모든 엔드포인트는 다음 응답을 반환할 수 있습니다:

  • 401 Unauthorized

  • 405 Method Not Allowed

  • 500 Internal Server Error

GET /v1/revocable_token_types#

revoke_tokens 엔드포인트에서 사용하기 위한 유효한 type 값을 반환합니다.

이 값들은 the secrets 분석기의 기본 식별자primary_identifier.typeprimary_identifier.value를 연결하여 만든 것과 일치합니다. 예를 들어, gitleaks_rule_id_gitlab_personal_access_token 값은 다음 결과 식별자와 일치합니다:

{"type": "gitleaks_rule_id", "name": "Gitleaks rule ID GitLab Personal Access Token", "value": "GitLab Personal Access Token"}
상태 코드 설명
200 응답 본문에 유효한 토큰 유형 값이 포함됩니다.

응답 본문 예시:

{
    "types": ["gitleaks_rule_id_gitlab_personal_access_token"]
}

POST /v1/revoke_tokens#

적절한 공급자에 의해 폐기될 토큰 목록을 수신합니다. 서비스는 각 공급자와 통신하여 토큰을 폐기할 책임이 있습니다.

상태 코드 설명
204 제출된 모든 토큰이 최종 폐기를 위해 수락되었습니다.
400 요청 본문이 잘못되었거나 제출된 토큰 유형 중 하나가 지원되지 않습니다. 요청을 재시도하지 않아야 합니다.
429 공급자가 너무 많은 요청을 수신했습니다. 나중에 요청을 재시도해야 합니다.

요청 본문 예시 (token 값에 시크릿 탐지 경고를 방지하기 위해 공백 문자 추가됨):

[{
    "type": "gitleaks_rule_id_gitlab_personal_access_token",
    "token": "glpat - 8GMtG8Mf4EnMJzmAWDU",
    "location": "https://example.com/some-repo/blob/abcdefghijklmnop/compromisedfile1.java"
},
{
    "type": "gitleaks_rule_id_gitlab_personal_access_token",
    "token": "glpat - tG84EGK33nMLLDE70zU",
    "location": "https://example.com/some-repo/blob/abcdefghijklmnop/compromisedfile2.java"
}]

GitLab이 Token Revocation API와 인터페이스하도록 구성#

GitLab 인스턴스에서 다음 데이터베이스 설정을 구성해야 합니다:

설정 유형 설명
secret_detection_token_revocation_enabled Boolean 자동 토큰 폐기 활성화 여부
secret_detection_token_revocation_url String Token Revocation API의 /v1/revoke_tokens 엔드포인트에 대한 완전한 URL
secret_detection_revocation_token_types_url String Token Revocation API의 /v1/revocable_token_types 엔드포인트에 대한 완전한 URL
secret_detection_token_revocation_token String Token Revocation API에 대한 요청을 인증하는 사전 공유 토큰

예를 들어, Rails 콘솔에서 이 값들을 구성하려면:

::Gitlab::CurrentSettings.update!(secret_detection_token_revocation_token: 'MYSECRETTOKEN')
::Gitlab::CurrentSettings.update!(secret_detection_token_revocation_url: 'https://gitlab.example.com/revocation_service/v1/revoke_tokens')
::Gitlab::CurrentSettings.update!(secret_detection_revocation_token_types_url: 'https://gitlab.example.com/revocation_service/v1/revocable_token_types')
::Gitlab::CurrentSettings.update!(secret_detection_token_revocation_enabled: true)

이 값들을 구성한 후, Token Revocation API는 고수준 아키텍처 다이어그램에 따라 호출됩니다.

토큰 폐기 API

GitLab v19.1
원문 보기
요약

Token Revocation API는 GitLab과 인터페이스하여 GitLab 시크릿 탐지가 감지한 API 토큰 및 기타 시크릿을 수신하고 폐기하는 외부 배포형 HTTP API입니다. GitLab.com은 내부적으로 유지 관리되는 Secret Revocation Service (팀 멤버 전용)를 Token Revocation API로 사용합니다.

Token Revocation API는 GitLab과 인터페이스하여 GitLab 시크릿 탐지가 감지한 API 토큰 및 기타 시크릿을 수신하고 폐기하는 외부 배포형 HTTP API입니다. 시크릿 탐지 후처리 및 폐기 흐름을 이해하려면 고수준 아키텍처를 참조하세요.

GitLab.com은 내부적으로 유지 관리되는 Secret Revocation Service (팀 멤버 전용)를 Token Revocation API로 사용합니다. GitLab Self-Managed의 경우, 자체 API를 생성하고 이를 사용하도록 GitLab을 구성할 수 있습니다.

GitLab Self-Managed용 Token Revocation API 구현#

폐기 기능을 사용하려는 GitLab Self-Managed 인스턴스는 다음을 수행해야 합니다:

  • 자체 Token Revocation API를 구현하고 배포합니다.

  • GitLab 인스턴스가 Token Revocation API를 사용하도록 구성합니다.

서비스는 다음 조건을 충족해야 합니다:

  • 아래 API 명세와 일치해야 합니다.

  • 두 가지 엔드포인트를 제공해야 합니다:

폐기 가능한 토큰 유형 조회.

  • 유출된 토큰 폐기.

  • 속도 제한이 있어야 하며 멱등성을 가져야 합니다.

문서화된 엔드포인트에 대한 요청은 Authorization 헤더에 전달되는 API 토큰을 사용하여 인증됩니다. 요청 및 응답 본문(있는 경우)의 콘텐츠 타입은 application/json이어야 합니다.

모든 엔드포인트는 다음 응답을 반환할 수 있습니다:

  • 401 Unauthorized

  • 405 Method Not Allowed

  • 500 Internal Server Error

GET /v1/revocable_token_types#

revoke_tokens 엔드포인트에서 사용하기 위한 유효한 type 값을 반환합니다.

이 값들은 the secrets 분석기의 기본 식별자primary_identifier.typeprimary_identifier.value를 연결하여 만든 것과 일치합니다. 예를 들어, gitleaks_rule_id_gitlab_personal_access_token 값은 다음 결과 식별자와 일치합니다:

{"type": "gitleaks_rule_id", "name": "Gitleaks rule ID GitLab Personal Access Token", "value": "GitLab Personal Access Token"}
상태 코드 설명
200 응답 본문에 유효한 토큰 유형 값이 포함됩니다.

응답 본문 예시:

{
    "types": ["gitleaks_rule_id_gitlab_personal_access_token"]
}

POST /v1/revoke_tokens#

적절한 공급자에 의해 폐기될 토큰 목록을 수신합니다. 서비스는 각 공급자와 통신하여 토큰을 폐기할 책임이 있습니다.

상태 코드 설명
204 제출된 모든 토큰이 최종 폐기를 위해 수락되었습니다.
400 요청 본문이 잘못되었거나 제출된 토큰 유형 중 하나가 지원되지 않습니다. 요청을 재시도하지 않아야 합니다.
429 공급자가 너무 많은 요청을 수신했습니다. 나중에 요청을 재시도해야 합니다.

요청 본문 예시 (token 값에 시크릿 탐지 경고를 방지하기 위해 공백 문자 추가됨):

[{
    "type": "gitleaks_rule_id_gitlab_personal_access_token",
    "token": "glpat - 8GMtG8Mf4EnMJzmAWDU",
    "location": "https://example.com/some-repo/blob/abcdefghijklmnop/compromisedfile1.java"
},
{
    "type": "gitleaks_rule_id_gitlab_personal_access_token",
    "token": "glpat - tG84EGK33nMLLDE70zU",
    "location": "https://example.com/some-repo/blob/abcdefghijklmnop/compromisedfile2.java"
}]

GitLab이 Token Revocation API와 인터페이스하도록 구성#

GitLab 인스턴스에서 다음 데이터베이스 설정을 구성해야 합니다:

설정 유형 설명
secret_detection_token_revocation_enabled Boolean 자동 토큰 폐기 활성화 여부
secret_detection_token_revocation_url String Token Revocation API의 /v1/revoke_tokens 엔드포인트에 대한 완전한 URL
secret_detection_revocation_token_types_url String Token Revocation API의 /v1/revocable_token_types 엔드포인트에 대한 완전한 URL
secret_detection_token_revocation_token String Token Revocation API에 대한 요청을 인증하는 사전 공유 토큰

예를 들어, Rails 콘솔에서 이 값들을 구성하려면:

::Gitlab::CurrentSettings.update!(secret_detection_token_revocation_token: 'MYSECRETTOKEN')
::Gitlab::CurrentSettings.update!(secret_detection_token_revocation_url: 'https://gitlab.example.com/revocation_service/v1/revoke_tokens')
::Gitlab::CurrentSettings.update!(secret_detection_revocation_token_types_url: 'https://gitlab.example.com/revocation_service/v1/revocable_token_types')
::Gitlab::CurrentSettings.update!(secret_detection_token_revocation_enabled: true)

이 값들을 구성한 후, Token Revocation API는 고수준 아키텍처 다이어그램에 따라 호출됩니다.