Skip to content

Commit c5ec054

Browse files
turnstile maintenance (#24918)
1 parent 9e1f230 commit c5ec054

File tree

12 files changed

+239
-192
lines changed

12 files changed

+239
-192
lines changed

src/content/docs/cloudflare-challenges/concepts/clearance.mdx

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Clearance
44
sidebar:
55
order: 2
66
---
7-
import { Render } from "~/components";
7+
import { Render, DashButton, Steps } from "~/components";
88

99
## `cf_clearance` cookies
1010

@@ -78,17 +78,24 @@ For more details on managing hostnames, refer to the [Hostname Management docume
7878

7979
#### Enable pre-clearance on a new site
8080

81-
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/login) and select your account.
82-
2. Go to **Turnstile** > **Add widget**.
83-
3. Under **Would you like to opt for pre-clearance for this site?** select **Yes**.
84-
4. Choose the pre-clearance level from the select box.
85-
5. Select **Create**.
81+
<Steps>
82+
1. In the Cloudflare dashboard, go to the **Turnstile** page.
83+
84+
<DashButton url="/?to=/:account/turnstile" />
85+
2. Select **Add widget**.
86+
3. Under **Would you like to opt for pre-clearance for this site?** select **Yes**.
87+
4. Choose the pre-clearance level from the select box.
88+
5. Select **Create**.
89+
</Steps>
8690

8791
#### Enable pre-clearance on an existing site
8892

89-
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/login) and select your account.
90-
2. Go to **Turnstile**.
91-
3. Go to the existing widget or site and select **Settings**.
92-
4. Under **Would you like to opt for pre-clearance for this site?** select **Yes**.
93-
5. Choose the pre-clearance level from the select box.
94-
6. Select **Update**.
93+
<Steps>
94+
1. In the Cloudflare dashboard, go to the **Turnstile** page.
95+
96+
<DashButton url="/?to=/:account/turnstile" />
97+
2. Go to the existing widget or site and select **Settings**.
98+
3. Under **Would you like to opt for pre-clearance for this site?** select **Yes**.
99+
4. Choose the pre-clearance level from the select box.
100+
5. Select **Update**.
101+
</Steps>

src/content/docs/turnstile/additional-configuration/hostname-management.mdx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ sidebar:
66

77
---
88

9+
import { DashButton, Steps } from "~/components"
10+
911
You can associate hostnames with your widget to control where it can be used using Hostname Management. Managing your hostnames ensures that Turnstile works seamlessly with your setup, whether you add standalone hostnames or leverage zones registered to your Cloudflare account.
1012

1113
## Hostname limits
@@ -22,12 +24,15 @@ You can add a hostname to your Turnstile widget even if it is not on the Cloudfl
2224

2325
To add a custom hostname:
2426

25-
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/) and select your account.
26-
2. Go to **Turnstile**.
27-
3. On an existing widget, select **Settings**.
28-
4. Select **Add Hostnames** under Hostname Management.
29-
5. Add a custom hostname or choose from an existing hostname.
30-
6. Select **Add**.
27+
<Steps>
28+
1. In the Cloudflare dashboard, go to the **Turnstile** page.
29+
30+
<DashButton url="/?to=/:account/turnstile" />
31+
2. On an existing widget, select **Settings**.
32+
3. Select **Add Hostnames** under Hostname Management.
33+
4. Add a custom hostname or choose from an existing hostname.
34+
5. Select **Add**.
35+
</Steps>
3136

3237
## Add hostnames with a registered zone
3338

src/content/docs/turnstile/extensions/google-firebase.mdx

Lines changed: 70 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,88 +7,100 @@ sidebar:
77

88
---
99

