[英]How to write firestore database security rule while not use firebase authentication
I want to use the phone number and password authentication for the application. 我想对应用程序使用电话号码和密码验证。 These type of authentication is not provided by firebase.
firebase不提供这些类型的身份验证。 So, normally create user collection and implement login signup flow.
因此,通常创建用户集合并实现登录注册流程。
Another thing is that I use phone number authentication for OTP send and verify. 另一件事是我使用电话号码验证进行OTP发送和验证。 So user entry is available in the authentical list.
因此,用户输入可在真实列表中找到。
I get request.resource.data.userUid from request and check that this userUid exists in authentication list. 我从请求中获取request.resource.data.userUid并检查此userUid是否存在于身份验证列表中。
match /user/{docId} {
allow read, write: if exists(/databases/$(database)/documents/user/$(request.resource.data.userUid))
}
Normally from any table we can check like this. 通常从任何表格我们可以像这样检查。 But I not found any way to access authentication list.
但我没有找到任何方式来访问身份验证列表。
Any way to write security rule as per my requirement or I need to change my authentication flow? 有什么方法可以根据我的要求编写安全规则,或者我需要更改我的身份验证流程?
If you're not using Firebase Authentication, then you can't use security rules to control access to specific users. 如果您未使用Firebase身份验证,则无法使用安全规则来控制对特定用户的访问。 There is no other way to validate the identity of the individual making the request.
没有其他方法可以验证发出请求的个人的身份。
request.auth
will always be null in this case. 在这种情况下,
request.auth
将始终为null。
In case you didn't know, Firebase Auth does provide phone number authentication . 如果您不知道,Firebase Auth确实提供了电话号码验证 。 You should be using this along with Cloud Firestore to implement security rules effectively.
您应该与Cloud Firestore一起使用它来有效地实施安全规则。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.