简体   繁体   English

如何在不使用firebase身份验证的情况下编写firestore数据库安全规则

[英]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.

相关问题 请求数据时以及未使用Firebase身份验证的情况下,如何编写Firebase Firestore的安全规则? - How to write security rules for firebase firestore when request data and in case where we have not used firebase authentication? 如何使用 Firestore 数据库和 Firebase 身份验证创建登录方法 - How to create a sign in method using firestore database and firebase authentication 如何匹配存储在 Firestore 的 Firebase 安全规则内的文档字段中的用户 uid - How to match a user's uid stored in document field inside Firebase security rule for Firestore Firestore orderBy 安全规则 - Firestore orderBy security rule 无法将数据写入数据库 firebase firestore - Can't write data into database firebase firestore 登录Firebase身份验证的用户时无法写入Firebase数据库 - Can't write to firebase database while a user from firebase authentication is signed in 在 Firestore 中,如何获取 Firebase Authentication 的 uid 为文档? - In Firestore, how to get the uid of Firebase Authentication to be a document? 如何在 Firebase Firestore 中使用查询 - How to use Query in Firebase Firestore 如何将 Firebase Firestore 与 Fragment 一起使用? - How to use Firebase Firestore with Fragments? 在Cloud Firestore中如何制作,只创建一次安全规则 - In Cloud Firestore how to make an, create only once security rule
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM