You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/bots/concepts/bot/verified-bots/web-bot-auth.mdx
+16-8Lines changed: 16 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,21 +40,23 @@ You need to generate a signing key which will be used to authenticate your bot's
40
40
41
41
By following these steps, you have generated a private key and a public key, then converted the public key to a JWK.
42
42
43
+
:::note
44
+
You can also [generate a JavaScript key using WebCrypto API](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/generateKey), which will produce a key in the correct JWK format.
45
+
46
+
Many existing [JWK libraries](https://jwt.io/libraries) support WebCrypto API for generating JavaScript key.
47
+
:::
48
+
43
49
## 2. Host a key directory
44
50
45
51
You need to host a key directory which creates a way for your bot to authenticate its requests to Cloudflare.
46
52
This directory should follow the definition from the active IETF draft [draft-meunier-http-message-signatures-directory-01](https://datatracker.ietf.org/doc/html/draft-meunier-http-message-signatures-directory-01).
47
53
48
54
<Steps>
49
-
1. Host a key directory at a well known message signatures directory. The key directory should serve a JSON Web Key Set (JWKS) including the public key derived from your signing key.
50
-
51
-
An example directory would be:
52
-
```txt
53
-
/.well-known/http-message-signatures-directory/
54
-
```
55
+
1. Host a key directory at `/.well-known/http-message-signatures-directory/` (note that this is a requirement). This key directory should serve a JSON Web Key Set (JWKS) including the public key derived from your signing key.
55
56
2. Serve the web page over HTTPS (not HTTP).
56
57
3.[Calculate the base64 URL-encoded JWK thumbprint](https://www.rfc-editor.org/rfc/rfc8037.html#appendix-A.3) associated with your Ed25519 public key.
57
58
4. Sign your HTTP response using the HTTP message signature specification by attaching one signature per key in your key directory. This ensures no one else can mirror your directory and attempt to register on your behalf. Your response must include the following headers:
59
+
-`Content-Type`: This header must have the value `application/http-message-signatures-directory+json`.
58
60
-`Signature`: Construct a [`Signature` header](https://www.rfc-editor.org/rfc/rfc9421#name-the-signature-http-field) over your chosen components.
59
61
-`Signature-Input`: Construct a [`Signature-Input` header](https://www.rfc-editor.org/rfc/rfc9421#name-the-signature-input-http-fi) over your chosen components. The header must meet the following requirements.
60
62
| Required component parameter | Requirement |
@@ -131,7 +133,12 @@ A component is either an HTTP header, or any [derived components](https://www.rf
131
133
:::note[Use components with only ASCII values]
132
134
Cloudflare currently does not support `bs` or `sf` parameter designed to serialize non-ASCII values into ASCII equivalents.
133
135
:::
134
-
- Add a `Content-Digest` header if you wish to sign your [message content](https://www.rfc-editor.org/rfc/rfc9421#name-message-content), then specify `Content-Digest` as a component to sign.
136
+
137
+
:::caution[`Content-Digest` header]
138
+
If you wish to sign your [message content](https://www.rfc-editor.org/rfc/rfc9421#name-message-content) using a `Content-Digest` header, note that you should only do so if there is zero risk of a message being altered on the way to Cloudflare.
139
+
140
+
For example, if the message is unencrypted and proxied to Cloudflare, you should not use `Content-Digest`.
141
+
:::
135
142
136
143
### 4.2. Calculate the JWK thumbprint
137
144
@@ -190,4 +197,5 @@ You may wish to refer to the following resources.
190
197
- Link to new blog TBC.
191
198
- Cloudflare blog: [Forget IPs: using cryptography to verify bot and agent traffic](https://blog.cloudflare.com/web-bot-auth/).
192
199
- Cloudflare's [`web-bot-auth` library in Rust](https://crates.io/crates/web-bot-auth).
193
-
- Cloudflare's [`web-bot-auth` npm package in Typescript](https://www.npmjs.com/package/web-bot-auth).
200
+
- Cloudflare's [`web-bot-auth` npm package in Typescript](https://www.npmjs.com/package/web-bot-auth).
The following derived components are not supported, and we will fail to verify a message if they are included:
188
188
189
-
-`@query-params`: Cloudflare recommends signing the whole query instead of an individual parameter.
189
+
-`@query-params`: Cloudflare recommends signing the whole query using the `@query` component instead of signing an individual parameter.
190
190
-`@status`: This is not possible to include in the request path.
191
191
192
192
The following component parameters defined in IETF RFC 9421 are not supported, and Cloudflare will fail to verify a message if they are included:
@@ -211,13 +211,13 @@ Instead, Cloudflare recommends short `expires` as a protection against replay at
211
211
212
212
### How do I know my JSON Web Key set directory will be accepted?
213
213
214
-
Cloudflare uses [`http-signature-directory` tool](https://crates.io/crates/http-signature-directory) to validate your directory. Please your this works before submitting a verification request.
214
+
Cloudflare uses [`http-signature-directory` tool](https://crates.io/crates/http-signature-directory) to validate your directory. Please ensure this works against your directory before registering with us.
215
215
216
216
---
217
217
218
218
### My message is failing validation. What could be the cause?
219
219
220
-
- Ensure you have a [`Signature-Agent` header](/bots/concepts/bot/verified-bots/web-bot-auth/#signature-agent-header), and that its value in double-quotes.
220
+
- Ensure you have a [`Signature-Agent` header](/bots/concepts/bot/verified-bots/web-bot-auth/#signature-agent-header), and that its value is in double-quotes.
221
221
- Ensure you include `signature-agent` in the component list in your [`Signature-Input` header](/bots/concepts/bot/verified-bots/web-bot-auth/#signature-agent-header).
222
222
- Ensure your `expires` timestamp is not too short, such that, by the time it arrives at Cloudflare servers, it has already expired. A minute is often sufficient.
223
223
- Ensure you are not signing components containing non-ASCII values, or on the unsupported list.
0 commit comments