التأكد من الـ JWT صح: التوقيع والـ claims والـ scopes

جارٍ التحميل…

01 / ملخص الدرس

التأكد من الـ JWT صح: التوقيع والـ claims والـ scopes

الـ API بيستقبل access token من الـ IdP. نسخة بتعمل decode بس بتقبل alg none وtoken متعدّل وtoken لـ API تانية وtoken منتهي و id_token. بنتعلم الـ JWKS و kid و key rotation، والـ claims: iss و aud و exp و typ، و clock skew، والفرق بين أربعمية وواحد وأربعمية وتلاتة، والـ scopes. والتحدي: requireAuth و requireScope بـ WWW-Authenticate صح.

02 / شرح الدرس مكتوبًا

نص شرح المعلم والكود الذي كتبه ونتيجة تشغيله، بنفس ترتيب الدرس.

أهلًا بيك. في الدرس اللي فات التطبيق اخد access token من الـ IdP. النهارده احنا الـ API اللي بيستقبل الـ token ده، الـ Resource Server. الـ JWT تلات حتت بينهم dots: header فيه alg و kid و typ. payload فيه الـ claims. و signature. الحتتين الأولانيين base64url بس، مش متشفّرين، أي حد يقدر يقراهم ويغيّرهم. اللي بيحمي الـ token هو التوقيع، ولو ما اتأكدتش منه، الـ token ده ورقة أي حد يكتب فيها اللي هو عايزه. issuer dot js: IdP مختصر على port أربعة آلاف. بينشر الـ public key على slash jwks ومعاه kid. و slash mint للتجربة بس: بيطلّع token بالـ claims اللي احنا عايزينها، علشان نجرّب كل الحالات. الـ token فيه: iss مين اللي طلّعه، و sub المستخدم، و aud الـ API اللي الـ token معمول لها، و exp وقت ما يخلص، و scope الصلاحيات، و typ في الـ header قيمته at plus jwt، يعني ده access token.

server dot js: الـ API. middleware اسمه auth بيستخدم decodeJwt: بيفك الـ payload ويصدّقه، من غير أي check. GET slash orders بترجّع الـ orders بتاعة الـ sub. و POST بتضيف order. الغلطة دي بتتعمل كتير، خصوصًا لما الـ API ورا gateway والناس تقول الـ gateway بيشيك. بس لو حد وصل للـ API من غير الـ gateway، خلاص. tokens dot js فيه أدوات التجربة: mint بتجيب token سليم من الـ IdP. forgeNone بتعمل token بـ alg none، يعني من غير توقيع. tamper بتاخد token سليم وتغيّر الـ payload وتسيب التوقيع القديم. و cases فيها عشر حالات. attack dot js بيجرّبهم كلهم. نشغّل.

attack.js
import { call, cases } from "./tokens.js";

for (const [name, method, token] of await cases()) {
  const r = await call(method, token);
  console.log(String(r.status).padEnd(4), name.padEnd(42), r.body.slice(0, 60));
}

المخرجات

$ node issuer.js & I=$!; node server.js & S=$!; sleep 1; node attack.js; kill $I $S
IdP: http://localhost:4000
API: http://localhost:3000
200  token سليم، GET                            [{"id":1,"owner":"user-7","item":"كتاب"}]
401  من غير token                               {"error":"مفيش token"}
200  alg none و sub=admin                       [{"id":2,"owner":"admin","item":"سيرفر"}]
200  token متعدّل sub=admin                     [{"id":2,"owner":"admin","item":"سيرفر"}]
200  aud=billing-api                            [{"id":1,"owner":"user-7","item":"كتاب"}]
200  خلص من دقيقتين                             [{"id":1,"owner":"user-7","item":"كتاب"}]
200  خلص من عشر ثواني (clock skew)              [{"id":1,"owner":"user-7","item":"كتاب"}]
200  id_token بدل access token                  [{"id":1,"owner":"user-7","item":"كتاب"}]
201  scope=orders:read بيعمل POST               {"id":3,"owner":"user-7","item":"قلم"}
201  scope=orders:read orders:write بيعمل POST  {"id":4,"owner":"user-7","item":"قلم"}

