Admin sign-in and password-reset attempts are counted across every instance that shares the ValKey server #74
Labels
No labels
agent
api-regen
agent
architect
agent
coder
agent
console-coder
agent
docs-writer
agent
mechanic
agent
protocol-coder
agent
storage-coder
area/api
area/ci
area/console
area/dhcp
area/dns
area/docs
area/packaging
area/process
area/storage
area/windows
kind
bug
kind
chore
kind
docs
kind
epic
kind
feature
kind
performance
kind
security
kind
test
priority
high
priority
low
priority
medium
resolution
duplicate
resolution
not-a-bug
resolution
wontfix
status
blocked
status
in-progress
status
needs-decision
status
needs-design
status
ready
theme
ad-samba-dns
theme
alternatives-benchmark
theme
console-toolchain
theme
later
theme
parity-devices
theme
parity-query
theme
post-release-fixes
theme
tracker-setup
theme
valkey
theme
windows-installer
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
Depends on
Reference
lantea-one/ninlil#74
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
The sign-in limiter is the ASP.NET Core rate-limiting middleware with a fixed-window partition per client IPv4 address or IPv6 /64, for two policies,
admin-loginandpassword-reset(src/dotnet/src/Ninlil.Dns.Identity/Extension/ServiceCollectionAdminLoginRateLimitingExtension.cs:33,:42,:119-175). Its counters live in the process. It is what bounds password guessing, because a wrong password does not count toward Identity lockout (src/dotnet/src/Ninlil.Dns.Identity/Options/AdminLoginRateLimitOptions.cs:22-28). Behind a load balancer, each node grants its ownPermitLimit(default 5 per 5 minutes,:53,:60).What changes
Technical call: unlike the DNS limiter (#73), a synchronous ValKey round trip per attempt is acceptable here: sign-ins are rare and already slow (password hashing), so the shared count is checked on every attempt rather than in a background loop.
Ninlil.Common.Valkey:IValkeyWindowCounterwithTask<long?> IncrementAsync(string key, TimeSpan window, CancellationToken stoppingToken). It runsINCRand, on the first increment,PEXPIREwith the window, in one transaction. It returns null when ValKey is not configured, disconnected, or slower than 250 ms.Ninlil.Dns.Identity/RateLimiting/(new folder):IAdminLoginAttemptCounterwithValueTask<long?> CountAttemptAsync(string policyName, string partitionKey, CancellationToken stoppingToken). Identity does not reference ValKey.RateLimitersubclass that wraps the existing local fixed-window limiter. It acquires the local permit first (a local denial stays a 429 at once). Then it asks the counter. A shared count overPermitLimitis a denial, withRetryAftermetadata set to the end of the shared window.Windowsince the Unix epoch, so every node uses the same key<prefix>:rl:login:<policy>:<partitionKey>:<windowIndex>.GetPartition(ServiceCollectionAdminLoginRateLimitingExtension.cs:152-175) builds this limiter when a counter is registered, and the plain one otherwise.OnRejectedprefers the shared window's remaining time forRetry-After.src/dotnet/src/Ninlil.Web/Valkey/ValkeyAdminLoginAttemptCounter.cs(new): implementsIAdminLoginAttemptCounteroverIValkeyWindowCounter. It is registered only whenValkeyOptions.EnableSharedRateLimitis set and a connection string exists.AdminLoginRateLimitOptionsdocuments (:15-20). A Warning is logged at most once a minute while the shared count is unavailable.AdminLoginRateLimitOptionsandServiceCollectionAdminLoginRateLimitingExtensionto describe the shared count.Acceptance
src/dotnet/tests/Ninlil.Dns.Identity.Tests: with a fake counter that reports 6 for a partition andPermitLimit = 5, the first attempt on a fresh local limiter is rejected with aRetryAftervalue.admin-loginandpassword-resetuse different keys, so a reset request does not use up sign-in attempts.src/dotnet/tests/Ninlil.Web.Tests: two hosts (factory.CreateSecondHost) on one ValKey withPermitLimit = 3; two failed sign-ins on host A and one on host B, then the next on host B gets 429 withRetry-After.src/dotnet/tests/Ninlil.Common.Valkey.Testspasses.EnableSharedRateLimitfrom #70 covers it);ENVIRONMENT.mddescription of that variable names both limiters.EnableSharedRateLimit.Source
Owner decision 2026-10-31 (Q-INT-3): "ValKey counters: DNS queries AND admin login limiter (NEW child issue)".