簡體   English   中英

我如何設置我的 firebase 規則,以便只有內容所有者可以讀取和寫入他們的數據?

[英]How can I set up my firebase rules so only content-owners have read and write to their data?

我已經檢查了文檔,但我不確定如何將該規則應用於我的特定數據結構,請檢查我的數據是如何組織的,並向我提供規則,因為它應該是 go。

我正在使用實時數據庫,在我的應用程序代碼中,我根據用戶 ID 編寫和讀取,但 firebase 一直告訴我應該更改我的規則。

在此處輸入圖像描述

要應用文檔中關於僅內容所有者訪問您的結構的規則,需要:

{
  "rules": {
    "Expenses": {
      "$uid": {
        // Allow only authenticated content owners access to their data
        ".read": "auth != null && auth.uid == $uid"
        ".write": "auth != null && auth.uid == $uid"
      }
    },
    "Users": {
      "$uid": {
        // Allow only authenticated content owners access to their data
        ".read": "auth != null && auth.uid == $uid"
        ".write": "auth != null && auth.uid == $uid"
      }
    }
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM