Skip to content

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

よく使うポリシー

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

次の Cloudflare Access ポリシーは、アプリケーションの保護によく使われます。

利用可能なアクション、ルールタイプ、セレクターの一覧は Access ポリシーのページ を参照してください。ポリシーの作成と管理は Access ポリシーを管理する を参照してください。

メールドメインで従業員を許可する

最も基本的な Access ポリシーは、組織に属するメールアドレスで認証したすべてのユーザーにアクセスを許可します。Access でアプリケーションを初めて保護し、企業の ID プロバイダー を使う従業員に限定したいときの出発点になります。

アクション ルールタイプ セレクター
Allow Include 次で終わるメールアドレス @example.com

Required API token permissions

At least one of the following token permissions is required:
  • Access: Apps and Policies Write
Create an Access reusable policybash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/policies" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Allow employees by email domain",
		"decision": "allow",
		"include": [
				{
						"email_domain": {
								"domain": "example.com"
						}
				}
		]
	}'

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Access: Apps and Policies Write

cloudflare_zero_trust_access_policy リソースを設定します。

resource "cloudflare_zero_trust_access_policy" "allow_employees_by_email_domain" {
  account_id = var.cloudflare_account_id
  name       = "Allow employees by email domain"
  decision   = "allow"
  include = [{
    email_domain = {
      domain = "example.com"
    }
  }]
}

組織が複数のドメインを使う場合(例: @example.com@example.co.uk)、Include ルールに複数のメールドメインを追加できます。

特定の国の従業員を許可する

特定の地域で事業を行う組織や、データ所在地の要件に従う必要がある組織は、承認した国のユーザーにアプリケーションアクセスを制限できます。出張中の役員など個別の例外を残しつつ、従業員の接続元を限定したいときに役立ちます。

Require ルールは AND 論理のため、1 つの Require ルールに複数の国を直接追加できません。そうすると、ユーザーがすべての国に同時にいることが条件になります。代わりに、承認した国を列挙した ルールグループ を先に作成します。

ルールタイプ セレクター
Include Country United States, Portugal

Required API token permissions

At least one of the following token permissions is required:
  • Access: Organizations, Identity Providers, and Groups Write
Create an Access groupbash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/groups" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Approved countries",
		"include": [
				{
						"geo": {
								"country_code": "US"
						}
				},
				{
						"geo": {
								"country_code": "PT"
						}
				}
		]
	}'

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Access: Apps and Policies Write

cloudflare_zero_trust_access_group リソースを設定します。

resource "cloudflare_zero_trust_access_group" "approved_countries" {
  account_id = var.cloudflare_account_id
  name       = "Approved countries"
  include = [
    {
      geo = {
        country_code = "US"
      }
    },
    {
      geo = {
        country_code = "PT"
      }
    },
  ]
}

次に、Access ポリシーでそのルールグループを参照します。

アクション ルールタイプ セレクター
Allow Include Emails ending in @example.com
Require Rule group Approved countries
Exclude Email [email protected], [email protected]

Required API token permissions

At least one of the following token permissions is required:
  • Access: Apps and Policies Write
Create an Access reusable policybash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/policies" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Allow employees from specific countries",
		"decision": "allow",
		"include": [
				{
						"email_domain": {
								"domain": "example.com"
						}
				}
		],
		"require": [
				{
						"group": {
								"id": "<APPROVED_COUNTRIES_GROUP_ID>"
						}
				}
		],
		"exclude": [
				{
						"email": {
								"email": "[email protected]"
						}
				},
				{
						"email": {
								"email": "[email protected]"
						}
				}
		]
	}'

<APPROVED_COUNTRIES_GROUP_ID> は、上記でルールグループを作成したときに返された id に置き換えます。既存グループの確認には、List Access groups エンドポイントを使います。

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Access: Apps and Policies Write

cloudflare_zero_trust_access_policy リソースを設定します。

resource "cloudflare_zero_trust_access_policy" "allow_employees_from_specific_countries" {
  account_id = var.cloudflare_account_id
  name       = "Allow employees from specific countries"
  decision   = "allow"
  include = [{
    email_domain = {
      domain = "example.com"
    }
  }]
  require = [{
    group = {
      id = cloudflare_zero_trust_access_group.approved_countries.id
    }
  }]
  exclude = [
    {
      email = {
        email = "[email protected]"
      }
    },
    {
      email = {
        email = "[email protected]"
      }
    },
  ]
}

