Skip to content

Commit 9e49780

Browse files
authored
Merge pull request #25249 from abpframework/fix/operation-rate-limiting-partition-key-normalization
Update OperationRateLimiting docs for partition key normalization
2 parents d20d681 + 805d326 commit 9e49780

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

docs/en/modules/operation-rate-limiting.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ await checker.CheckAsync("SendSmsCode",
324324
new OperationRateLimitingContext { Parameter = phoneNumber });
325325
````
326326

327+
> **Important:** `PartitionByParameter` uses the parameter value **as-is** without any normalization. If you pass user-supplied values (e.g., email addresses, phone numbers), you are responsible for normalizing them before passing. For example, `user@example.com` and `User@Example.COM` will be treated as **different** partition keys. Use `PartitionByEmail` or `PartitionByPhoneNumber` instead when the parameter is an email or phone number — they handle normalization automatically.
328+
327329
### PartitionByCurrentUser
328330

329331
Uses `ICurrentUser.Id` as the partition key. The user must be authenticated:
@@ -357,7 +359,7 @@ policy.WithFixedWindow(TimeSpan.FromMinutes(15), maxCount: 10)
357359
358360
### PartitionByEmail
359361

360-
Resolves from `context.Parameter` first, then falls back to `ICurrentUser.Email`:
362+
Resolves from `context.Parameter` first, then falls back to `ICurrentUser.Email`. The value is automatically **normalized to uppercase** (using `ToUpperInvariant()`) so that `user@example.com` and `User@Example.COM` share the same rate limit counter:
361363

362364
````csharp
363365
policy.WithFixedWindow(TimeSpan.FromMinutes(1), maxCount: 1)
@@ -370,7 +372,7 @@ await checker.CheckAsync("SendEmailCode",
370372

371373
### PartitionByPhoneNumber
372374

373-
Works the same way as `PartitionByEmail`: resolves from `context.Parameter` first, then falls back to `ICurrentUser.PhoneNumber`.
375+
Works the same way as `PartitionByEmail`: resolves from `context.Parameter` first, then falls back to `ICurrentUser.PhoneNumber`. The value is automatically **normalized** by stripping formatting characters (spaces, dashes, dots, parentheses) while keeping `+` and digits, so that `+1-555-123-4567` and `+15551234567` share the same counter.
374376

375377
### Custom Partition (PartitionBy)
376378

0 commit comments

Comments
 (0)