الـ OAuth و OpenID Connect و PKCE: login بـ Google من غير ما تشوف الـ password

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

01 / ملخص الدرس

الـ OAuth و OpenID Connect و PKCE: login بـ Google من غير ما تشوف الـ password

بنبني Authorization Server صغير وتطبيق client، ونمشي الـ Authorization Code Flow خطوة خطوة بالـ redirects: state ضد CSRF على الـ login، و nonce ضد إعادة استخدام الـ id_token، و PKCE علشان الـ code المسروق ما ينفعش. بنشوف إزاي الـ code المسروق والـ replay بينجحوا على IdP مش عامل حسابه، والتحدي: endpoint الـ /token الآمن.

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

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

أهلًا بيك. زرار Login with Google اللي في كل موقع، ده وراه بروتوكولين: OAuth two: بيخلّي تطبيق ياخد صلاحية محدودة على حاجة بتاعتك، من غير ما ياخد الـ password بتاعك. و OpenID Connect، أو OIDC: طبقة فوق OAuth بتقول للتطبيق انت مين. فيه أربع أدوار: الـ user، اللي هو مُنى. الـ client، اللي هو الـ backend بتاعنا. الـ Authorization Server أو الـ IdP، زي Google. والـ Resource Server، الـ API اللي بيقبل الـ access token. النهارده هنبني الـ IdP بنفسنا، علشان نشوف كل حاجة من جُوّه. ده idp dot js، شغال على port أربعة آلاف. عنده key pair من نوع ES256، والـ public key منشور على slash jwks، علشان أي حد يتأكد من التوقيع. CLIENTS: كل client متسجّل بالـ redirect URIs بتاعته بالضبط. slash authorize: المتصفح بيوصل هنا. بيشيك إن الـ client_id والـ redirect_uri متسجّلين، وده مهم أوي: لو قبل أي redirect، المهاجم يخلّي الـ code يروح عنده. بعدين المستخدم بيعمل login ويوافق، وإحنا هنا بنفترض إنه وافق. بيعمل code عشوائي، ويخزّن معاه كل حاجة: الـ client والـ redirect والـ code_challenge والـ nonce، وصلاحية دقيقة واحدة. ويرجّع المتصفح للـ redirect_uri ومعاه الـ code والـ state. idToken: JWT متوقّع فيه iss و aud و sub و nonce و email. وفي الآخر slash token، النسخة البسيطة الغلط: أي حد معاه code ياخد tokens.

ده server dot js، تطبيقنا. slash login بيعمل تلات حاجات عشوائية: state: هنقارنه لما نرجع، علشان نتأكد إن الـ callback ده جه من login احنا اللي بدأناه. nonce: بيتحط جُوّه الـ id_token، علشان الـ token ده يبقى بتاع المحاولة دي بعينها. و verifier: سر بيفضل عندنا. والـ code_challenge هو SHA-256 للـ verifier. ده اللي بيروح للـ IdP، والـ verifier نفسه لأ. بنحفَظ التلاتة في الـ server، ونحط في المتصفح cookie اسمها tx بتشاور عليهم. slash callback: يشيك الـ state. يبعت الـ code ومعاه الـ verifier لـ slash token من الـ backend للـ backend. يتأكد من الـ id_token بـ jwtVerify، بالـ issuer والـ audience. ويشيك الـ nonce. وبعدين يعمل session بتاعته العادية. browser dot js متصفح صغير بيمشي ورا الـ redirects بإيده، وبيطبع كل خطوة. نشغّل الاتنين ونعمل login.

نشغّل.

browser.js
// متصفح بيمشي ورا الـ redirects بإيده، علشان نشوف كل خطوة
const hop = async (url, cookie = "") => {
  const res = await fetch(url, { redirect: "manual", headers: { cookie } });
  const { host, pathname } = new URL(url);
  console.log(`${res.status} ← ${host}${pathname}`);
  return res;
};

export async function loginUntilCode() {
  const a = await hop("http://localhost:3000/login");
  const tx = a.headers.get("set-cookie").split(";")[0];
  const b = await hop(a.headers.get("location"));
  const callback = new URL(b.headers.get("location"));
  return { tx, callback };
}

if (process.argv[1].endsWith("browser.js")) {
  const { tx, callback } = await loginUntilCode();
  const c = await hop(callback.href, tx);
  console.log(await c.json());
}

المخرجات

$ node idp.js & I=$!; node server.js & S=$!; sleep 1; node browser.js; kill $I $S
IdP: http://localhost:4000
App: http://localhost:3000
302 ← localhost:3000/login
302 ← localhost:4000/authorize
200 ← localhost:3000/callback
{ welcome: '[email protected]', sub: 'user-7' }

