【发布时间】:2020-03-10 15:39:08
【问题描述】:
对不起,我太天真了。我对使用 kreait/firebase-php 包进行身份验证有点困惑。我在 firebase 控制台定义了一些规则,例如:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow create,delete:if request.auth.uid == true;
}
}
}
问题是,即使我更改规则,服务(CRUD)的行为也会以相同的方式工作。看来 JSON 文档(从 google 下载的服务帐户)具有所有权限或不需要 firebase 规则。
就我而言,我想将访问和数据库操作限制为没有身份验证和权限的用户。
我目前正在检查电子邮件/密码。如果请求为真,该方法将返回一个令牌。之后,我将令牌保存在 CACHE 中,并在用户注销时将其删除。对于每个请求,中间件都会检查令牌是否存在于 CACHE 中。这样,它只会帮助我限制用户的访问页面。如何限制数据库的操作(CRUD)?谢谢大家!
【问题讨论】:
标签: firebase google-cloud-firestore firebase-authentication firebase-security