Configure development rate limiter limit and fix base url in local tests runner
TaxBaik CI/CD / build-and-deploy (push) Successful in 1m36s
TaxBaik CI/CD / build-and-deploy (push) Successful in 1m36s
This commit is contained in:
@@ -32,7 +32,7 @@ def is_server_healthy(url):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
port = 5001
|
port = 5001
|
||||||
base_url = f"http://localhost:{port}/taxbaik"
|
base_url = f"http://localhost:{port}"
|
||||||
health_url = f"{base_url}/healthz"
|
health_url = f"{base_url}/healthz"
|
||||||
|
|
||||||
server_process = None
|
server_process = None
|
||||||
|
|||||||
@@ -69,11 +69,12 @@ builder.Services.AddRateLimiter(options =>
|
|||||||
options.AddPolicy("client-logs", httpContext =>
|
options.AddPolicy("client-logs", httpContext =>
|
||||||
{
|
{
|
||||||
var ip = httpContext.Connection.RemoteIpAddress?.ToString() ?? "unknown";
|
var ip = httpContext.Connection.RemoteIpAddress?.ToString() ?? "unknown";
|
||||||
|
var isDevelopment = builder.Environment.IsDevelopment();
|
||||||
return RateLimitPartition.GetFixedWindowLimiter(
|
return RateLimitPartition.GetFixedWindowLimiter(
|
||||||
partitionKey: $"client-logs:{ip}",
|
partitionKey: $"client-logs:{ip}",
|
||||||
factory: _ => new FixedWindowRateLimiterOptions
|
factory: _ => new FixedWindowRateLimiterOptions
|
||||||
{
|
{
|
||||||
PermitLimit = 10,
|
PermitLimit = isDevelopment ? 200 : 10,
|
||||||
Window = TimeSpan.FromMinutes(1),
|
Window = TimeSpan.FromMinutes(1),
|
||||||
QueueLimit = 0,
|
QueueLimit = 0,
|
||||||
AutoReplenishment = true
|
AutoReplenishment = true
|
||||||
@@ -82,11 +83,12 @@ builder.Services.AddRateLimiter(options =>
|
|||||||
options.AddPolicy("admin-login", httpContext =>
|
options.AddPolicy("admin-login", httpContext =>
|
||||||
{
|
{
|
||||||
var ip = httpContext.Connection.RemoteIpAddress?.ToString() ?? "unknown";
|
var ip = httpContext.Connection.RemoteIpAddress?.ToString() ?? "unknown";
|
||||||
|
var isDevelopment = builder.Environment.IsDevelopment();
|
||||||
return RateLimitPartition.GetFixedWindowLimiter(
|
return RateLimitPartition.GetFixedWindowLimiter(
|
||||||
partitionKey: $"admin-login:{ip}",
|
partitionKey: $"admin-login:{ip}",
|
||||||
factory: _ => new FixedWindowRateLimiterOptions
|
factory: _ => new FixedWindowRateLimiterOptions
|
||||||
{
|
{
|
||||||
PermitLimit = 5,
|
PermitLimit = isDevelopment ? 100 : 5,
|
||||||
Window = TimeSpan.FromMinutes(1),
|
Window = TimeSpan.FromMinutes(1),
|
||||||
QueueLimit = 0,
|
QueueLimit = 0,
|
||||||
AutoReplenishment = true
|
AutoReplenishment = true
|
||||||
|
|||||||
Reference in New Issue
Block a user