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/waf/custom-rules/use-cases/configure-token-authentication.mdx
+44-2Lines changed: 44 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -166,7 +166,7 @@ You will need to append this parameter to the URL you are protecting:
166
166
The authentication token parameter (`verify=<VALUE>` in the example) must be the last parameter in the query string.
167
167
:::
168
168
169
-
### Testing the generated token parameter
169
+
### Test the generated token parameter
170
170
171
171
If you are on an Enterprise plan, you can test if URLs are being generated correctly on the origin server by doing the following:
172
172
@@ -175,7 +175,7 @@ If you are on an Enterprise plan, you can test if URLs are being generated corre
175
175
176
176
---
177
177
178
-
## Protecting several paths using the same secret
178
+
## Protect several paths using the same secret
179
179
180
180
You can use the same secret key to protect several URI paths.
181
181
@@ -184,3 +184,45 @@ This is illustrated in the previous example, where `http.request.uri` is passed
184
184
Since `http.request.uri` includes the path to the asset and that value is extracted for each request, the validation function evaluates all request URIs to `downloads.example.com` using the same secret key.
185
185
186
186
Note that while you can use the same secret key to authenticate several paths, you must generate an HMAC token for each unique message you want to authenticate.
187
+
188
+
## Protect an entire URI path prefix with a single signature
189
+
190
+
You can protect an entire fixed-length URI path prefix with a single HMAC signature (it would also use the same secret). To achieve this, supply a URI path prefix (instead of the full URI path) and the original query string as the [`MessageMAC`](/ruleset-engine/rules-language/functions/#messagemac) argument for the [`is_timed_hmac_valid_v0()`](/ruleset-engine/rules-language/functions/#hmac-validation) function.
191
+
192
+
Use the [`substring()`](/ruleset-engine/rules-language/functions/#substring) function to obtain the prefix from the full URI path.
193
+
194
+
In the following example, the URI path prefix requiring a single HMAC signature is always 51 characters long (`x` is a character placeholder):
The first two URI paths can use the same HMAC signature because they share the same 51-character prefix (`/case-studies/12345678-90ab-4cde-f012-3456789abcde/`) that is validated by the custom rule.
227
+
228
+
The third URI path needs a different HMAC signature, since the prefix is different.
0 commit comments