קל לארגן דפים בעזרת אוספים אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
בדף הזה מתוארות השיטות המומלצות החשובות ביותר לשמירה על אבטחה בסביבות שונות, אבל כדאי לעיין ברשימת משימות האבטחה כדי לקבל הנחיות מפורטות ומקיפות יותר בנושא אבטחה ו-Firebase.
אבטחה לסביבות טרום-ייצור
אחד היתרונות של הפרדת סביבות בפרויקטים שונים של Firebase הוא גורם זדוני שיש לו גישה לסביבות המוכנות מראש לא יוכל גישה לנתוני משתמשים אמיתיים. אלה אמצעי האבטחה החשובים ביותר שיש לנקוט לסביבות טרום-ייצור:
הגבלת הגישה לסביבות טרום ייצור. באפליקציות לנייד, יש להשתמש ב- App Distribution (או משהו דומה) להפצה אפליקציה לקבוצה ספציפית של אנשים. קשה יותר להגביל אפליקציות אינטרנט. כדאי להגדיר פונקציית חסימה לסביבות המוכנות מראש שמגבילות את הגישה למשתמשים עם אימייל כתובות שספציפיות לדומיין שלך. לחלופין, אם אתם משתמשים ב-Firebase Hosting, תוכלו להגדיר את תהליכי העבודה שלכם בשלב טרום הייצור כך שישתמשו בכתובות URL זמניות לתצוגה מקדימה.
כשלא צריך לשמור על סביבה כזו, והיא נמצאת בשימוש רק על ידי משתמש אחד אדם (או במקרה של בדיקות, על ידי מכונה אחת) ישתמש Firebase Local Emulator Suite האמולטורים האלה בטוחים יותר מהר יותר כי הן יכולות לעבוד רק על Localhost במקום להשתמש בענן במשאבי אנוש.
חשוב לוודא שה-Firebase Security Rules מוגדר בשלב טרום-ייצור. בסביבות שונות, בדיוק כמו במשחק. באופן כללי, Rules יהיו זהות בכל הסביבות, עם האזהרה שמכיוון שהכללים משתנים באמצעות יכול להיות שיש כללים בשלב מוקדם יותר בצינור עיבוד הנתונים שעדיין לא קיימים בסביבת הייצור.
אבטחה לסביבות ייצור
נתוני ייצור הם תמיד יעד, גם אם האפליקציה מעורפלת. אמנם אי אפשר למנוע לחלוטין מגורם זדוני לקבל את הנתונים שלכם, אבל בעזרת ההנחיות האלה תוכלו להקשות עליו:
מפעילים ואוכפים את App Check בכל המוצרים שבהם אתם משתמשים שתומכים בכך. App Check מוודא שהבקשות אל שירותים לקצה העורפי מגיעים מהאפליקציות המקוריות שלכם. כדי להשתמש בו, עליך לרשום כל גרסה של האפליקציה אצל App Check. קל יותר כדאי להגדיר אותו לפני שיהיו לך משתמשים, לכן כדאי להגדיר אותו בהקדם האפשרי.
כדאי לכתוב Firebase Security Rules בצורה יעילה. Realtime Database, Cloud Firestore וגם Cloud Storage כולם מסתמכים על Rules שהוגדר על ידי המפתח כדי לאכוף מי צריך ומי לא יכול לגשת לנתונים. חשוב מאוד את האבטחה שלך כשכותבים Rules טוב. אם אתם לא בטוחים איך לעשות זאת, תוכלו להתחיל בcodelab הזה.
[[["התוכן קל להבנה","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-25 (שעון UTC)."],[],[],null,["This page describes the most important best practices for security across\nenvironments, but review the\n[*Security checklist*](/support/guides/security-checklist) for more detailed and\nthorough guidance about security and Firebase.\n\nSecurity for pre-production environments\n\nOne benefit of separating environments in different Firebase projects is that a\nmalicious actor who is able to access your pre-prod environments won't be able\naccess real user data. Here are the most important security precautions to take\nfor pre-production environments:\n\n- Limit access to pre-prod environments. For mobile apps, use\n [App Distribution](/docs/app-distribution) (or something similar) to distribute\n an app to a specific set of people. Web applications are harder to restrict;\n consider setting up a\n [blocking function](https://cloud.google.com/identity-platform/docs/blocking-functions)\n for the pre-prod environments that restricts access to users with email\n addresses that are specific to your domain. Or, if you're using\n Firebase Hosting, set up your pre-prod workflows to use\n [temporary preview URLs](/docs/hosting/test-preview-deploy).\n\n- When an environment doesn't need to be persisted and is only being used by one\n person (or in the case of tests, by one machine) use the\n [Firebase Local Emulator Suite](/docs/emulator-suite). These emulators are safer\n and faster because they can work entirely on localhost instead of using cloud\n resources.\n\n- Make sure that you have [Firebase Security Rules](/docs/rules) set up in pre-production\n environments, just as you do in prod. In general, the Rules should\n be the same across environments, with the caveat that since rules change with\n code, there may be rules earlier in the pipeline that don't yet exist in\n production.\n\nSecurity for production environments\n\nProduction data is always a target, even if the app is obscure. Following these\nguidelines doesn't make it impossible for a malicious actor to get your data,\nbut it makes it more difficult:\n\n- Enable and enforce [App Check](/docs/app-check) for all the products\n you're using that support it. App Check makes sure that requests to your\n backend services are coming from your genuine apps. In order to use it, you\n need to register each version of your app with App Check. It's easier to\n set up before you have users, so set it up as soon as possible.\n\n- Write robust [Firebase Security Rules](/docs/rules). Realtime Database, Cloud Firestore, and\n Cloud Storage all rely on developer-configured Rules to\n enforce who should and shouldn't be able to access data. It's essential to\n your security that you write good Rules. If you're not sure how,\n start with this [codelab](/codelabs/firebase-rules).\n\n- Review the [*Security checklist*](/support/guides/security-checklist) for more\n recommendations about security for production environments.\n\nNext steps\n\n- Review the [Firebase launch checklist](/support/guides/launch-checklist)."]]