Class CachePasswordLoginRateLimiter

java.lang.Object
io.leandev.appfuse.security.auth.CachePasswordLoginRateLimiter
All Implemented Interfaces:
PasswordLoginRateLimiter, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationEventPublisherAware

public final class CachePasswordLoginRateLimiter extends Object implements PasswordLoginRateLimiter, org.springframework.context.ApplicationEventPublisherAware

同一連線 IP+trim/lowercase(ROOT) username 的滾動視窗限流。

預設五次/60 秒;被拒請求不延長視窗,成功登入不重置配額。 synchronized 僅保障同一實作物件內的讀/判定/寫入;同用途 cache 只能有一個 owner。 淘汰、重啟或 cache 故障可能失去配額;此實作不承諾全叢集硬上限。 cache expiry 只用於清理,視窗由 Clock 與已接受時間判斷,不以 TTI 滑動等待時間。

Spring bean 會自動以 AuditApplicationEvent 發出 CACHE_UNAVAILABLE/CACHE_RECOVERED; 非 Spring 消費端可顯式接入 publisher。只在 cache 邊界降級,不略過認證與 SQL Session。