我有一个非常简单的firestore数据库,看起来像上面的图片。
我想编写一个安全规则,以便只有经过身份验证的用户才能进入,但是无论我写什么,我总是会被拒绝权限。
我尝试过:
rules_version = '2';
service cloud.firestore {
match /users/{user} {
allow read, write: if request.auth.uid == user
match / {docs = **} {
allow read, write: if request.auth.uid == user
}
}
}
我也尝试过:
rules_version = '2';
service cloud.firestore {
match /users/{user} {
allow read, write: if request.auth.uid == user
match / {docs = **} {
allow read, write: if request.auth.uid == user
}
}
}
我也尝试过:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId}/{documents=**} {
allow read, write: if isOwner(userId);
}
}
function isOwner(userId) {
return request.auth.uid == userId;
}
}
这不起作用:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /sessions/{sessionID} {
allow read, write: if request.auth != null;
}
}
}
这也不是:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /sessions/{sessionsID} {
allow read, write: if request.auth != null;
}
}
}
答案 0 :(得分:1)
我试图将规则与您的数据库结构进行比较。
$entry = $this->serializer->deserialize($content, CreateDto::class, 'json', ["groups" => "api"]);
现在,这应该只允许注册用户访问。