كارسة. alg none و sub admin: اخد الـ orders بتاعة الـ admin. الـ token المتعدّل: نفس الحكاية. token معمول لـ billing API اتقبل عندنا. token خلص من دقيقتين اتقبل. الـ id_token اتقبل كأنه access token. و scope read عمل POST. كل ده لأن الـ API ما بيتأكدش من أي حاجة.

إيه اللي لازم يتشيك؟ التوقيع: بالـ public key من الـ JWKS، والـ kid اللي في الـ header بيقول أنهي key. algorithms: انت اللي بتحدد المسموح، مش الـ token. لو سبت الـ token يختار، ممكن يقول none، أو يقول HS256 ويستخدم الـ public key كأنه secret، ودي اسمها algorithm confusion. iss: من الـ IdP بتاعك. aud: معمول للـ API دي بالضبط. exp و nbf: في وقته، مع سماحية صغيرة للساعات اللي مش مضبوطة، اسمها clock skew. typ: access token مش id_token. وبعدين الـ scope حسب الـ route.

حاجتين مهمين. key rotation: الـ IdP بيغيّر الـ keys كل فترة. بيحط الـ key الجديد في الـ JWKS قبل ما يستخدمه، ويسيب القديم لحد ما آخر token اتوقّع بيه يخلص. و createRemoteJWKSet بتعمل cache للـ keys، ولو جالها kid مش عارفاه بتجيب الـ JWKS تاني، مع cooldown علشان محدش يغرّق الـ IdP بـ kids عشوائية. الـ revocation: الـ JWT صالح لحد exp حتى لو المستخدم عمل logout أو اتقفل. علشان كده خلّي عمر الـ access token قصير، خمس أو عشر دقايق، والـ refresh token هو اللي يتلغي. ولو محتاج إلغاء فوري، يا إما denylist بالـ jti، يا إما opaque token وتسأل الـ IdP عن كل token بـ introspection. التحدي: requireAuth و requireScope. jwtVerify بكل الـ options اللي قلناها. أربعمية وواحد لو مش عارفين انت مين، مع header اسمه WWW-Authenticate فيه invalid_token. أربعمية وتلاتة لو الـ scope ناقص، مع insufficient_scope. الـ header ده جاي من standard الـ Bearer tokens، والـ clients بتعتمد عليه علشان تعرف تعمل refresh ولا تطلب صلاحية أكتر. test dot js فيه الحالات العشرة وكمان الـ headers.

تمرين

requireAuth بـ jwtVerify (issuer, audience, algorithms [ES256], typ at+jwt, clockTolerance 30s, requiredClaims) و 401 + invalid_token، و requireScope(scope) بـ 403 + insufficient_scope.

الحل. بنقسم الـ header ونتأكد إنه Bearer. jwtVerify بالـ JWKS والـ options. الـ scopes Set علشان الـ check يبقى سريع وواضح. أي exception من jose بيبقى أربعمية وواحد، وبنطبع الـ code بتاعه بس. و requireScope function بترجّع middleware، فكل route يقول محتاج إيه. نشغّل الهجمات تاني.

server.js
// الـ Resource Server: الـ API اللي بيقبل الـ access tokens
import express from "express";
import { createRemoteJWKSet, decodeJwt, jwtVerify } from "jose";

const app = express();
app.use(express.json());
const orders = [
  { id: 1, owner: "user-7", item: "كتاب" },
  { id: 2, owner: "admin", item: "سيرفر" },
];

const JWKS = createRemoteJWKSet(new URL("http://localhost:4000/jwks"));

const requireAuth = async (req, res, next) => {
  const [scheme, token] = (req.get("authorization") ?? "").split(" ");
  if (scheme !== "Bearer" || !token) {
    res.set("WWW-Authenticate", 'Bearer realm="orders-api"');
    return res.status(401).json({ error: "محتاج token" });
  }
  try {
    const { payload } = await jwtVerify(token, JWKS, {
      issuer: "http://localhost:4000",
      audience: "orders-api",
      algorithms: ["ES256"],
      typ: "at+jwt",
      clockTolerance: 30,
      requiredClaims: ["sub", "exp", "iat"],
    });
    req.user = { sub: payload.sub, scopes: new Set(String(payload.scope ?? "").split(" ")) };
    next();
  } catch (e) {
    console.log("رفضنا:", e.code ?? e.message);
    res.set("WWW-Authenticate", 'Bearer realm="orders-api", error="invalid_token"');
    res.status(401).json({ error: "token مش صالح" });
  }
};