cloudflare_zero_trust_access_group.approved_countries の参照は、上記で作成した cloudflare_zero_trust_access_group リソースを指します。

機密アプリケーションにデバイスポスチャを必須にする

機密データを含むアプリケーションでは、組織のセキュリティ基準を満たす管理対象デバイスからの接続であることを確認できます。次の例は、ID 確認と デバイスポスチャチェック を組み合わせ、デバイスが対応する OS バージョン を実行し、Cloudflare One Client 経由で接続していることを確認します。後者は Require Gateway チェック で強制します。

アクション ルールタイプ セレクター
Allow Include Okta Groups Full-Time Employees
Require Gateway Gateway
Require OS Version Latest version of Windows

Required API token permissions

At least one of the following token permissions is required:
  • Access: Apps and Policies Write
Create an Access reusable policybash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/policies" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Require device posture for sensitive apps",
		"decision": "allow",
		"include": [
				{
						"okta": {
								"name": "Full-Time Employees",
								"identity_provider_id": "<OKTA_IDP_ID>"
						}
				}
		],
		"require": [
				{
						"device_posture": {
								"integration_uid": "<GATEWAY_CHECK_ID>"
						}
				},
				{
						"device_posture": {
								"integration_uid": "<OS_VERSION_CHECK_ID>"
						}
				}
		]
	}'

okta ルールは、ID プロバイダーに適したルール に置き換えます。ID プロバイダー ID の取得には、List Access identity providers エンドポイントを使います。デバイスポスチャチェックの integration UID の取得には、List device posture checks エンドポイントを使います。

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Access: Apps and Policies Write

cloudflare_zero_trust_access_policy リソースを設定します。

resource "cloudflare_zero_trust_access_policy" "require_device_posture" {
  account_id = var.cloudflare_account_id
  name       = "Require device posture for sensitive apps"
  decision   = "allow"
  include = [{
    okta = {
      name                 = "Full-Time Employees"
      identity_provider_id = cloudflare_zero_trust_access_identity_provider.okta.id
    }
  }]
  require = [
    {
      device_posture = {
        integration_uid = cloudflare_zero_trust_device_posture_rule.gateway_check.id
      }
    },
    {
      device_posture = {
        integration_uid = cloudflare_zero_trust_device_posture_rule.os_version_check.id
      }
    },
  ]
}

これらのデバイス要件を複数のアプリケーションで再利用するには、ポスチャチェックを含む ルールグループ「Corporate device requirements」を作成します。その後、任意のポリシーの Require フィールドでこのルールグループを参照できます。

高セキュリティアプリケーションに MFA を必須にする

財務データ、本番インフラ、その他の高価値リソースを扱うアプリケーションでは、ID プロバイダーの資格情報に加えて、多要素認証(MFA)での認証を必須にできます。パスワードが漏洩しただけではアクセスできないようにします。

Access では、MFA を強制する方法が 2 つあります。

ID プロバイダーベースの MFA

ID プロバイダーがログイン時の認証方式を報告する場合、Authentication method セレクターを追加し、ハードウェアセキュリティキーなど特定の MFA 方式を必須にできます。

アクション ルールタイプ セレクター
Allow Include Okta Groups Employees
Require Authentication method Security key
Require Gateway (enabled)

Required API token permissions

At least one of the following token permissions is required:
  • Access: Apps and Policies Write
Create an Access reusable policybash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/policies" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Require MFA for high-security apps",
		"decision": "allow",
		"include": [
				{
						"okta": {
								"name": "Employees",
								"identity_provider_id": "<OKTA_IDP_ID>"
						}
				}
		],
		"require": [
				{
						"auth_method": {
								"auth_method": "swk"
						}
				},
				{
						"device_posture": {
								"integration_uid": "<GATEWAY_CHECK_ID>"
						}
				}
		]
	}'

auth_method の値は RFC 8176 の認証方式参照値を使います。たとえば swk はソフトウェア保護キー(セキュリティキー)を表します。okta ルールは、ID プロバイダーに適したルール に置き換えます。ID プロバイダー ID の取得には、List Access identity providers エンドポイントを使います。<GATEWAY_CHECK_ID> の取得には、List device posture checks エンドポイントを使います。

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Access: Apps and Policies Write