10+
import { Steps, DashButton } from "~/components"
11+
1012
Turnstile is [available as an extension](https://extensions.dev/extensions/cloudflare/cloudflare-turnstile-app-check-provider) with [Google's Firebase](https://firebase.google.com/) platform as an [App Check](https://firebase.google.com/docs/app-check) provider. You can leverage Cloudflare Turnstile's bot detection and challenge capabilities to ensure that requests to your Firebase backend services are verified and only authentic human visitors can interact with your application.
1113

1214
Google Firebase is a comprehensive app development platform that provides a variety of tools and services to help developers build, improve, and grow their mobile and web applications.
1315

1416
Firebase App Check helps protect Firebase resources like Cloud Firestore, Realtime Database, Cloud Storage, and Functions from abuse, such as automated fraud attacks and denial of service (DoS) attacks, by ensuring that incoming requests are from legitimate visitors and trusted sources.
1517

16-
## Set up a Google Firebase project
18+
## 1. Set up a Google Firebase project
1719

18-
1. Create a Firebase project by going to the [Firebase Console](https://console.firebase.google.com/).
19-
2. Select **Add Project** and follow the prompts to create a new project.
20-
3. Add an app to your project by selecting your project.
21-
4. In the project overview, select **Add App** and choose the platform: **Web**.
22-
5. [Register your app](https://firebase.google.com/docs/web/setup?hl=en&authuser=0#register-app) and follow the guide to get your Firebase configuration.
20+
<Steps>
21+
1. Create a Firebase project by going to the [Firebase Console](https://console.firebase.google.com/).
22+
2. Select **Add Project** and follow the prompts to create a new project.
23+
3. Add an app to your project by selecting your project.
24+
4. In the project overview, select **Add App** and choose the platform: **Web**.
25+
5. [Register your app](https://firebase.google.com/docs/web/setup?hl=en&authuser=0#register-app) and follow the guide to get your Firebase configuration.
26+
</Steps>
2327

2428
:::note
2529

2630
It is important to register your web app first to connect it with Turnstile later.
2731
:::
2832

29-
## Set up Cloudflare Turnstile
33+
## 2. Set up Cloudflare Turnstile
3034

31-
1. Create a Cloudflare Turnstile site by going to the [Cloudflare Turnstile dashboard](https://dash.cloudflare.com/?to=/:account/turnstile).
32-
2. Create a new widget and get the [sitekey and secret key](/turnstile/get-started/#get-a-sitekey-and-secret-key).
33-
- The domain you configure with the Turnstile widget should be the domain of your web app.
34-
- The [widget mode](/turnstile/concepts/widget/) must be **Invisible**.
35+
<Steps>
36+
1. Create a Cloudflare Turnstile site by going to the [Cloudflare Turnstile dashboard](https://dash.cloudflare.com/?to=/:account/turnstile).
37+
2. Create a new widget and get the [sitekey and secret key](/turnstile/get-started/#get-a-sitekey-and-secret-key).
38+
- The domain you configure with the Turnstile widget should be the domain of your web app.
39+
- The [widget mode](/turnstile/concepts/widget/) must be **Invisible**.
40+
</Steps>
3541

36-
## Integrate Firebase App Check with Turnstile
42+
## 3. Integrate Firebase App Check with Turnstile
3743

38-
### Enable App Check in Firebase
44+
### 3a. Enable App Check in Firebase
3945

40-
1. Go to [Cloudflare Turnstile in the Firebase Extensions hub](https://extensions.dev/extensions/cloudflare/cloudflare-turnstile-app-check-provider).
41-
2. Install the Cloudflare Turnstile extension to your Firebase project.
42-
3. Enable [Cloud Functions](https://cloud.google.com/functions?hl=en), [Artifact Registry](https://cloud.google.com/artifact-registry), and [Secret Manager](https://cloud.google.com/security/products/secret-manager?hl=en).
43-
4. Enter the secret key from Cloudflare Turnstile and your Firebase App ID.
44-
5. Select **Install extension**.
46+
<Steps>
47+
1. Go to [Cloudflare Turnstile in the Firebase Extensions hub](https://extensions.dev/extensions/cloudflare/cloudflare-turnstile-app-check-provider).
48+
2. Install the Cloudflare Turnstile extension to your Firebase project.
49+
3. Enable [Cloud Functions](https://cloud.google.com/functions?hl=en), [Artifact Registry](https://cloud.google.com/artifact-registry), and [Secret Manager](https://cloud.google.com/security/products/secret-manager?hl=en).
50+
4. Enter the secret key from Cloudflare Turnstile and your Firebase App ID.
51+
5. Select **Install extension**.
52+
</Steps>
4553

46-
### Grant access to the Cloudflare extension
54+
### 3b. Grant access to the Cloudflare extension
4755

48-
1. Grant access to the Cloudflare extension under the IAM section of your project by selecting **Grant Access** under **View by Principals**.
49-
2. Select `ext-cloudflare-turnstile` from the dropdown menu.
50-
3. When filtering the token, select **Service Account Token Creator**.
56+
<Steps>
57+
1. Grant access to the Cloudflare extension under the IAM section of your project by selecting **Grant Access** under **View by Principals**.
58+
2. Select `ext-cloudflare-turnstile` from the dropdown menu.
59+
3. When filtering the token, select **Service Account Token Creator**.
60+
</Steps>
5161

52-
### Configure Firebase in your app with Turnstile
62+
### 3c. Configure Firebase in your app with Turnstile
5363

54-
1. Create an `index.ts` file.
55-
2. Add your Firebase configuration.
64+
<Steps>
65+
1. Create an `index.ts` file.
66+
2. Add your Firebase configuration.
5667

57-
```js
58-
import { initializeApp } from "firebase/app";
59-
import { getAppCheck, initializeAppCheck } from "firebase/app-check";
60-
import {
61-
CloudflareProviderOptions,
62-
} from '@cloudflare/turnstile-firebase-app-check';
63-
64-
const firebaseConfig = {
65-
apiKey: "YOUR_API_KEY",
66-
authDomain: "YOUR_PROJECT_ID.firebaseapp.com",
67-
projectId: "YOUR_PROJECT_ID",
68-
storageBucket: "YOUR_PROJECT_ID.appspot.com",
69-
messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
70-
appId: "YOUR_APP_ID",
71-
};
72-
73-
const app = initializeApp(firebaseConfig);
74-
75-
// Initialize App Check
76-
const siteKey = 'YOUR-SITEKEY';
77-
const HTTP_ENDPOINT = '${function:ext-cloudflare-turnstile-app-check-provider-tokenExchange.url}';
78-
79-
const cpo = new CloudflareProviderOptions(HTTP_ENDPOINT, siteKey);
80-
const provider = new CustomProvider(cpo);
81-
82-
initializeAppCheck(app, { provider });
83-
84-
// retrieve App Check token from Cloudflare Turnstile
85-
cpo.getToken().then(({ token }) => {
86-
document.getElementById('app-check-token').innerHTML = token;
87-
});
68+
```js
69+
import { initializeApp } from "firebase/app";
70+
import { getAppCheck, initializeAppCheck } from "firebase/app-check";
71+
import {
72+
CloudflareProviderOptions,
73+
} from '@cloudflare/turnstile-firebase-app-check';
74+
75+
const firebaseConfig = {
76+
apiKey: "YOUR_API_KEY",
77+
authDomain: "YOUR_PROJECT_ID.firebaseapp.com",
78+
projectId: "YOUR_PROJECT_ID",
79+
storageBucket: "YOUR_PROJECT_ID.appspot.com",
80+
messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
81+
appId: "YOUR_APP_ID",
82+
};
83+
84+
const app = initializeApp(firebaseConfig);
85+
86+
// Initialize App Check
87+
const siteKey = 'YOUR-SITEKEY';
88+
const HTTP_ENDPOINT = '${function:ext-cloudflare-turnstile-app-check-provider-tokenExchange.url}';
89+
90+
const cpo = new CloudflareProviderOptions(HTTP_ENDPOINT, siteKey);
91+
const provider = new CustomProvider(cpo);
92+
93+
initializeAppCheck(app, { provider });
94+
95+
// retrieve App Check token from Cloudflare Turnstile
96+
cpo.getToken().then(({ token }) => {
97+
document.getElementById('app-check-token').innerHTML = token;
98+
});
8899

89-
```
100+
```
101+
</Steps>
90102

91-
### Verify the App Check token in your web application
103+
### 3d. Verify the App Check token in your web application
92104

93105
To verify the App Check token in your web application, refer to Firebase's [Token Verification guide](https://firebase.google.com/docs/app-check/custom-resource-backend?hl=en#verification).
94106

src/content/docs/turnstile/get-started/client-side-rendering/widget-configurations.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ Turnstile widgets can be implemented using implicit or explicit rendering.
1919

2020
**How it works**
2121
<Steps>
22-
1. Add the Turnstile script to your page.
23-
2. Include `<div class="cf-turnstile" data-sitekey="your-key"></div>` elements.
24-
3. Widgets will render automatically when the page loads.
25-
4. Configure the widget using `data-*` attributes on the HTML element.
22+
1. Add the Turnstile script to your page.
23+
2. Include `<div class="cf-turnstile" data-sitekey="your-key"></div>` elements.
24+
3. Widgets will render automatically when the page loads.
25+
4. Configure the widget using `data-*` attributes on the HTML element.
2626
</Steps>
2727

2828
```html title="Example" wrap
@@ -35,10 +35,10 @@ Turnstile widgets can be implemented using implicit or explicit rendering.
3535

3636
**How it works**
3737
<Steps>
38-
1. Add the Turnstile script with `?render=explicit` parameter.
39-
2. Create container elements (without the `cf-turnstile` class).
40-
3. Call `turnstile.render()` function when you want to create widgets.
41-
4. Configure the widget using JavaScript object parameters.
38+
1. Add the Turnstile script with `?render=explicit` parameter.
39+
2. Create container elements (without the `cf-turnstile` class).
40+
3. Call `turnstile.render()` function when you want to create widgets.
41+
4. Configure the widget using JavaScript object parameters.
4242
</Steps>
4343

4444
```html title="Example" wrap

src/content/docs/turnstile/get-started/widget-management/dashboard.mdx

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,29 @@ sidebar:
55
order: 1
66
---
77

8-
import { Steps } from "~/components";
8+
import { Steps, DashButton } from "~/components";
99

1010

1111
The Cloudflare dashboard provides a user-friendly interface for creating and managing widgets.
1212

1313
## Create a widget
1414

1515
<Steps>
16-
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/), and select your account.
17-
2. Go to **Turnstile**.
18-
3. Select **Add widget**.
19-
4. Fill out the required information:
16+
1. In the Cloudflare dashboard, go to the **Turnstile** page.
17+
18+
<DashButton url="/?to=/:account/turnstile" />
19+
2. Select **Add widget**.
20+
3. Fill out the required information:
2021
- **Widget name**: A descriptive name for your widget.
2122
- **Hostname management**: Domains where the widget will be used.
2223
- **Widget mode**: Choose from Managed, Non-Interactive, or Invisible.
23-
5. (Optional) Configure **Pre-clearance support** for single-page applications.
24-
6. Select **Create** to save your widget.
25-
7. Copy your sitekey and secret key, and store the secret key securely.
24+
4. (Optional) Configure **Pre-clearance support** for single-page applications.
25+
5. Select **Create** to save your widget.
26+
6. Copy your sitekey and secret key, and store the secret key securely.
2627
</Steps>
2728

2829
## Manage existing widgets
2930

30-
### View widget details
31+
You can view your widget details on the Cloudflare dashboard by selecting any existing widget to access analytics, settings, and performance metrics.
3132

32-
<Steps>
33-
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/), and select your account.
34-
2. Go to **Turnstile**.
35-
3. Select any existing widget to view its configuration.
36-
4. Access analytics, settings, and performance metrics.
37-
</Steps>
38-
39-
### Update widget configuration
40-
41-
<Steps>
42-
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/), and select your account.
43-
2. Go to **Turnstile**.
44-
3. Select any existing widget to view its configuration.
45-
4. Select **Settings**.
46-
5. Modify hostnames, mode, or other settings.
47-
6. Select **Save** to apply changes.
48-
</Steps>
33+
To update the widget configuration, go to any existing widget and select **Settings**. Select **Save** to apply your changes.

0 commit comments

Comments
 (0)