تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
Firebase Security Rules
plat_iosplat_androidplat_webplat_flutterplat_node
يمكنك استخدام "قواعد أمان Firebase" المرنة والقابلة للتوسُّع
تأمين بياناتك في Cloud Firestore وFirebase Realtime DatabaseCloud Storage
يظهر تطبيق "Firebase Security Rules" بين بياناتك والمستخدمين الضارين. يمكنك كتابة بيانات بسيطة أو
هي قواعد معقّدة تحمي بيانات تطبيقك بمستوى الدقّة الذي
يتطلبها تطبيقك المحدد.
الاستفادة من Firebase Security Rules
لغات إعداد مرنة وقابلة للتوسُّع لتحديد البيانات التي يمكن للمستخدمين الوصول إليها.
بإمكانها الوصول إلى Realtime Database وCloud Firestore وCloud Storage.
Firebase Realtime Database Security Rules تستفيد من JSON في تعريفات القواعد
تستفيد Cloud Firestore Security Rules وFirebase Security Rules لـ Cloud Storage من قيمة فريدة
لغة تم تصميمها لاستيعاب بُنى أكثر تعقيدًا خاصة بالقواعد.
مزيد من المعلومات حول كيفية إعداد Rules لمنتجات Firebase المحدّدة
المستخدَمة في تطبيقك، ومدى اختلاف سلوك Rules عبر Firebase
المنتجات.
كتابة قواعد مخصّصة منطقية لبنية تطبيقك وسلوكه
تستخدم ميزة "Rules" لغات تتيح لك الاستفادة من بياناتك الخاصة.
لمنح إذن الوصول.
الدقة
يمكن أن تكون قواعدك واسعة أو ضيقة حسب حاجتك.
الأمان المستقل
بما أنّه يتم تحديد Rules خارج تطبيقك (في وحدة تحكّم Firebase أو
واجهة سطر الأوامر Firebase)، العملاء
ليست مسئولة عن فرض الأمان، والأخطاء لا تهدد البيانات،
فإن بياناتك محمية دائمًا.
كيف تعمل هذه الإعلانات؟
تعمل Firebase Security Rules بمطابقة نمط مع مسارات قواعد البيانات، ثم تطبيقها
شروط مخصصة للسماح بالوصول إلى البيانات في تلك المسارات. جميع Rules
تتضمّن جميع منتجات Firebase مكوّنًا لمطابقة المسار وشرطًا
عبارة تسمح بالوصول للقراءة أو الكتابة. يجب تحديد Rules من أجل
كل منتج من منتجات Firebase تستخدمه في تطبيقك.
بالنسبة إلى Cloud Firestore وCloud Storage، استخدِم Rules ما يلي:
بناء الجملة:
service <<name>> {
// Match the resource path.
match <<path>> {
// Allow the request if the following conditions are true.
allow <<methods>> : if <<condition>>
}
}
بالنسبة إلى Realtime Database، تستخدم لغة Rules المستندة إلى JSON البنية التالية:
{
"rules": {
"<<path>>": {
// Allow the request if the condition for each method is true.
".read": <<condition>>,
".write": <<condition>>
}
}
}
يتم تطبيق Rules كعبارات OR، وليس كعبارة AND.
وبالتالي، إذا تطابقت قواعد متعددة مع أحد المسارات، وكان أيٌ من قواعد
تمنح الشروط إمكانية الوصول، تمنح Rules إمكانية الوصول إلى البيانات الموجودة على ذلك
. لذلك، إذا منحت إحدى القواعد العامة إمكانية الوصول إلى البيانات، فلا يمكنك حصر إمكانية الوصول باستخدام
بقاعدة أكثر تحديدًا. ومع ذلك، يمكنك تجنب هذه المشكلة بالتأكد من أن
لا تتداخل Rules كثيرًا. هناك تداخل في علم واحد (Firebase Security Rules) في
المسارات المطابقة كتحذيرات من برنامج التحويل البرمجي.
بإمكان "Firebase Security Rules" أيضًا الاستفادة من Authentication لمنح الأذونات المستندة إلى المستخدمين،
التي تحددها يمكن أن تكون أساسية للغاية أو معقدة بشكل لا يصدق. مزيد من المعلومات
حول اللغة والسلوك لدى "Rules"
قبل البدء في كتابة Rules.
تاريخ التعديل الأخير: 2025-07-24 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-07-24 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["Firebase Security Rules \nplat_ios plat_android plat_web plat_flutter plat_node \nUse our flexible, extensible Firebase Security Rules to\nsecure your data in Cloud Firestore, Firebase Realtime Database, and\nCloud Storage.\n\nFirebase Security Rules stand between your data and malicious users. You can write simple or\ncomplex rules that protect your app's data to the level of granularity that\nyour specific app requires.\n\nFirebase Security Rules leverage\nextensible, flexible configuration languages to define what data your users\ncan access for Realtime Database, Cloud Firestore, and Cloud Storage.\nFirebase Realtime Database Security Rules leverage JSON in rule definitions, while\nCloud Firestore Security Rules and Firebase Security Rules for Cloud Storage leverage a unique\nlanguage built to accommodate more complex rules-specific structures.\n\nLearn more about how to set up Rules for the specific Firebase products\nyou use in your app, and how Rules behavior differs across Firebase\nproducts.\n\n[Get started](/docs/rules/get-started)\n\nKey capabilities\n\n|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Flexibility | Write custom rules that make sense for your app's structure and behavior. Rules use languages that allow you to leverage your own data to authorize access. |\n| Granularity | Your rules can be as broad or as narrow as you need. |\n| Independent security | Because Rules are defined outside of your app (in the Firebase console or Firebase CLI), clients aren't responsible for enforcing security, bugs don't compromise data, and your data is always protected. |\n\nHow do they work?\n\nFirebase Security Rules work by matching a pattern against database paths, and then applying\ncustom conditions to allow access to data at those paths. All Rules\nacross Firebase products have a path-matching component and a conditional\nstatement allowing read or write access. You must define Rules for\neach Firebase product you use in your app.\n\nFor Cloud Firestore and Cloud Storage, Rules use the following\nsyntax: \n\n service \u003c\u003cname\u003e\u003e {\n // Match the resource path.\n match \u003c\u003cpath\u003e\u003e {\n // Allow the request if the following conditions are true.\n allow \u003c\u003cmethods\u003e\u003e : if \u003c\u003ccondition\u003e\u003e\n }\n }\n\nFor Realtime Database, JSON-based Rules use the following syntax: \n\n {\n \"rules\": {\n \"\u003c\u003cpath\u003e\u003e\": {\n // Allow the request if the condition for each method is true.\n \".read\": \u003c\u003ccondition\u003e\u003e,\n \".write\": \u003c\u003ccondition\u003e\u003e\n }\n }\n }\n\nRules are applied as `OR` statements, not `AND` statements.\nConsequently, if multiple rules match a path, and any of the matched\nconditions grants access, Rules grant access to the data at that\npath. Therefore, if a broad rule grants access to data, you can't restrict with\na more specific rule. You can, however, avoid this problem by making sure your\nRules don't overlap too much. Firebase Security Rules flag overlaps in your\nmatched paths as compiler warnings.\n\nFirebase Security Rules can also leverage Authentication to grant user-based permissions, and the\nconditions you set can be very basic or incredibly complex. Learn more\nabout Rules [language](/docs/rules/rules-language) and [behavior](/docs/rules/rules-behavior)\nbefore you start writing Rules.\n\nImplementation path\n\n|---|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|\n| | Integrate the product SDKs | Set up [Cloud Firestore](/docs/firestore), [Cloud Storage](/docs/storage), or [Realtime Database](/docs/database) for your app. |\n| | Write your Firebase Security Rules | Learn more about [how Rules work](/docs/rules/rules-behavior) and [set up some basic Rules](/docs/rules/basics) |\n| | Test your Firebase Security Rules | Use the Realtime Database and Cloud Firestore emulators to test your app's behavior and validate your rules before you deploy them to production. |\n| | Deploy your Firebase Security Rules | Use the Firebase console or the Firebase CLI to deploy your rules to production. |\n\nNext steps\n\n- [Understand the Firebase Security Rules language](/docs/rules/rules-language).\n- Learn more about [how Firebase Security Rules work](/docs/rules/rules-behavior).\n- Explore the [common mistakes you should avoid](/docs/rules/insecure-rules)."]]