Firestore 安全规则获取与列表
Firestore security rule get vs. list
假设我试图让网页仅在用户具有确切 link 时才可读,我可以使用如下文档 ID 和安全规则的组合来实现此目的吗?
例如。我有文件存储在
/posts/{postID}
我设置了安全规则:
match /posts/{postID} {
allow get, write: if true;
allow list: if false;
}
是否会简单地禁用“列表”操作,使您只能访问已知其确切 ID 的文档?在我看来是这样,但我不确定我是否遗漏了任何边缘情况。
Would simply disabling the "list" operation make it such that you can
only access a document if you already know its exact ID?
对,没错。
对 posts
集合的任何查询都将 return 出现“缺少或权限不足”错误,即使是使用确切 ID 进行查询的查询,如:
firebase
.firestore()
.collection('posts')
.where('__name__', '==', 'exactID')
.get()
假设我试图让网页仅在用户具有确切 link 时才可读,我可以使用如下文档 ID 和安全规则的组合来实现此目的吗?
例如。我有文件存储在
/posts/{postID}
我设置了安全规则:
match /posts/{postID} {
allow get, write: if true;
allow list: if false;
}
是否会简单地禁用“列表”操作,使您只能访问已知其确切 ID 的文档?在我看来是这样,但我不确定我是否遗漏了任何边缘情况。
Would simply disabling the "list" operation make it such that you can only access a document if you already know its exact ID?
对,没错。
对 posts
集合的任何查询都将 return 出现“缺少或权限不足”错误,即使是使用确切 ID 进行查询的查询,如:
firebase
.firestore()
.collection('posts')
.where('__name__', '==', 'exactID')
.get()