|
6 | 6 |
|
7 | 7 | --- |
8 | 8 |
|
9 | | -import { GlossaryTooltip, Steps, Tabs, TabItem } from "~/components" |
| 9 | +import { GlossaryTooltip, Steps, Tabs, TabItem, Render } from "~/components" |
10 | 10 |
|
11 | 11 | <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. |
12 | 12 |
|
@@ -103,29 +103,7 @@ If you expect to migrate between two different identity providers, you must crea |
103 | 103 |
|
104 | 104 | API Shield will verify JSON Web Tokens regardless of whether or not they have the `Bearer` prefix. |
105 | 105 |
|
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" /> |
129 | 107 |
|
130 | 108 | ## Availability |
131 | 109 |
|
|
0 commit comments