Skip to content

Commit 6f5a673

Browse files
partial
1 parent ee3d7ef commit 6f5a673

File tree

3 files changed

+35
-25
lines changed

3 files changed

+35
-25
lines changed

src/content/docs/api-shield/security/jwt-validation/index.mdx

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar:
66

77
---
88

9-
import { GlossaryTooltip, Steps, Tabs, TabItem } from "~/components"
9+
import { GlossaryTooltip, Steps, Tabs, TabItem, Render } from "~/components"
1010

1111
<GlossaryTooltip term="JSON web token (JWT)">JSON web tokens (JWT)</GlossaryTooltip> are often used as part of an authentication component on many web applications today. Since JWTs are crucial to identifying users and their access, ensuring the token’s integrity is important.
1212

@@ -103,29 +103,7 @@ If you expect to migrate between two different identity providers, you must crea
103103

104104
API Shield will verify JSON Web Tokens regardless of whether or not they have the `Bearer` prefix.
105105

106-
### Rate limit by user (JWT claim)
107-
108-
You can rate limit requests based on any claim inside of a JSON Web Token (JWT), such as registered claims like `aud` or `sub`, or custom claims like `userEmail` or nested custom claims like `user.email`.
109-
110-
Rate limiting based on JWT claim values will only work on valid JSON Web Tokens. If you do not block invalid JSON Web Tokens on your path, the [JWT claims will all be counted and possibly blocked](https://developers.cloudflare.com/waf/rate-limiting-rules/parameters/#missing-field-versus-empty-value) if high traffic is detected in the Point of Presence (PoP).
111-
112-
You must also count the JWT claim that uniquely identifies the user. If you select a claim that is the same for many of your users, their rate limits will all be counted together.
113-
114-
### Rate limit by user tier
115-
116-
If you offer multiple tiers on your website or application and you want to enforce rate limiting based on the tiers, such as:
117-
118-
- If `"aud": "free-tier"`, rate limit to five requests per minute
119-
- If `"aud": "premium-tier"`, rate limit to 50 requests per minute
120-
121-
You can follow the rate limiting rule example below:
122-
123-
```txt title="Rule example"
124-
(http.request.method eq "GET" and
125-
http.host eq "<YOUR_DOMAIN>" and
126-
http.request.uri.path matches "</EXAMPLE_PATH>" and
127-
lookup_json_string(http.request.jwt.claims["<JWT_TOKEN_CONFIGURATION_ID>"][0], "aud") eq "free-tier"
128-
```
106+
<Render file="rate-limit-user" />
129107

130108
## Availability
131109

src/content/docs/api-shield/security/volumetric-abuse-detection.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar:
77

88
---
99

10-
import { GlossaryTooltip, Steps } from "~/components"
10+
import { GlossaryTooltip, Steps, Render } from "~/components"
1111

1212
Cloudflare Volumetric Abuse Detection helps you set up a system of adaptive rate limiting.
1313

@@ -60,6 +60,10 @@ Refer to the [Rules documentation](https://developers.cloudflare.com/waf/rate-li
6060

6161
[Rate limit recommendations are available via the API](/api/resources/api_gateway/subresources/operations/methods/get/) if you would like to dynamically update rate limits over time.
6262

63+
## Special cases
64+
65+
<Render file="rate-limit-user" />
66+
6367
## Limitations
6468

6569
API Shield will always calculate recommendations when session identifiers are configured. To enable session-based rate limits, [subscribe to Advanced Rate Limiting](/waf/rate-limiting-rules/#availability).
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
{}
3+
4+
---
5+
6+
### Rate limit by user (JWT claim)
7+
8+
You can rate limit requests based on any claim inside of a JSON Web Token (JWT), such as registered claims like `aud` or `sub`, or custom claims like `userEmail` or nested custom claims like `user.email`.
9+
10+
Rate limiting based on JWT claim values will only work on valid JSON Web Tokens. If you do not block invalid JSON Web Tokens on your path, the [JWT claims will all be counted and possibly blocked](https://developers.cloudflare.com/waf/rate-limiting-rules/parameters/#missing-field-versus-empty-value) if high traffic is detected in the Point of Presence (PoP).
11+
12+
You must also count the JWT claim that uniquely identifies the user. If you select a claim that is the same for many of your users, their rate limits will all be counted together.
13+
14+
### Rate limit by user tier
15+
16+
If you offer multiple tiers on your website or application and you want to enforce rate limiting based on the tiers, such as:
17+
18+
- If `"aud": "free-tier"`, rate limit to five requests per minute
19+
- If `"aud": "premium-tier"`, rate limit to 50 requests per minute
20+
21+
You can follow the rate limiting rule example below:
22+
23+
```txt title="Rule example"
24+
(http.request.method eq "GET" and
25+
http.host eq "<YOUR_DOMAIN>" and
26+
http.request.uri.path matches "</EXAMPLE_PATH>" and
27+
lookup_json_string(http.request.jwt.claims["<JWT_TOKEN_CONFIGURATION_ID>"][0], "aud") eq "free-tier"
28+
```

0 commit comments

Comments
 (0)