Firebase 特定火基规则

Firebase 特定火基规则,firebase,google-cloud-firestore,firebase-security,Firebase,Google Cloud Firestore,Firebase Security,我正在使用firestore作为事件应用程序的API端点,需要能够为集合编写数据。我怎么写规则 应用程序没有身份验证(它是完全公开的),因此我尝试了以下规则: service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read: if true; } } // Need to be a

我正在使用firestore作为事件应用程序的API端点,需要能够为集合编写数据。我怎么写规则

应用程序没有身份验证(它是完全公开的),因此我尝试了以下规则:

service cloud.firestore {
    match /databases/{database}/documents {
        match /{document=**} {
            allow read: if true;
        }
    }

    // Need to be able to write documents into the silent_disco collection
    match /databases/silent_disco/documents {
    match /{document=**} {
            allow write: if true;
        }
    }

    // Need to be able to write into the passport collection
    match /databases/passport/documents {
    match /{document=**} {
            allow write: if true;
        }
    }
}

当我使用模拟内存时,我可以按预期读取所有内容,但写入请求被拒绝。

以下操作应能正常工作:

service cloud.firestore {
    match /databases/{database}/documents {

        match /{document=**} {
           allow read: if true;
        }

        // Need to be able to write documents into the silent_disco collection
        match /silent_disco/{docId} {
            allow write: if true;
        }

        // Need to be able to write documents into the passport collection
        match /passport/{docId} {
            allow write: if true;
        }

    }
}

您可以观看关于该主题的精彩官方视频:

这似乎很有效,谢谢!视频也是一个很好的资源,我会把它收藏起来。非常感谢。