cloudflare_zero_trust_access_policy リソースを設定します。

resource "cloudflare_zero_trust_access_policy" "require_mfa" {
  account_id = var.cloudflare_account_id
  name       = "Require MFA for high-security apps"
  decision   = "allow"
  include = [{
    okta = {
      name                 = "Employees"
      identity_provider_id = cloudflare_zero_trust_access_identity_provider.okta.id
    }
  }]
  require = [
    {
      auth_method = {
        auth_method = "swk"
      }
    },
    {
      device_posture = {
        integration_uid = cloudflare_zero_trust_device_posture_rule.gateway_check.id
      }
    },
  ]
}

auth_method の値は RFC 8176 の認証方式参照値を使います。たとえば swk はソフトウェア保護キー(セキュリティキー)を表します。

独立 MFA

IdP に依存せず Access で直接 MFA を強制したい場合は、独立 MFA を使えます。独立 MFA はポリシーセレクターでは設定しません。先に組織レベルで 独立 MFA をオン にし、設定パネルから特定のアプリケーションまたはポリシーで有効にします。Access は、ユーザーが IdP で認証したあと、第 2 要素(セキュリティキー、認証アプリ、生体認証など)を求めます。

両方の方法の詳細は MFA を強制する を参照してください。

メールベース認証で契約者アクセスを許可する

企業の ID プロバイダーに属さない外部の契約者やパートナーと協働する場合、ワンタイム PIN(OTP) でアクセスを付与できます。OTP は契約者のメールアドレスに短期間有効なコードを送り、IdP のアカウントなしで認証できます。

アクション ルールタイプ セレクター
Allow Include Emails ending in @contractor-a.com, @contractor-b.com
Require Login methods One-time PIN

Required API token permissions

At least one of the following token permissions is required:
  • Access: Apps and Policies Write
Create an Access reusable policybash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/policies" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Allow contractor access with OTP",
		"decision": "allow",
		"include": [
				{
						"email_domain": {
								"domain": "contractor-a.com"
						}
				},
				{
						"email_domain": {
								"domain": "contractor-b.com"
						}
				}
		],
		"require": [
				{
						"login_method": {
								"id": "<OTP_IDENTITY_PROVIDER_ID>"
						}
				}
		]
	}'

OTP ID プロバイダーの ID を取得するには、List Access identity providers エンドポイントを使います。

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Access: Apps and Policies Write

cloudflare_zero_trust_access_policy リソースを設定します。

resource "cloudflare_zero_trust_access_policy" "allow_contractor_access_with_otp" {
  account_id = var.cloudflare_account_id
  name       = "Allow contractor access with OTP"
  decision   = "allow"
  include = [
    {
      email_domain = {
        domain = "contractor-a.com"
      }
    },
    {
      email_domain = {
        domain = "contractor-b.com"
      }
    },
  ]
  require = [{
    login_method = {
      id = cloudflare_zero_trust_access_identity_provider.otp.id
    }
  }]
}

OTP 向けの cloudflare_zero_trust_access_identity_provider リソース(type = "onetimepin" で設定)は、ワンタイム PIN を参照してください。

内部アプリケーションへの契約者アクセスを隔離する

契約者やその他の外部ユーザーが内部アプリケーションを閲覧する必要がある一方、管理対象外デバイスへのダウンロード、コピー、データ転送を許可したくない場合は、リモートブラウザー でアプリケーションを提供できます。外部ユーザーには読み取り専用の表示を与え、機密データが環境外へ出ないようにします。

アクション ルールタイプ セレクター
Allow Include Emails ending in @contractor-a.com, @contractor-b.com

Additional settings: Isolate application をオンにします。

まだ有効にしていない場合は、先にアカウントで Clientless Web Isolation を有効にします。

Patch Zero Trust account configurationbash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/configuration" \
	--request PATCH \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"settings": {
				"browser_isolation": {
						"url_browser_isolation_enabled": true
				}
		}
	}'

次に、isolation_requiredtrue にした Access ポリシーを作成します。

Required API token permissions

At least one of the following token permissions is required:
  • Access: Apps and Policies Write
Create an Access reusable policybash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/policies" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Isolate contractor access",
		"decision": "allow",
		"include": [
				{
						"email_domain": {
								"domain": "contractor-a.com"
						}
				},
				{
						"email_domain": {
								"domain": "contractor-b.com"
						}
				}
		],
		"isolation_required": true
	}'

