简体   繁体   English

Firestore 安全规则:了解匹配 /databases/{database}/documents

[英]Firestore Security Rules: understanding match /databases/{database}/documents

I am having trouble wrapping my head around match /databases/{database}/documents , in the security rules from the official documentation:在官方文档的安全规则中,我无法理解match /databases/{database}/documents documents :

The match /databases/{database}/documents declaration specifies that rules should match any Cloud Firestore database in the project. match /databases/{database}/documents声明指定规则应匹配项目中的任何 Cloud Firestore 数据库。 Currently each project has only a single database named (default)目前每个项目只有一个名为(默认)的数据库

Correct me if I am wrong, if, currently, there is only one database per project, the latter being named default so would it be possible to replace {database} by {default} or default as in /databases/default/documents ?如果我错了,请纠正我,如果当前每个项目只有一个数据库,后者被命名为default那么是否可以将{database}替换为{default}default ,如/databases/default/documents

If not, why?如果不是,为什么?

Also, following the "any" wildcard could we replace /databases/{database}/documents by /databases/{database=**}/documents ?此外,在“任何”通配符之后,我们可以将/databases/{database}/documents替换为/databases/{database=**}/documents吗?

If not, why?如果不是,为什么?

if, currently, there is only one database per project, the latter being named default so would it be possible to replace {database} by {default} or default as in /databases/default/documents?如果目前每个项目只有一个数据库,后者被命名为 default 那么是否可以将 {database} 替换为 {default} 或 default ,如 /databases/default/documents?

You would replace it with "(default)".您可以将其替换为“(默认)”。 There are no other strings that will work, currently.目前没有其他可用的字符串。

Also, following the "any" wildcard could we replace /databases/{database}/documents by /databases/{database=**}/documents?此外,在“任何”通配符之后,我们可以将 /databases/{database}/documents 替换为 /databases/{database=**}/documents 吗?

No, that will not work.不,那行不通。 The recursive wildcard syntax you're referring to only works for matching paths of documents when referring to collections and documents.您所指的递归通配符语法仅适用于在引用 collections 和文档时匹配文档的路径。

Currently, there is no real value in saying anything other than "/databases/{database}/documents" as the prefix of the match.目前,除了“/databases/{database}/documents”作为匹配前缀外,没有任何实际价值。 There can be only one database per project.每个项目只能有一个数据库。 While the rules allow for the concept of more, in practice, there is never any more.虽然规则允许更多的概念,但在实践中,永远不会有更多。 That is not likely to change any time soon.这不太可能很快改变。

If you have feedback about the rules system, feel free to report that to Firebase support directly.如果您对规则系统有任何反馈,请随时直接向Firebase 支持部门报告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM