انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهJNR-041-L03

الإسناد الجماعي (Mass assignment)

  • الدرس 3 من 7
  • Junior
في هذا الدرس 4 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

avoid letting clients set fields they should not.

الموضوعات المخطط لها

  • Mass assignment: binding a request body straight onto an entity lets clients set fields like role, price, or enabled.
  • Attack: send {"name":"Ana","role":"ADMIN"} to the registration endpoint.
  • Fix: bind requests to a separate DTO with only the allowed fields.
  • Copy fields explicitly into the entity.
  • Entities are for the database; DTOs are for the API.
تفاصيل المخطط المبدئي

عرض عملي

RegisterRequest(email, password) DTO versus an entity with a role field.

اختبر فهمك

Why not bind the request body to the entity?

أظهر الإجابة

A client could set fields such as role that it should not control.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.