まだ有効にしていない場合は、先に cloudflare_zero_trust_gateway_settings リソースを設定し、アカウントで Clientless Web Isolation を有効にします。

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Zero Trust Write
resource "cloudflare_zero_trust_gateway_settings" "gateway_settings" {
  account_id = var.cloudflare_account_id
  settings = {
    browser_isolation = {
      url_browser_isolation_enabled = true
    }
  }
}

次に、isolation_requiredtrue にした cloudflare_zero_trust_access_policy リソースを設定します。

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Access: Apps and Policies Write
resource "cloudflare_zero_trust_access_policy" "isolate_contractor_access" {
  account_id         = var.cloudflare_account_id
  name               = "Isolate contractor access"
  decision           = "allow"
  isolation_required = true
  include = [
    {
      email_domain = {
        domain = "contractor-a.com"
      }
    },
    {
      email_domain = {
        domain = "contractor-b.com"
      }
    },
  ]
}

隔離セッション内でユーザーができる操作を制限するには、アプリケーションドメイン宛のトラフィックに一致する併用の Gateway HTTP ポリシー を作成します。アクションを Isolate にし、ポリシー設定 でインタラクティブな操作を無効にします。

Gateway HTTP ポリシーの例

セレクター 演算子 アクション
Domain in wiki.example.com Isolate

Policy settings:

設定
Copy Do not allow
Paste Do not allow
Keyboard Do not allow
File downloads Do not allow
File uploads Do not allow
Printing Do not allow

詳細は セルフホストアプリケーションを隔離する を参照してください。

高リスク国からのリクエストをブロックする

社内ポリシーや、OFAC 制裁ITAR 規制 などの規制要件により特定の国からのアクセスを制限する場合、それらの地域からのアクセスを拒否する Block ポリシーを作成できます。企業の IP 許可リストを Exclude ルールとして追加すると、信頼できるオフィスネットワーク経由で接続する従業員が誤ってブロックされません。

アクション ルールタイプ セレクター
Block Include Russian Federation
Exclude IP リスト Corporate IP allowlist

Required API token permissions

At least one of the following token permissions is required:
  • Access: Apps and Policies Write
Create an Access reusable policybash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/policies" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Block requests from high-risk countries",
		"decision": "deny",
		"include": [
				{
						"geo": {
								"country_code": "RU"
						}
				}
		],
		"exclude": [
				{
						"ip_list": {
								"id": "<CORPORATE_IP_ALLOWLIST_ID>"
						}
				}
		]
	}'

IP リストの ID を取得するには、List Zero Trust lists エンドポイントを使います。

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Access: Apps and Policies Write

cloudflare_zero_trust_access_policy リソースを設定します。

resource "cloudflare_zero_trust_access_policy" "block_high_risk_countries" {
  account_id = var.cloudflare_account_id
  name       = "Block requests from high-risk countries"
  decision   = "deny"
  include = [{
    geo = {
      country_code = "RU"
    }
  }]
  exclude = [{
    ip_list = {
      id = cloudflare_zero_trust_list.corporate_ip_allowlist.id
    }
  }]
}

上記で参照している cloudflare_zero_trust_list リソース(type = "IP" で設定)は、リスト を参照してください。

Block ポリシーは、例外を切り出す Allow ポリシー と組み合わせて使うのが最適です。Access はデフォルトですべてのリクエストを拒否するため、Block ポリシーに一致しないユーザーも、Allow ポリシーに一致しなければ拒否されます。

高リスクユーザーを除外する

Cloudflare User Risk Scores で異常な行動のユーザーにフラグを付けている場合、機密アプリケーションへのアクセスから高リスクユーザーを除外できます。ユーザーの行動がリスクレベルの変更を引き起こしたときに、手動対応なしでアクセスを自動制限する動的な安全策として役立ちます。

アクション ルールタイプ セレクター
Allow Include Emails ending in @example.com
Exclude ユーザーリスクスコア

Required API token permissions

At least one of the following token permissions is required:
  • Access: Apps and Policies Write
Create an Access reusable policybash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/policies" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Exclude high-risk users",
		"decision": "allow",
		"include": [
				{
						"email_domain": {
								"domain": "example.com"
						}
				}
		],
		"exclude": [
				{
						"user_risk_score": {
								"user_risk_score": [
										"high"
								]
						}
				}
		]
	}'

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Access: Apps and Policies Write

