عرض عملي: أمان الدوال مع فحوص الملكية
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
combine roles and ownership in the service layer. Prepares JNR-040-LAB1.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Enable method security.
- Add
@PreAuthorize("hasRole('ADMIN')")to the "list all orders" service method. - Add a service method
getMyOrders(currentUser)that filters by owner. - Remove
customerIdfrom the create-order request body and take it from the principal. - Planned mistake: leaving the
customerIdin the body, so customer A creates an order for B. Show the attack, then fix. - Add tests for customer A, customer B, and admin.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.