Skip to content

Commit 4f9de6a

Browse files
committed
Add network API example
1 parent 82ffb32 commit 4f9de6a

File tree

3 files changed

+48
-14
lines changed

3 files changed

+48
-14
lines changed

src/content/partials/cloudflare-one/gateway/get-started/create-dns-policy.mdx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ To create a new DNS policy:
3737
--header "X-Auth-Email: <EMAIL>" \
3838
--header "X-Auth-Key: <API_KEY>" \
3939
--data '{
40-
"action": "allow",
41-
"name": "Block security risks",
42-
"description": "Block all default Cloudflare security categories",
43-
"device_posture": "any(device_posture.checks.passed[*] in {})",
44-
"enabled": true,
45-
"filters": [
46-
"dns"
47-
],
48-
"precedence": 0,
49-
"traffic": "any(dns.security_category[*] in {68 178 80 83 176 175 117 131 134 151 153})"
40+
"name": "Block security risks",
41+
"description": "Block all default Cloudflare security categories",
42+
"precedence": 0,
43+
"enabled": true,
44+
"action": "block",
45+
"filters": [
46+
"dns"
47+
],
48+
"traffic": "any(dns.security_category[*] in {68 178 80 83 176 175 117 131 134 151 153})"
5049
}'
5150
```
5251

src/content/partials/cloudflare-one/gateway/get-started/create-network-policy.mdx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
{}
33
---
44

5-
import { Render } from "~/components";
5+
import { Render, Tabs, TabItem } from "~/components";
6+
7+
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
68

79
To create a new network policy:
810

@@ -17,4 +19,37 @@ To create a new network policy:
1719
/>
1820
6. Select **Create policy**.
1921

22+
</TabItem>
23+
24+
<TabItem label="API">
25+
26+
1. [Create an API token](/fundamentals/api/get-started/create-token/) with the following permissions:
27+
28+
| Type | Item | Permission |
29+
| ------- | ---------- | ---------- |
30+
| Account | Zero Trust | Edit |
31+
32+
2. (Optional) Configure your API environment variables to include your [account ID](/fundamentals/setup/find-account-and-zone-ids/), email address, and API token.
33+
3. Send a `POST` request to the [Create a Zero Trust Gateway rule](/api/operations/zero-trust-gateway-rules-create-zero-trust-gateway-rule) endpoint. For example, you can use a list of [device serial numbers](/cloudflare-one/identity/devices/warp-client-checks/corp-device/) to ensure users can only access an application if they connect with the WARP client from a company device:
34+
35+
```bash title="curl API example"
36+
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/gateway/rules \
37+
--header "X-Auth-Email: <EMAIL>" \
38+
--header "X-Auth-Key: <API_KEY>" \
39+
--data '{
40+
"name": "Enforce device posture",
41+
"description": "Ensure only devices in Zero Trust organization can connect to application",
42+
"precedence": 0,
43+
"enabled": true,
44+
"action": "block",
45+
"filters": [
46+
"l4"
47+
],
48+
"traffic": "any(net.sni.domains[*] == \"internalapp.com\")",
49+
"device_posture": "not(any(device_posture.checks.passed[*] in {\"<LIST_UUID>\"}))"
50+
}'
51+
```
52+
53+
</TabItem> </Tabs>
54+
2055
For more information, refer to [network policies](/cloudflare-one/policies/gateway/network-policies/).

src/content/partials/cloudflare-one/gateway/policies/enforce-device-posture.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
{}
33
---
44

5-
In the following example, you can use a list of [device serial numbers](/cloudflare-one/identity/devices/warp-client-checks/corp-device/) to ensure users can only access an application if they connect with the WARP client from a company device:
5+
For example, you can use a list of [device serial numbers](/cloudflare-one/identity/devices/warp-client-checks/corp-device/) to ensure users can only access an application if they connect with the WARP client from a company device:
66

77
| Selector | Operator | Value | Logic | Action |
88
| ---------------------------- | -------- | ----------------------- | ----- | ------ |
9-
| Passed Device Posture Checks | not in | _Device serial numbers_ | And | Block |
10-
| SNI Domain | is | `internalapp.com` | | |
9+
| SNI Domain | is | `internalapp.com` | And | Block |
10+
| Passed Device Posture Checks | not in | _Device serial numbers_ | | |

0 commit comments

Comments
 (0)