以下是我们在 I/O 大会上宣布的所有内容,从新的 Firebase Studio 功能到集成 AI 的更多方式,内容非常丰富。
阅读博客。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Firebase Security Rules
plat_ios
plat_android
plat_web
plat_flutter
plat_node
使用靈活、可擴充的 Firebase 安全性規則,
保障您在「Cloud Firestore」、「Firebase Realtime Database」和
Cloud Storage。
Firebase Security Rules 能區分您的資料和惡意使用者。編寫簡單的
採取複雜的規則,以更精細的方式保護應用程式資料
您的特定應用程式需求
「Firebase Security Rules」利用
可擴充的彈性設定語言,
「Realtime Database」、「Cloud Firestore」和「Cloud Storage」可以存取。
Firebase Realtime Database Security Rules 會在規則定義中使用 JSON,而
Cloud Storage 的 Cloud Firestore Security Rules 和 Firebase Security Rules 使用專屬的
來處理更複雜的規則專屬結構。
進一步瞭解如何為特定 Firebase 產品設定 Rules
在應用程式中使用,以及「Rules」在不同 Firebase 中的行為差異
很少直接解答該如何打造產品
開始
主要功能
彈性 |
撰寫符合應用程式結構和行為的自訂規則。
Rules 會使用你使用自己的資料的語言
授予存取權。
|
精細程度 |
您可視需要設定規則的廣泛或範圍。
|
獨立安全性 |
因為 Rules 是在應用程式之外定義 (在 Firebase 控制台或
Firebase CLI)、用戶端
您不負責強制執行安全性,錯誤也不會損害資料。
保障資料安全
|
影片廣告的運作方式為何?
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,以 JSON 為基礎的 Rules 會使用下列語法:
{
"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。
實作路徑
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-24 (世界標準時間)。
[null,null,["上次更新時間: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)."]]