CSRF ومتى ينطبق
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
know when cross-site request forgery matters.
الموضوعات المخطط لها
- CSRF: a malicious site makes the user's browser send a request to your site, and the browser attaches the user's cookies automatically.
- It matters when authentication is carried by cookies that the browser sends by itself.
- Defenses: CSRF tokens,
SameSitecookies, and checking the request origin. - If your API uses an
Authorizationheader token that scripts add explicitly, the browser does not add it on its own, so CSRF is not the same risk. - CORS and CSRF are different: CORS controls which pages may read responses; CSRF defends state-changing requests that use cookies.
تفاصيل المخطط المبدئي
عرض عملي
| CORS | CSRF | |
|---|---|---|
| Concern | Which origins may read responses | Forged actions using cookies |
| Applies | Browser calls across origins | Cookie-authenticated browsers |
اختبر فهمك
Why is a bearer-token API less exposed to CSRF?
أظهر الإجابة
The browser does not attach the header automatically.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.