three oh two من التطبيق للـ IdP. three oh two من الـ IdP راجع للـ callback ومعاه الـ code. two hundred، والتطبيق عرف إن ده mona at example dot com، من غير ما يشوف الـ password بتاعها. ده اسمه Authorization Code Flow. الـ code بيعدّي في المتصفح، إنما الـ tokens نفسها بتيجي من الـ back channel، backend لـ backend. دلوقتي المهاجم. attack dot js بيجرّب تلات حاجات: app شرير خطف الـ code من الـ redirect، وده بيحصل فعلًا على الموبايل لما app تانية تسجّل نفس الـ custom scheme. بيروح لـ slash token من غير verifier. نفس الـ code مرة تانية. و callback بـ state مزوّر، يعني CSRF على الـ login: المهاجم يخلّي الضحية تدخل بحساب المهاجم، فأي حاجة تكتبها تروح له. نشغّل.

attack.js
import { loginUntilCode } from "./browser.js";
const token = (body) =>
  fetch("http://localhost:4000/token", { method: "POST", body: new URLSearchParams(body) });

// 1) app خبيث على نفس الموبايل خطف الـ code من الـ redirect، وما عندوش الـ verifier
const { callback } = await loginUntilCode();
const code = callback.searchParams.get("code");
const stolen = await token({ grant_type: "authorization_code", code, client_id: "my-backend", redirect_uri: "http://localhost:3000/callback" });
console.log("code مسروق من غير verifier:", stolen.status, stolen.ok ? "اخد token ❌" : await stolen.text());

// 2) نفس الـ code تاني (replay)
const again = await token({ grant_type: "authorization_code", code, client_id: "my-backend", redirect_uri: "http://localhost:3000/callback" });
console.log("نفس الـ code تاني:            ", again.status, again.ok ? "اخد token ❌" : await again.text());

// 3) CSRF على الـ login: المهاجم بيبعت للضحية callback بـ code بتاعه
const forged = await fetch(`http://localhost:3000/callback?code=${code}&state=guess`);
console.log("callback بـ state مزوّر:       ", forged.status, await forged.text());

المخرجات

$ node idp.js & I=$!; node server.js & S=$!; sleep 1; node attack.js; kill $I $S
IdP: http://localhost:4000
App: http://localhost:3000
302 ← localhost:3000/login
302 ← localhost:4000/authorize
code مسروق من غير verifier: 200 اخد token ❌
نفس الـ code تاني:             200 اخد token ❌
callback بـ state مزوّر:        400 {"error":"state غلط"}

الـ code المسروق اشتغل، والمهاجم اخد token. والـ replay اشتغل كمان. بس الـ state المزوّر اترفض، لأن تطبيقنا بيشيك عليه. المشكلة كلها في الـ IdP. الـ code لوحده بقى كأنه password.

إزاي PKCE بيحل ده؟ قبل الـ login، الـ client بيعمل verifier عشوائي، ويبعت الـ hash بتاعه بس. الـ IdP بيحفَظ الـ hash مع الـ code. ساعة التبادل، الـ client لازم يبعت الـ verifier نفسه، والـ IdP يحسب الـ hash ويقارن. اللي خطف الـ code من المتصفح ما شافش الـ verifier أبدًا، لأنه ما عدّاش في المتصفح. واستخدم S256 دايمًا، مش plain. وفي OAuth two point one، PKCE بقى إجباري لكل الـ clients، حتى اللي عندهم client secret. والـ Implicit flow، اللي كان بيرجّع الـ token في الـ URL، اتلغى. التحدي: اكتب slash token الآمن في idp dot js. الـ code يتحرق من أول محاولة. يتشيك الوقت والـ client والـ redirect_uri. ويتشيك الـ verifier بـ S256. وكل الرفض invalid_grant من غير تفاصيل. test dot js فيه ست حالات، والتفاصيل كلها في الكومنت.

تمرين

POST /token: الـ code يتمسح من أول محاولة، ويتشيك exp و client_id و redirect_uri، و code_verifier (شكله + S256 = code_challenge)، وكل الرفض 400 invalid_grant.

الحل. s256 بتحسب الـ hash بـ base64url. codes dot delete أول حاجة، قبل أي شيك. fail بتطبع السبب في الـ console وترجّع invalid_grant بس. وبعدين الشيكات بالترتيب: grant_type، وجود الـ code، الوقت، الـ client والـ redirect، شكل الـ verifier، وفي الآخر الـ hash. نشغّل الهجمات تاني.

idp.js
// الـ Authorization Server (زي Google أو Auth0)، على port أربعة آلاف
import express from "express";
import crypto from "node:crypto";
import { generateKeyPair, exportJWK, SignJWT } from "jose";