cloudflare_zero_trust_access_policy リソースを設定します。

resource "cloudflare_zero_trust_access_policy" "exclude_high_risk_users" {
  account_id = var.cloudflare_account_id
  name       = "Exclude high-risk users"
  decision   = "allow"
  include = [{
    email_domain = {
      domain = "example.com"
    }
  }]
  exclude = [{
    user_risk_score = {
      user_risk_score = ["high"]
    }
  }]
}

この例では、Include ルールに一致していても、高リスクとスコア付けされたユーザーは除外されます。リスクスコアの算出方法とリスク行動の設定は ユーザーリスクスコア を参照してください。

サービストークンでサービスを認証する

CI/CD パイプライン、監視システム、バックエンド API などの自動サービスは、対話型ログインなしで保護されたアプリケーションにアクセスする必要があります。Service Auth ポリシーは、有効な サービストークン ヘッダーを提示するリクエストを認証し、マシン間通信を許可します。追加のセキュリティとして、トークンを特定の IP 範囲からのリクエストに制限し、既知のインフラからのみ使えるようにできます。

アクション ルールタイプ セレクター
Service Auth Include Service Token My service token
Require IP ranges 192.0.2.0/24

Required API token permissions

At least one of the following token permissions is required:
  • Access: Apps and Policies Write
Create an Access reusable policybash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/policies" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Authenticate service with service token",
		"decision": "non_identity",
		"include": [
				{
						"service_token": {
								"token_id": "<SERVICE_TOKEN_ID>"
						}
				}
		],
		"require": [
				{
						"ip": {
								"ip": "192.0.2.0/24"
						}
				}
		]
	}'

サービストークンの ID を取得するには、List service tokens エンドポイントを使います。

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Access: Apps and Policies Write

cloudflare_zero_trust_access_policy リソースを設定します。

resource "cloudflare_zero_trust_access_policy" "authenticate_service_with_token" {
  account_id = var.cloudflare_account_id
  name       = "Authenticate service with service token"
  decision   = "non_identity"
  include = [{
    service_token = {
      token_id = cloudflare_zero_trust_access_service_token.my_service_token.id
    }
  }]
  require = [{
    ip = {
      ip = "192.0.2.0/24"
    }
  }]
}

上記で参照している cloudflare_zero_trust_access_service_token リソースの設定は サービストークン を参照してください。

相互 TLS でサービスを認証する

証明書ベースの認証が必要な環境では、相互 TLS(mTLS) を使い、接続元クライアントが想定どおりの身元を持つ有効な証明書を提示することを検証できます。mTLS は、ID プロバイダーを使わない自動システムや IoT デバイスの認証、または IdP でもログインするチームメンバー向けの追加認証要素として役立ちます。

特定のクライアントにアクセスを制限するには、Common Name セレクターを使い、クライアント証明書内の身元に一致させます。

アクション ルールタイプ セレクター
Service Auth Include Common Name John Doe

Required API token permissions

At least one of the following token permissions is required:
  • Access: Apps and Policies Write
Create an Access reusable policybash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/policies" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Authenticate service with mTLS",
		"decision": "non_identity",
		"include": [
				{
						"common_name": {
								"common_name": "John Doe"
						}
				}
		]
	}'

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Access: Apps and Policies Write

cloudflare_zero_trust_access_policy リソースを設定します。

resource "cloudflare_zero_trust_access_policy" "authenticate_service_with_mtls" {
  account_id = var.cloudflare_account_id
  name       = "Authenticate service with mTLS"
  decision   = "non_identity"
  include = [{
    common_name = {
      common_name = "John Doe"
    }
  }]
}

自社 CA が署名した有効な証明書を提示する任意のクライアントを許可するには、Valid Certificate セレクターを使います。CA が発行したすべての証明書を信頼し、特定の Common Name を確認する必要がない場合に役立ちます。

アクション ルールタイプ セレクター
Service Auth Include Valid Certificate

Required API token permissions

At least one of the following token permissions is required:
  • Access: Apps and Policies Write
Create an Access reusable policybash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/policies" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Authenticate service with valid certificate",
		"decision": "non_identity",
		"include": [
				{
						"certificate": {}
				}
		]
	}'

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Access: Apps and Policies Write

