Skip to content

非公式本サイトは非公式の日本語ドキュメントであり、Cloudflare 公式サイトではありません。最新情報はdevelopers.cloudflare.comをご確認ください。

よく使う API 呼び出し

最終更新 Markdown で表示Agent セットアップ

次の例は、漏洩認証情報の検出を管理・設定するために Cloudflare API を使う一般的なシナリオです。

Terraform を使う場合は、Terraform 設定の例 を参照してください。

一般的な操作

次の API 例は、漏洩認証情報の検出の有効化と無効化など、基本的な操作を扱います。

漏洩認証情報の検出をオンにする

漏洩認証情報の検出をオンにするには、次のような POST リクエストを使います。

Required API token permissions

At least one of the following token permissions is required:
  • Zone WAF Write
  • Account WAF Write
Update the Leaked Credential Checks status for a zone.bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/leaked-credential-checks" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"enabled": true
	}'

漏洩認証情報の検出をオフにする

漏洩認証情報の検出をオフにするには、次のような POST リクエストを使います。

Required API token permissions

At least one of the following token permissions is required:
  • Zone WAF Write
  • Account WAF Write
Update the Leaked Credential Checks status for a zone.bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/leaked-credential-checks" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"enabled": false
	}'

漏洩認証情報の検出の状態を取得する

漏洩認証情報の検出の現在の状態を取得するには、次のような GET リクエストを使います。

Required API token permissions

At least one of the following token permissions is required:
  • Zone WAF Write
  • Zone WAF Read
  • Account WAF Write
  • Account WAF Read
Get the Leaked Credential Checks status for a zone.bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/leaked-credential-checks" \
	--request GET \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
{
	"result": {
		"enabled": true
	},
	"success": true,
	"errors": [],
	"messages": []
}

カスタム検出ロケーションの操作

次の API 例は、漏洩認証情報の検出向けの カスタム検出ロケーション に対する操作です。

カスタム検出ロケーションを追加する

カスタム検出ロケーションを追加するには、次のような POST リクエストを使います。

Required API token permissions

At least one of the following token permissions is required:
  • Zone WAF Write
  • Account WAF Write
Create a custom detection location for a zone.bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/leaked-credential-checks/detections" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"username": "lookup_json_string(http.request.body.raw, \"user\")",
		"password": "lookup_json_string(http.request.body.raw, \"secret\")"
	}'

既存のカスタム検出ロケーションを取得する

既存のカスタム検出ロケーションの一覧を取得するには、次のような GET リクエストを使います。

Required API token permissions

At least one of the following token permissions is required:
  • Zone WAF Write
  • Zone WAF Read
  • Account WAF Write
  • Account WAF Read
List the custom detection locations of a zone.bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/leaked-credential-checks/detections" \
	--request GET \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
{
	"result": [
		{
			"id": "<DETECTION_ID>",
			"username": "lookup_json_string(http.request.body.raw, \"user\")",
			"password": "lookup_json_string(http.request.body.raw, \"secret\")"
		}
		// (...)
	],
	"success": true,
	"errors": [],
	"messages": []
}

カスタム検出ロケーションを削除する

カスタム検出ロケーションを削除するには、次のような DELETE リクエストを使います。

Required API token permissions

At least one of the following token permissions is required:
  • Zone WAF Write
  • Account WAF Write
Delete a custom detection location from a zone.bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/leaked-credential-checks/detections/$DETECTION_ID" \
	--request DELETE \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"

役に立ちましたか?