const ISSUER = "http://localhost:4000";
const CLIENTS = { "my-backend": { redirectUris: ["http://localhost:3000/callback"] } };
const { publicKey, privateKey } = await generateKeyPair("ES256");
const jwk = { ...(await exportJWK(publicKey)), kid: "k1", alg: "ES256", use: "sig" };
const codes = new Map(); // code → { client_id, redirect_uri, code_challenge, nonce, sub, exp }

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

app.get("/authorize", (req, res) => {
  const { client_id, redirect_uri, response_type, state, nonce, code_challenge } = req.query;
  const client = CLIENTS[client_id];
  if (!client?.redirectUris.includes(redirect_uri))
    return res.status(400).send("client_id أو redirect_uri مش متسجّل");
  if (response_type !== "code") return res.status(400).send("response_type=code بس");
  // هنا المستخدم بيكتب الـ password عند الـ IdP ويوافق. في التجربة: mona وافقت.
  const code = crypto.randomBytes(32).toString("base64url");
  codes.set(code, { client_id, redirect_uri, code_challenge, nonce, sub: "user-7", exp: Date.now() + 60_000 });
  const back = new URL(redirect_uri);
  back.searchParams.set("code", code);
  back.searchParams.set("state", state);
  res.redirect(302, back.href);
});

const idToken = (c) =>
  new SignJWT({ nonce: c.nonce, email: "[email protected]" })
    .setProtectedHeader({ alg: "ES256", kid: "k1" })
    .setIssuer(ISSUER)
    .setAudience(c.client_id)
    .setSubject(c.sub)
    .setIssuedAt()
    .setExpirationTime("5m")
    .sign(privateKey);

const s256 = (v) => crypto.createHash("sha256").update(v).digest("base64url");

app.post("/token", async (req, res) => {
  const { grant_type, code, client_id, redirect_uri, code_verifier } = req.body;
  const c = codes.get(code);
  codes.delete(code); // مرة واحدة، حتى لو المحاولة فشلت
  const fail = (why) => {
    console.log("رفضنا:", why);
    res.status(400).json({ error: "invalid_grant" });
  };
  if (grant_type !== "authorization_code") return res.status(400).json({ error: "unsupported_grant_type" });
  if (!c) return fail("code مش موجود أو اتستخدم قبل كده");
  if (Date.now() > c.exp) return fail("code قديم");
  if (c.client_id !== client_id || c.redirect_uri !== redirect_uri) return fail("client أو redirect_uri مختلف");
  if (typeof code_verifier !== "string" || !/^[\w.~-]{43,128}$/.test(code_verifier))
    return fail("code_verifier مش موجود أو شكله غلط");
  if (s256(code_verifier) !== c.code_challenge) return fail("code_verifier مش مطابق");
  res.json({
    access_token: crypto.randomBytes(24).toString("base64url"),
    token_type: "Bearer",
    expires_in: 300,
    id_token: await idToken(c),
  });
});

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

المخرجات

$ node idp.js & I=$!; node server.js & S=$!; sleep 1; node attack.js; kill $I $S
IdP: http://localhost:4000
App: http://localhost:3000
302 ← localhost:3000/login
302 ← localhost:4000/authorize
رفضنا: code_verifier مش موجود أو شكله غلط
code مسروق من غير verifier: 400 {"error":"invalid_grant"}
رفضنا: code مش موجود أو اتستخدم قبل كده
نفس الـ code تاني:             400 {"error":"invalid_grant"}
callback بـ state مزوّر:        400 {"error":"state غلط"}

الـ code المسروق اترفض، والـ IdP طبع إن الـ verifier مش موجود. والـ replay اترفض لأن الـ code اتحرق. ونشغّل test dot js.

idp.js

المخرجات

$ node idp.js & I=$!; node server.js & S=$!; sleep 1; node test.js; kill $I $S
IdP: http://localhost:4000
App: http://localhost:3000
302 ← localhost:3000/login
302 ← localhost:4000/authorize
✅ الـ login العادي بيرجّع welcome
302 ← localhost:3000/login
302 ← localhost:4000/authorize
رفضنا: code_verifier مش موجود أو شكله غلط
✅ code من غير code_verifier ← 400
رفضنا: code مش موجود أو اتستخدم قبل كده
✅ الـ code اتحرق بعد أول محاولة ← 400
302 ← localhost:3000/login
302 ← localhost:4000/authorize
رفضنا: code_verifier مش مطابق
✅ code_verifier غلط ← 400
302 ← localhost:3000/login
302 ← localhost:4000/authorize
رفضنا: client أو redirect_uri مختلف
✅ redirect_uri مختلف ← 400
✅ grant_type غلط ← 400

6/6 نجحوا

