簡體   English   中英

Firebase - 如何設置安全規則,只有登錄用戶才能讀寫?

[英]Firebase - How to set security rules so that only logged in users can read and write?

Firebase - 如何設置安全規則以便只有登錄用戶才能讀寫特定表?

對於登錄,我使用 firebase 內置身份驗證。

您可以檢查auth變量

{
  "rules": {
    "posts": {
      "$post_id": {
        ".write": "auth != null"
      }
    }
  }
}

請查看《 Firebase安全指南》以了解更多信息。

另外,您可能想簽出Bolt編譯器。

通過改變規則如下

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth != null;
    }
  }
}

暫無
暫無

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

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