| | | 1 | | namespace ProjectTemplate.Web.Options; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Represents template-level rate limiting configuration. |
| | | 5 | | /// </summary> |
| | | 6 | | public sealed class ApplicationRateLimitingOptions |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Configuration section name for rate limiting settings. |
| | | 10 | | /// </summary> |
| | | 11 | | public const string SectionName = "ProjectTemplate:RateLimiting"; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Gets or sets a value indicating whether rate limiting is enabled. |
| | | 15 | | /// </summary> |
| | 1692 | 16 | | public bool Enabled { get; set; } = true; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Gets or sets a value indicating whether to use the global limiter. |
| | | 20 | | /// When true, <see cref="GlobalFixedWindow"/> is used as a global limiter. |
| | | 21 | | /// </summary> |
| | 1558 | 22 | | public bool UseGlobalLimiter { get; set; } = true; |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Gets or sets a value indicating whether requests without a resolved client IP address |
| | | 26 | | /// should use one shared fallback partition key. |
| | | 27 | | /// </summary> |
| | 1112 | 28 | | public bool UseSharedUnknownClientPartition { get; set; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Gets or sets the base fallback partition key used when the client IP address cannot be resolved. |
| | | 32 | | /// </summary> |
| | 1964 | 33 | | public string UnknownClientPartitionKey { get; set; } = "unknown-client"; |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Gets or sets the global fixed-window rate limiting options. |
| | | 37 | | /// </summary> |
| | 3754 | 38 | | public FixedWindowRateLimitingOptions GlobalFixedWindow { get; set; } = new() |
| | 574 | 39 | | { |
| | 574 | 40 | | PermitLimit = 60, |
| | 574 | 41 | | WindowSeconds = 60, |
| | 574 | 42 | | QueueLimit = 0 |
| | 574 | 43 | | }; |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Gets or sets the fixed-window rate limiting options applied at the template level. |
| | | 47 | | /// </summary> |
| | 3662 | 48 | | public FixedWindowRateLimitingOptions FixedWindowPolicy { get; set; } = new() |
| | 574 | 49 | | { |
| | 574 | 50 | | PermitLimit = 60, |
| | 574 | 51 | | WindowSeconds = 60, |
| | 574 | 52 | | QueueLimit = 0 |
| | 574 | 53 | | }; |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// Gets or sets the concurrency-based rate limiting options applied at the template level. |
| | | 57 | | /// </summary> |
| | 2820 | 58 | | public ConcurrencyRateLimitingOptions ConcurrencyPolicy { get; set; } = new() |
| | 574 | 59 | | { |
| | 574 | 60 | | PermitLimit = 10, |
| | 574 | 61 | | QueueLimit = 0 |
| | 574 | 62 | | }; |
| | | 63 | | } |