Skip to content

Commit 4844691

Browse files
committed
Add API procedure
1 parent 9ab0dba commit 4844691

File tree

1 file changed

+54
-3
lines changed

1 file changed

+54
-3
lines changed

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

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

5-
import { Render } from "~/components";
5+
import { Render, Tabs, TabItem } from "~/components";
66

7-
To create a new DNS policy:
7+
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
88

99
1. In [Zero Trust](https://one.dash.cloudflare.com/), go to **Gateway** > **Firewall policies**.
1010
2. In the **DNS** tab, select **Add a policy**.
@@ -17,4 +17,55 @@ To create a new DNS policy:
1717
/>
1818
6. Select **Create policy**.
1919

20-
For more information, refer to [DNS policies](/cloudflare-one/policies/gateway/dns-policies/).
20+
</TabItem>
21+
22+
<TabItem label="API">
23+
24+
1. Create a custom API token with the following permissions:
25+
26+
| Scope | Application | Action |
27+
| ------- | ----------- | ------ |
28+
| Account | Zero Trust | Edit |
29+
30+
2. (Optional) Configure your API environment variables with your account ID, email address, and API token.
31+
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:
32+
33+
```bash
34+
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/gateway/rules \
35+
--header "X-Auth-Email: <EMAIL>" \
36+
--header "X-Auth-Key: <API_KEY>" \
37+
--header "Content-Type: application/json" \
38+
--data '{
39+
"action": "allow",
40+
"description": "Lisbon team access rule",
41+
"device_posture": "any(device_posture.checks.passed[*] in {})",
42+
"enabled": true,
43+
"expiration": {
44+
"duration": 10,
45+
"expired": false,
46+
"expires_at": "2014-01-01T05:20:20Z"
47+
},
48+
"filters": [
49+
"http"
50+
],
51+
"identity": "any(identity.groups.name[*] in {\"Lisbon-team\"})",
52+
"name": "Lisbon Team Access Rule",
53+
"precedence": 0,
54+
"rule_settings": {
55+
"allow_child_bypass": false
56+
},
57+
"schedule": {
58+
"fri": "08:00-12:30,13:30-17:00",
59+
"mon": "08:00-12:30,13:30-17:00",
60+
"sat": "08:00-12:30,13:30-17:00",
61+
"sun": "08:00-12:30,13:30-17:00",
62+
"thu": "08:00-12:30,13:30-17:00",
63+
"time_zone": "America/New York",
64+
"tue": "08:00-12:30,13:30-17:00",
65+
"wed": "08:00-12:30,13:30-17:00"
66+
},
67+
"traffic": "http.request.uri matches \".*a/partial/uri.*\" and http.request.host in $01302951-49f9-47c9-a400-0297e60b6a10"
68+
}'
69+
```
70+
71+
</TabItem> </Tabs>

0 commit comments

Comments
 (0)