const requireScope = (scope) => (req, res, next) => {
  if (req.user.scopes.has(scope)) return next();
  res.set("WWW-Authenticate", `Bearer realm="orders-api", error="insufficient_scope", scope="${scope}"`);
  res.status(403).json({ error: `محتاج ${scope}` });
};

app.get("/orders", requireAuth, (req, res) => res.json(orders.filter((o) => o.owner === req.user.sub)));
app.post("/orders", requireAuth, requireScope("orders:write"), (req, res) => {
  const o = { id: orders.length + 1, owner: req.user.sub, item: req.body.item };
  orders.push(o);
  res.status(201).json(o);
});

app.listen(3000, () => console.log("API: http://localhost:3000"));

المخرجات

$ node issuer.js & I=$!; node server.js & S=$!; sleep 1; node attack.js; kill $I $S
IdP: http://localhost:4000
API: http://localhost:3000
200  token سليم، GET                            [{"id":1,"owner":"user-7","item":"كتاب"}]
401  من غير token                               {"error":"محتاج token"}
رفضنا: ERR_JOSE_ALG_NOT_ALLOWED
401  alg none و sub=admin                       {"error":"token مش صالح"}
رفضنا: ERR_JWS_SIGNATURE_VERIFICATION_FAILED
401  token متعدّل sub=admin                     {"error":"token مش صالح"}
رفضنا: ERR_JWT_CLAIM_VALIDATION_FAILED
401  aud=billing-api                            {"error":"token مش صالح"}
رفضنا: ERR_JWT_EXPIRED
401  خلص من دقيقتين                             {"error":"token مش صالح"}
200  خلص من عشر ثواني (clock skew)              [{"id":1,"owner":"user-7","item":"كتاب"}]
رفضنا: ERR_JWT_CLAIM_VALIDATION_FAILED
401  id_token بدل access token                  {"error":"token مش صالح"}
403  scope=orders:read بيعمل POST               {"error":"محتاج orders:write"}
201  scope=orders:read orders:write بيعمل POST  {"id":3,"owner":"user-7","item":"قلم"}

شوف الـ console: كل رفض ليه سبب من jose. alg none: ERR JOSE ALG NOT ALLOWED. المتعدّل: ERR JWS SIGNATURE VERIFICATION FAILED. الـ aud والـ typ: ERR JWT CLAIM VALIDATION FAILED. والمنتهي: ERR JWT EXPIRED. ونشغّل test dot js.

server.js

المخرجات

$ node issuer.js & I=$!; node server.js & S=$!; sleep 1; node test.js; kill $I $S
API: http://localhost:3000
IdP: http://localhost:4000
✅ token سليم، GET                            200 
✅ من غير token                               401 
رفضنا: ERR_JOSE_ALG_NOT_ALLOWED
✅ alg none و sub=admin                       401 
رفضنا: ERR_JWS_SIGNATURE_VERIFICATION_FAILED
✅ token متعدّل sub=admin                     401 
رفضنا: ERR_JWT_CLAIM_VALIDATION_FAILED
✅ aud=billing-api                            401 
رفضنا: ERR_JWT_EXPIRED
✅ خلص من دقيقتين                             401 
✅ خلص من عشر ثواني (clock skew)              200 
رفضنا: ERR_JWT_CLAIM_VALIDATION_FAILED
✅ id_token بدل access token                  401 
✅ scope=orders:read بيعمل POST               403 
✅ scope=orders:read orders:write بيعمل POST  201 
✅ WWW-Authenticate في الـ 403: Bearer realm="orders-api", error="insufficient_scope", scope="orders:write"
رفضنا: ERR_JWS_INVALID
✅ WWW-Authenticate في الـ 401: Bearer realm="orders-api", error="invalid_token"

12/12 نجحوا