cloudflare_zero_trust_access_policy リソースを設定します。

resource "cloudflare_zero_trust_access_policy" "authenticate_service_with_valid_certificate" {
  account_id = var.cloudflare_account_id
  name       = "Authenticate service with valid certificate"
  decision   = "non_identity"
  include = [{
    certificate = {}
  }]
}

機密アプリケーションに利用目的の記入を必須にする

データベース管理ツール、本番コンソール、人事システムなどのアプリケーションでは、アクセスのたびに書面での理由を求められます。これにより、セキュリティチームがアクセス理由を把握できる監査証跡が残ります。利用目的の入力画面は、ユーザーが認証したあと、アプリケーションに到達する前に表示されます。詳細は 利用目的の記入を必須にする を参照してください。

アクション ルールタイプ セレクター
Allow Include Okta Groups IT Administrators
Require Gateway Gateway
Require OS Version Latest version of Windows

Additional settings: Purpose justification をオンにします。

Required API token permissions

At least one of the following token permissions is required:
  • Access: Apps and Policies Write
Create an Access reusable policybash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/policies" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Require purpose justification for sensitive apps",
		"decision": "allow",
		"include": [
				{
						"okta": {
								"name": "IT Administrators",
								"identity_provider_id": "<OKTA_IDP_ID>"
						}
				}
		],
		"require": [
				{
						"device_posture": {
								"integration_uid": "<GATEWAY_CHECK_ID>"
						}
				},
				{
						"device_posture": {
								"integration_uid": "<WINDOWS_VERSION_CHECK_ID>"
						}
				}
		],
		"purpose_justification_required": true,
		"purpose_justification_prompt": "Please enter a justification for accessing this application."
	}'

okta ルールは、ID プロバイダーに適したルール に置き換えます。ID プロバイダー ID の取得には、List Access identity providers エンドポイントを使います。デバイスポスチャチェックの integration UID の取得には、List device posture checks エンドポイントを使います。

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Access: Apps and Policies Write

cloudflare_zero_trust_access_policy リソースを設定します。

resource "cloudflare_zero_trust_access_policy" "require_purpose_justification" {
  account_id                      = var.cloudflare_account_id
  name                            = "Require purpose justification for sensitive apps"
  decision                        = "allow"
  purpose_justification_required  = true
  purpose_justification_prompt    = "Please enter a justification for accessing this application."
  include = [{
    okta = {
      name                 = "IT Administrators"
      identity_provider_id = cloudflare_zero_trust_access_identity_provider.okta.id
    }
  }]
  require = [
    {
      device_posture = {
        integration_uid = cloudflare_zero_trust_device_posture_rule.gateway_check.id
      }
    },
    {
      device_posture = {
        integration_uid = cloudflare_zero_trust_device_posture_rule.windows_version.id
      }
    },
  ]
}

利用目的の記入は 一時認証 と組み合わせ、アクセス付与前に指定したレビュアーの承認も必須にできます。

公開エンドポイントをバイパスする

一部のアプリケーションには、OAuth コールバック URL、Webhook 受信、ヘルスチェックパスなど、公開到達が必要なエンドポイントがあります。特定の アプリケーションパス にスコープした Bypass ポリシーを作成し、そのエンドポイントだけ Access の適用を無効にできます。たとえば、アプリケーションが app.example.com の場合、app.example.com/oauth/callback 用に別の Access アプリケーションを作成し、次の Bypass ポリシーを適用できます。

アクション ルールタイプ セレクター
Bypass Include Everyone Everyone

Required API token permissions

At least one of the following token permissions is required:
  • Access: Apps and Policies Write
Create an Access reusable policybash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/policies" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Bypass public endpoint",
		"decision": "bypass",
		"include": [
				{
						"everyone": {}
				}
		]
	}'

必要な API トークン権限

次の トークン権限 のうち、少なくとも 1 つが必要です。

  • Access: Apps and Policies Write

cloudflare_zero_trust_access_policy リソースを設定します。

resource "cloudflare_zero_trust_access_policy" "bypass_public_endpoint" {
  account_id = var.cloudflare_account_id
  name       = "Bypass public endpoint"
  decision   = "bypass"
  include = [{
    everyone = {}
  }]
}

役に立ちましたか?