နားလည်ထားရမယ့် အချက်
Auth layer မှာ session confidentiality/revocation နဲ့ abuse prevention နှစ်မျိုးလုံးလိုပါတယ်။ Login endpoint က IP+account limiter၊ authenticated APIs က user limiter၊ expensive exports က concurrency guard လိုနိုင်ပါတယ်။ Redis failure တွင် endpoint risk အလိုက် fail-open/fail-closed ဆုံးဖြတ်ရပါတယ်။
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
Secure cookie + hashed session key၊ CSRF state၊ idle/absolute timeout၊ logout-all index တည်ဆောက်မယ်။ Lua fixed-window limiter ကို login/search/export policies မတူအောင် config ဖြင့်သုံးမယ်။ Audit logs တွင် raw token/IP မဟုတ်ဘဲ safe hashes နဲ့ outcome သာသိမ်းမယ်။
အတူတူ စမ်းရေးကြည့်မယ်
const session = await readSession(hash(cookie.sid));
if (!session) return reply.status(401).send();
const [count, ttl] = await evalRateLimit(`rl:export:${session.userId}`, 3600);
if (count > 5) return reply.status(429).header('Retry-After', ttl).send();
return createExport(session.userId);Authenticated export ကို hourly limit နှင့် clear retry behavior ဖြင့်ကာကွယ်မည်။၅ မိနစ် စမ်းကြည့်
Redis down အချိန် login/search/export တစ်ခုစီ fail-open/closed policy နဲ့ justification ရေးပါ။
သတိလေးတစ်ချက်
User enumeration မဖြစ်စေရန် unknown account နဲ့ known account limiter/error response မခွဲပါနှင့်။
Redis — Data Types — Redis