كله نجح. بس خد بالك من حاجة: الـ token السليم بتاع user seven بيرجّع الـ orders بتاعته هو بس، لأن الـ route بيفلتر بالـ sub. لو كان فيه GET slash orders slash id، وما شيكناش إن الـ order ده بتاعه، أي حد معاه token سليم يقرا orders غيره. ودي أشهر vulnerability في الـ APIs، اسمها BOLA، وهي الدرس الجاي.

issuer.js
// الـ Authorization Server (مختصر): بينشر الـ public key، وبيطلّع tokens للتجربة
import express from "express";
import { generateKeyPair, exportJWK, SignJWT } from "jose";

const ISSUER = "http://localhost:4000";
const { publicKey, privateKey } = await generateKeyPair("ES256");
const jwk = { ...(await exportJWK(publicKey)), kid: "k1", alg: "ES256", use: "sig" };

const app = express();
app.use(express.json());
app.get("/jwks", (req, res) => res.json({ keys: [jwk] }));

// للتجربة بس: بيطلّع أي token احنا عايزينه (في الحقيقة ده /token بعد login)
app.post("/mint", async (req, res) => {
  const { sub = "user-7", aud = "orders-api", scope = "orders:read", expIn = 300, typ = "at+jwt" } = req.body;
  const now = Math.floor(Date.now() / 1000);
  const token = await new SignJWT({ scope, client_id: "my-backend" })
    .setProtectedHeader({ alg: "ES256", kid: "k1", typ })
    .setIssuer(ISSUER)
    .setAudience(aud)
    .setSubject(sub)
    .setIssuedAt(now)
    .setExpirationTime(now + expIn)
    .sign(privateKey);
  res.json({ token });
});

app.listen(4000, () => console.log("IdP: http://localhost:4000"));
tokens.js
// أدوات التجربة: tokens سليمة من الـ IdP، وtokens مزوّرة
export const mint = async (claims = {}) => {
  const r = await fetch("http://localhost:4000/mint", {
    method: "POST",
    headers: { "content-type": "application/json" },
    body: JSON.stringify(claims),
  });
  return (await r.json()).token;
};
const b64 = (o) => Buffer.from(JSON.stringify(o)).toString("base64url");
const part = (t, i) => JSON.parse(Buffer.from(t.split(".")[i], "base64url"));

// alg none: من غير توقيع خالص
export const forgeNone = (payload) => `${b64({ alg: "none", typ: "at+jwt" })}.${b64(payload)}.`;
// نفس التوقيع، بس غيّرنا الـ payload
export const tamper = (t, changes) => {
  const [h, , s] = t.split(".");
  return `${h}.${b64({ ...part(t, 1), ...changes })}.${s}`;
};

export const call = async (method, token) => {
  const headers = { "content-type": "application/json" };
  if (token) headers.authorization = `Bearer ${token}`;
  const r = await fetch("http://localhost:3000/orders", {
    method,
    headers,
    body: method === "POST" ? JSON.stringify({ item: "قلم" }) : undefined,
  });
  return { status: r.status, www: r.headers.get("www-authenticate"), body: await r.text() };
};

