تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
لطالما كان الأمان أحد أكثر جوانب تطوير التطبيقات تعقيدًا. في معظم التطبيقات، على المطوّرين إنشاء خادم وتشغيله
يتولّى عملية المصادقة (تحديد هوية المستخدم) والتفويض (تحديد الإجراءات التي يمكن للمستخدم تنفيذها).
يصعب إعداد المصادقة والتفويض، ويصعب أكثر إعدادهما بشكل صحيح، وهما أمران ضروريان لنجاح منتجك.
على غرار الطريقة التي يسهّل بها Firebase Authentication مصادقة المستخدمين، يسهّل Firebase Security Rules في Cloud Storage عليك منح المستخدمين الإذن والتحقّق من صحة الطلبات. Cloud Storage Security Rules إدارة التعقيد نيابةً عنك من خلال
السماح لك بتحديد الأذونات المستندة إلى المسار. باستخدام بضعة أسطر من الرمز البرمجي، يمكنك كتابة قواعد تفويض تقيّد طلبات Cloud Storage بمستخدم معيّن أو تحدّ من حجم عملية تحميل.
تُعد معرفة هوية المستخدمين جزءًا مهمًا من عملية إنشاء التطبيق، وتوفّر
Firebase Authentication حلاً سهلاً وآمنًا للمصادقة من جهة العميل فقط. Firebase Security Rules يرتبط Cloud Storage بـ Firebase Authentication
في ما يتعلق بالأمان المستند إلى المستخدم. عندما يتم إثبات هوية المستخدم باستخدام Firebase Authentication، يصبح المتغيّر request.auth في Cloud Storage Security Rules عنصرًا يحتوي على المعرّف الفريد للمستخدم (request.auth.uid) وجميع معلومات المستخدم الأخرى في الرمز المميز (request.auth.token). وعندما لا يتم إثبات هوية المستخدم، تكون قيمة request.auth هي null. يتيح لك ذلك التحكّم بشكل آمن في إمكانية الوصول إلى البيانات لكل مستخدم على حدة. يمكنك الاطّلاع على مزيد من المعلومات في قسم المصادقة.
التفويض
تحديد هوية المستخدم هو جزء واحد فقط من الأمان. بعد معرفة المستخدمين، عليك إيجاد طريقة للتحكّم في إمكانية وصولهم إلى الملفات في Cloud Storage.
تتيح لك Cloud Storage تحديد قواعد التفويض لكل ملف ولكل مسار، وهي قواعد مخزّنة على خوادمنا وتحدّد إمكانية الوصول إلى الملفات في تطبيقك. على سبيل المثال، تتطلّب Cloud Storage Security Rules التلقائية Firebase Authentication من أجل تنفيذ أي عمليات read أو write على جميع الملفات:
يمكنك تعديل هذه القواعد من خلال اختيار تطبيق Firebase في وحدة تحكّم Firebase
وعرض علامة التبويب Rules في قسم "التخزين".
التحقّق من صحة البيانات
يمكن أيضًا استخدام Firebase Security Rules لـ Cloud Storage للتحقّق من صحة البيانات، بما في ذلك التحقّق من صحة اسم الملف ومساره وخصائص البيانات الوصفية للملف، مثل contentType وsize.
servicefirebase.storage{match/b/{bucket}/o{match/images/{imageId}{//Onlyallowuploadsofanyimagefilethat's less than 5MBallowwrite:ifrequest.resource.size < 5*1024*1024&&request.resource.contentType.matches('image/.*');}}}
تاريخ التعديل الأخير: 2025-08-23 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-08-23 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["\u003cbr /\u003e\n\nTraditionally, security has been one of the most complex parts of app\ndevelopment. In most applications, developers must build and run a server that\nhandles authentication (who a user is) and authorization (what a user can do).\nAuthentication and authorization are hard to set up, harder to get right, and\ncritical to the success of your product.\n\nSimilar to how Firebase Authentication makes it easy for you to authenticate your\nusers, Firebase Security Rules for Cloud Storage makes it easy for you to authorize users\nand validate requests. Cloud Storage Security Rules manage the complexity for you by\nallowing you to specify path based permissions. In just a few lines of code, you\ncan write authorization rules that restrict Cloud Storage requests to a\ncertain user or limit the size of an upload.\n| **Note:** If you use Google App Engine and have a default Cloud Storage bucket with a name format of `*.appspot.com`, you may need to consider [how your security rules impact access to App Engine files](/docs/storage/gcp-integration#security-rules-and-app-engine-files).\n\nThe Firebase Realtime Database has a similar feature, called\n[Firebase Realtime Database Security Rules](/docs/database/security)\n\nAuthentication\n\nKnowing who your users are is an important part of building an application, and\nFirebase Authentication provides an easy to use, secure, client side only solution\nto authentication. Firebase Security Rules for Cloud Storage ties in to Firebase Authentication\nfor user based security. When a user is authenticated with Firebase Authentication,\nthe `request.auth` variable in Cloud Storage Security Rules becomes an object that\ncontains the user's unique ID (`request.auth.uid`) and all other user\ninformation in the token (`request.auth.token`). When the user is not\nauthenticated, `request.auth` is `null`. This allows you to securely control\ndata access on a per-user basis. You can learn more in the\n[Authentication](/docs/storage/security/rules-conditions#authentication) section.\n\nAuthorization\n\nIdentifying your user is only part of security. Once you know who they are, you\nneed a way to control their access to files in Cloud Storage.\n\nCloud Storage lets you specify per file and per path authorization\nrules that live on our servers and determine access to the files in your app.\nFor example, the default Cloud Storage Security Rules require Firebase Authentication in\norder to perform any `read` or `write` operations on all files: \n\n```css+lasso\nservice firebase.storage {\n match /b/{bucket}/o {\n match /someFolder/{fileName} {\n allow read, write: if request.auth != null;\n }\n }\n}\n```\n\nYou can edit these rules by selecting a Firebase app in the [Firebase console](//console.firebase.google.com/)\nand viewing the `Rules` tab of the Storage section.\n\nData Validation\n\nFirebase Security Rules for Cloud Storage can also be used for data validation, including\nvalidating file name and path as well as file metadata properties such as\n`contentType` and `size`. \n\n```gdscript\nservice firebase.storage {\n match /b/{bucket}/o {\n match /images/{imageId} {\n // Only allow uploads of any image file that's less than 5MB\n allow write: if request.resource.size \u003c 5 * 1024 * 1024\n && request.resource.contentType.matches('image/.*');\n }\n }\n}\n```\n\nNext steps\n\n- [Get started](/docs/storage/security/get-started) planning rules development\n for your Cloud Storage buckets.\n\n- Learn more about [securing your data](/docs/storage/security/core-syntax)\n using security rules."]]