Thuta Learning
ရှာဖွေရန်
Redis
ProjectsData & Databasesbeginner

Project 3 — Sessions နှင့် Rate Limits

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • Project 3 — Sessions နှင့် Rate Limits concept ကို နားလည်ရှင်းပြနိုင်ရန်
  • နမူနာ Redis command/code ကို ကိုယ်တိုင် run ပြီး output စစ်နိုင်ရန်
  • Tutorial Platform project နှင့် production scenario တွင် မှန်ကန်စွာအသုံးချနိုင်ရန်

နားလည်ထားရမယ့် အချက်

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 သာသိမ်းမယ်။

အတူတူ စမ်းရေးကြည့်မယ်

typescript
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);
You should see
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 TypesRedis

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • User enumeration မဖြစ်စေရန် unknown account နဲ့ known account limiter/error response မခွဲပါနှင့်။
  • နမူနာ command ကို production Redis ပေါ် တိုက်ရိုက်မစမ်းဘဲ local/test instance နဲ့ recoverable data ပေါ်တွင် အရင်အတည်ပြုပါ။

လေ့ကျင့်ခန်း

Redis down အချိန် login/search/export တစ်ခုစီ fail-open/closed policy နဲ့ justification ရေးပါ။

You'll know it worked when: Authenticated export ကို hourly limit နှင့် clear retry behavior ဖြင့်ကာကွယ်မည်။

Project 3 — Sessions နှင့် Rate Limits | Thuta Learning