export const cases = async () => {
  const ok = await mint();
  return [
    ["token سليم، GET", "GET", ok, 200],
    ["من غير token", "GET", undefined, 401],
    ["alg none و sub=admin", "GET", forgeNone({ sub: "admin", aud: "orders-api", scope: "orders:write" }), 401],
    ["token متعدّل sub=admin", "GET", tamper(ok, { sub: "admin" }), 401],
    ["aud=billing-api", "GET", await mint({ aud: "billing-api" }), 401],
    ["خلص من دقيقتين", "GET", await mint({ expIn: -120 }), 401],
    ["خلص من عشر ثواني (clock skew)", "GET", await mint({ expIn: -10 }), 200],
    ["id_token بدل access token", "GET", await mint({ typ: "JWT" }), 401],
    ["scope=orders:read بيعمل POST", "POST", ok, 403],
    ["scope=orders:read orders:write بيعمل POST", "POST", await mint({ scope: "orders:read orders:write" }), 201],
  ];
};
test.js
import { call, cases } from "./tokens.js";
let ok = 0, all = 0;
for (const [name, method, token, want] of await cases()) {
  const r = await call(method, token);
  all++;
  const pass = r.status === want;
  if (pass) ok++;
  console.log(pass ? "✅" : "❌", name.padEnd(42), r.status, pass ? "" : `(المفروض ${want})`);
}
const noScope = await call("POST", (await cases())[0][2]);
const www1 = noScope.www ?? "";
all++; if (/insufficient_scope/.test(www1) && /scope="orders:write"/.test(www1)) ok++;
console.log(/insufficient_scope/.test(www1) ? "✅" : "❌", "WWW-Authenticate في الـ 403:", www1);
const bad = await call("GET", "abc.def.ghi");
all++; if (/invalid_token/.test(bad.www ?? "")) ok++;
console.log(/invalid_token/.test(bad.www ?? "") ? "✅" : "❌", "WWW-Authenticate في الـ 401:", bad.www);
console.log(`\n${ok}/${all} نجحوا`);
03 / دروس المسار (122)
  1. 01أهلًا بيك: يعني إيه backend، والكورس ده ماشي إزاي
  2. 02الملفات والفولدرات والـ terminal: تتحرك على جهازك زي المبرمجين
  3. 03Node وأول برنامج: تشغّل وتقرا رسالة الخطأ
  4. 04القيم والمتغيرات والأنواع: const و let و typeof
  5. 05القرارات والتكرار: if و === والـ truthy والـ loops
  6. 06الـ functions: parameters و return والـ arrow functions والـ scope
  7. 07الـ objects والـ arrays: destructuring و spread و map و filter و reduce
  8. 08JSON والنصوص والتواريخ: اللغة اللي الـ backend بيتكلم بيها
  9. 09الـ callbacks والـ closures وأول لمسة async: setTimeout
  10. 10الـ classes والـ errors: throw و try/catch و stack trace
  11. 11git: تحفَظ كل خطوة وترجعلها، وما تسرّبش أسرارك
  12. 12ESM و CommonJS و package exports: Node بيلاقي الـ modules إزاي
  13. 13الـ Promises و async/await: sequential و parallel والأخطاء والإلغاء
  14. 14الـ event loop والـ microtasks: Node بيعمل كل حاجة بـ thread واحد إزاي
  15. 15الـ Streams والـ Backpressure: ملفات أكبر من الـ memory
  16. 16الـ File System والـ paths: قراية وكتابة صح، ومن غير path traversal
  17. 17الـ Buffers والبيانات الـ binary: الـ bytes من جُوّه
  18. 18Crypto APIs والأسرار: random و hash و HMAC و AES-GCM
  19. 19الـ Worker Threads: شغل CPU تقيل من غير ما توقف الـ server
  20. 20الـ Errors على مستوى الـ process: operational و programmer و crash-only
  21. 21الـ Node test runner والـ debugging: tests من غير مكتبات
  22. 22HTTP من جُوّه: الـ methods والـ status codes والـ headers
  23. 23Express والـ Routing: الـ params والـ query والترتيب والـ Router
  24. 24Express 5: إيه اللي اتغيّر، وإزاي تنقل مشروع قديم
  25. 25الـ Middleware ودورة حياة الـ request جُوّه Express
  26. 26Validation للمدخلات بـ Zod: ما تصدّقش أي حاجة جاية من برة
  27. 27تصنيف الأخطاء و Problem Details: شكل واحد لكل الـ errors
  28. 28الـ CORS والـ Cookies: المتصفح بيحمي المستخدم إزاي
  29. 29رفع الملفات وحدود الحجم: multer من غير ثغرات
  30. 30الـ Realtime: Server-Sent Events و WebSockets
  31. 31OpenAPI والـ API Versioning: عقد مكتوب، وتغيير من غير ما تكسر حد
  32. 32PostgreSQL: الـ DDL وأنواع البيانات الصح لكل عمود
  33. 33الـ Constraints: PK و FK و UNIQUE و CHECK — الـ database بتحمي نفسها
  34. 34الـ Normalization والـ ERD: تقسّم البيانات صح من أول يوم
  35. 35الـ JOINs والتجميع: INNER و LEFT و GROUP BY و HAVING و window functions
  36. 36JSONB في PostgreSQL: إمتى تستخدمه، وإزاي تسأله وتعمله index
  37. 37الـ Indexes من جُوّه: B-tree و GIN و BRIN
  38. 38Partial و Covering indexes: indexes أصغر وأسرع
  39. 39الـ Pagination بالـ Keyset: ليه OFFSET بيبطّأ وبيكرر
  40. 40Full Text Search في Postgres: بحث بالكلمات، بالعربي والإنجليزي
  41. 41EXPLAIN ANALYZE والـ Planner: اقرا الـ plan وصلّح الـ query
  42. 42الـ Transactions بـ node-postgres: كله أو ولا حاجة
  43. 43الـ MVCC ومستويات الـ Isolation: transactions كتير في نفس الوقت
  44. 44الـ Locks والـ Deadlocks: مين مستني مين
  45. 45SKIP LOCKED و Job Leasing: Postgres كـ job queue
  46. 46Row Level Security والـ Multi-tenancy: كل عميل يشوف بياناته بس
  47. 47Migrations من غير downtime: expand و backfill و contract
  48. 48الـ Replication والـ Read Replicas: نسخ حية من الـ database
  49. 49الـ Connection Pooling و PgBouncer: connections أقل، requests أكتر
  50. 50الـ Partitioning والـ VACUUM والمراقبة: Postgres على المدى الطويل
  51. 51Redis وأنواع البيانات: strings و hashes و lists و sets و sorted sets
  52. 52Cache-aside والـ TTL: Redis قدام الـ database
  53. 53الـ Cache invalidation والـ Stampede: لما الـ key الشهير يموت
  54. 54Lua والـ Atomicity في Redis: كام أمر كأنهم أمر واحد
  55. 55الـ Rate Limiting في Redis: fixed window و sliding window و token bucket
  56. 56الـ Sessions في Redis: تسجيل دخول تقدر تلغيه في أي وقت
  57. 57Redis Streams والـ Consumer Groups: log بيتوزع على workers
  58. 58Pub/Sub و BullMQ: إشارات بين الـ instances، وطوابير شغل محترمة
  59. 59Redis لما يقع: الـ persistence (RDB و AOF) والـ replication
  60. 60Redis في الإنتاج: الـ ACLs والـ Cluster والمراقبة
  61. 61تخزين الـ Passwords بـ Argon2id: صح من أول مرة
  62. 62Session Fixation والـ Rotation: id جديد مع كل صلاحية جديدة
  63. 63الـ Cookie Flags والـ CSRF: المتصفح بيبعت الـ cookie، فلازم تتأكد مين اللي طلب
  64. 64الـ XSS والـ Content Security Policy: ما تخليش النص يتحوّل لـ code
  65. 65الـ OAuth و OpenID Connect و PKCE: login بـ Google من غير ما تشوف الـ password
  66. 66التأكد من الـ JWT صح: التوقيع والـ claims والـ scopesانت هنا
  67. 67الـ BOLA و BFLA: الـ token السليم مش معناه إن الطلب مسموح
  68. 68الـ RBAC و ABAC والملكية: policy واحدة بدل ifs متفرقة
  69. 69الـ MFA والـ recovery: التاني factor اللي بجد
  70. 70الـ Passkeys و WebAuthn: login من غير password وضد الـ phishing
  71. 71الـ Threat Modeling بـ STRIDE: فكّر زي المهاجم قبل ما تكتب code
  72. 72الـ SQL Injection والـ Parameterization: الـ data ما تبقاش code
  73. 73الـ SSRF والـ Egress: ما تخليش الـ server بتاعك يزور الشبكة الداخلية
  74. 74الـ Security Headers والـ TLS: كل response يقول للـ browser يحمي المستخدم إزاي
  75. 75توقيع الـ Webhooks والـ Replay: الـ webhook ده جاي فعلًا من Stripe؟
  76. 76تغيير الأسرار والـ HMAC: إزاي تغيّر مفتاح من غير ما كل حاجة تقع
  77. 77سلسلة التوريد والـ SBOM: إنت واثق في ألف package ما تعرفهمش؟
  78. 78الـ Audit والـ Privacy Logs: سجّل مين عمل إيه، من غير ما تسجّل الأسرار
  79. 79اختبار الأمان و OWASP ASVS: الأمن جُوّه الـ CI، مش audit آخر السنة
  80. 80الـ Prototype Pollution والـ Resource DoS: request واحد يخلّي الكل admin أو يوقّع الـ server
  81. 81الـ SLI والـ SLO والـ Error Budget: إمتى تصحّي الـ on-call وإمتى تسيبه نايم
  82. 82الـ Event Loop Delay والـ ELU: لما Node نفسه يتخنق
  83. 83الـ Worker Threads والـ CPU Profiling: الشغل التقيل بره الـ event loop، والوقت راح فين
  84. 84الـ Memory والـ GC والـ Leaks: الـ process اللي بيكبر لحد ما يقع
  85. 85الـ N+1 Queries والـ DataLoader: صفحة واحدة بمِيّتين query
  86. 86الـ HTTP Caching والـ Compression: أسرع request هو اللي ما بيوصلش
  87. 87الـ Load Testing والـ Soak Testing: الـ server بيستحمل قد إيه بجد
  88. 88الـ Concurrency Limits والـ Bulkheads: dependency بطيئة ما توقعش الـ app كله
  89. 89الـ Timeouts والـ Retries والـ Circuit Breakers: إزاي تتعامل مع dependency بطيئة أو واقعة
  90. 90OpenTelemetry والـ Distributed Tracing: الـ request راح فين وضاع وقته فين
  91. 91Docker Layers والـ Build Context: ليه الـ build بياخد دقيقة وفيه الـ .env بتاعك
  92. 92Multi-stage Builds و Non-root: image صغيرة ومن غير root
  93. 93Docker Compose والـ Networks: الـ services بتلاقي بعض إزاي
  94. 94Docker Volumes: الـ data بتتحفَظ فين
  95. 95Healthcheck و Restart و Resource Limits: running مش معناها شغّال
  96. 96BuildKit والـ Build Secrets: الـ token ما يدخلش الـ image
  97. 97Reverse Proxy و TLS: اللي واقف قدام الـ app
  98. 98Multi-arch Images والـ Native Modules: اشتغلت عندي
  99. 99CI/CD و Rollback و Canary: الـ deploy يبقى ممل
  100. 100Kubernetes من الأول: Pods و Deployments و Services و Probes
  101. 101Modular Monolith و DDD: حدود واضحة من غير network
  102. 102Transactional Outbox و Inbox: الـ event ما يضيعش وما يتنفذش مرتين
  103. 103Sagas: عملية واحدة على تلات services من غير transaction واحدة
  104. 104CQRS و Event Sourcing: الـ events هي الحقيقة
  105. 105الـ Queues والـ Brokers: BullMQ و RabbitMQ و Kafka و SQS
  106. 106Realtime على أكتر من instance: Redis pub/sub و presence و resume
  107. 107الـ Object Storage والـ Media: presigned URLs و uploads مباشرة
  108. 108التكامل مع الـ Email والـ Search: retries و webhooks و indexes
  109. 109GraphQL و gRPC في الإنتاج: contracts و DataLoader و limits و deadlines
  110. 110Kafka على أكتر من zone و region: الـ replication والـ ISR والـ acks والـ MirrorMaker والـ failover
  111. 111TypeScript و runtime boundaries: الـ types بتختفي، والـ schemas لأ
  112. 112ORM ولا SQL: query builders و repositories و migrations و transactions
  113. 113الـ Serverless من جُوّه: cold starts و freeze و timeouts و connections
  114. 114الـ Testing Pyramid: unit و integration و e2e على Postgres حقيقية
  115. 115Contract Testing و Property-Based Testing بـ fast-check
  116. 116الـ Payments: idempotency و webhooks و refunds و reconciliation
  117. 117الـ Timezones والـ Internationalization: UTC و DST والـ locales والـ plurals والفلوس
  118. 118الـ Privacy والـ Data Retention: consent و export و erasure و crypto shredding
  119. 119الـ ADRs والـ Feature Flags: القرارات المكتوبة والـ rollout من غير deploy
  120. 120Multi-region active-active: حل الـ conflicts بـ HLC و CRDTs
  121. 121Readiness و Liveness و Startup Probes: الـ pod جاهز ولا عايش؟
  122. 122Incident Runbooks: من الـ alert للـ postmortem