كله نجح، والـ login العادي لسه شغال. في الحقيقة انت مش هتكتب IdP، هتستخدم Google أو Auth0 أو Keycloak، وفي الـ client استخدم مكتبة زي openid-client. بس دلوقتي انت فاهم كل باراميتر بتعمله إيه. الدرس الجاي: الـ access token نفسه، إزاي الـ API يتأكد منه صح، والـ scopes والـ audience والـ key rotation.

server.js
// تطبيقنا (الـ client): login بـ OpenID Connect + PKCE
import express from "express";
import crypto from "node:crypto";
import { createRemoteJWKSet, jwtVerify } from "jose";

const IDP = "http://localhost:4000";
const CLIENT_ID = "my-backend";
const REDIRECT = "http://localhost:3000/callback";
const JWKS = createRemoteJWKSet(new URL(IDP + "/jwks"));
const rand = () => crypto.randomBytes(32).toString("base64url");
const cookie = (req, name) => req.get("cookie")?.match(new RegExp(`(?:^|; )${name}=([^;]+)`))?.[1];
const pending = new Map(); // tx → { state, nonce, verifier }

const app = express();

app.get("/login", (req, res) => {
  const t = { state: rand(), nonce: rand(), verifier: rand() };
  const tx = rand();
  pending.set(tx, t);
  const url = new URL(IDP + "/authorize");
  url.search = new URLSearchParams({
    response_type: "code",
    client_id: CLIENT_ID,
    redirect_uri: REDIRECT,
    scope: "openid email",
    state: t.state,
    nonce: t.nonce,
    code_challenge: crypto.createHash("sha256").update(t.verifier).digest("base64url"),
    code_challenge_method: "S256",
  });
  res.cookie("tx", tx, { httpOnly: true, sameSite: "lax", maxAge: 10 * 60 * 1000 });
  res.redirect(302, url.href);
});

app.get("/callback", async (req, res) => {
  const t = pending.get(cookie(req, "tx"));
  pending.delete(cookie(req, "tx")); // كل محاولة login تُستخدم مرة واحدة
  if (!t || req.query.state !== t.state) return res.status(400).json({ error: "state غلط" });

  const r = await fetch(IDP + "/token", {
    method: "POST",
    body: new URLSearchParams({
      grant_type: "authorization_code",
      code: req.query.code,
      redirect_uri: REDIRECT,
      client_id: CLIENT_ID,
      code_verifier: t.verifier,
    }),
  });
  if (!r.ok) return res.status(401).json({ error: "التبادل فشل", idp: await r.json() });
  const { id_token } = await r.json();

  const { payload } = await jwtVerify(id_token, JWKS, { issuer: IDP, audience: CLIENT_ID });
  if (payload.nonce !== t.nonce) return res.status(401).json({ error: "nonce غلط" });
  res.cookie("sid", rand(), { httpOnly: true, secure: true, sameSite: "lax" });
  res.json({ welcome: payload.email, sub: payload.sub });
});

app.listen(3000, () => console.log("App: http://localhost:3000"));
test.js
import { loginUntilCode } from "./browser.js";
const token = (body) =>
  fetch("http://localhost:4000/token", { method: "POST", body: new URLSearchParams(body) });
const base = { grant_type: "authorization_code", client_id: "my-backend", redirect_uri: "http://localhost:3000/callback" };
let ok = 0, all = 0;
const check = (name, cond) => { all++; if (cond) ok++; console.log(cond ? "✅" : "❌", name); };

// 1) الـ login العادي لازم يفضل شغال
const { tx, callback } = await loginUntilCode();
const res = await fetch(callback.href, { headers: { cookie: tx } });
check("الـ login العادي بيرجّع welcome", res.status === 200 && (await res.json()).welcome === "[email protected]");

// 2) code من غير verifier
let { callback: c2 } = await loginUntilCode();
const code2 = c2.searchParams.get("code");
check("code من غير code_verifier ← 400", (await token({ ...base, code: code2 })).status === 400);
// 3) نفس الـ code بعد محاولة فاشلة: اتحرق
check("الـ code اتحرق بعد أول محاولة ← 400", (await token({ ...base, code: code2, code_verifier: "x".repeat(43) })).status === 400);

// 4) verifier غلط
let { callback: c3 } = await loginUntilCode();
check("code_verifier غلط ← 400", (await token({ ...base, code: c3.searchParams.get("code"), code_verifier: "a".repeat(43) })).status === 400);

// 5) redirect_uri مختلف
let { callback: c4 } = await loginUntilCode();
check("redirect_uri مختلف ← 400", (await token({ ...base, code: c4.searchParams.get("code"), redirect_uri: "http://evil.example/cb", code_verifier: "a".repeat(43) })).status === 400);

// 6) grant_type غلط
check("grant_type غلط ← 400", (await token({ ...base, grant_type: "password", code: "x" })).status === 400);
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