firebase-security

Firebase encryption at rest

故事扮演 提交于 2019-12-24 13:35:06
问题 I really enjoy using Firebase, and I would like to use it in a new app, but the app would have the user upload sensitive information. I know Firebase uses https, but looking around, it seems Firebase does not yet make encryption at rest available. Is there a way around this to use Firebase and still make an administrator unable to read the data from the Firebase Forge, for instance? Thank you. 回答1: If you encrypt all data that you store in Firebase with a key that is only known to the client,

Firebase : How to read every child node in parent except children with particular data

房东的猫 提交于 2019-12-24 07:25:11
问题 Assume the following. posts : { "$postid":{ "meta":{ "state":true, "text" :"I should be read", }, "likes":{ "uid1":true, "uid2":true, }, }, "$postid":{ "meta":{ "state":false, "text" :"I should be read", }, "likes":{ "uid1":true, "uid2":true, "uid3":true, }, } } I want to query the parent node('posts') as follows. Leave out posts with state = false Prioritise posts with most likes Security Rules Deny posts with state == false to be read. Here's the Javascript Version Of how I'm querying data.

How to filter by orderByChild containing a string in Firebase query-based rules

浪子不回头ぞ 提交于 2019-12-24 02:56:08
问题 I want to get all the users that are friends of the logged user. This is my data structure. { "users": { "UID1":{ "name":"Pepito", "friends":{ "UID2":true, "UID4":true, } } ... } } I am getting the users with this code Firebase.database.reference().child("users") .orderByChild("friends/" + Firebase.user.uid).equalTo(true) And the rules should be { "rules": { "users" : { ".read" : "query.orderByChild.contains('friends/')", "$uid" : { ".write": "auth.uid == $uid", } } } } But the rules not

Firebase Firestore prevent client side creation of fields in a document

喜你入骨 提交于 2019-12-24 01:43:02
问题 I am struggling to find a solution to prevent clients from just creating random fields with values in a document where they have write access to in Firestore. Since you cannot restrict access to single fields in Firestore like you could with the realtime database, this seems hard to achieve. A solution would maybe be to not allow creation of fields and just letting clients update fields, but this would mean you would have to precreate the fields for documents which is not really a good

firestore security for the update of specific field within document

让人想犯罪 __ 提交于 2019-12-24 01:17:30
问题 I have a following data structure as a firestore document and I want to set the security rule to each participants. { event_name: 'XXX', created_by: 'userid' participants: { userid_a: true, userid_b: true, userid_c: true, } } participants are set as array-like data to query the collection by using participant's userid. And I am updating the data as a following way const eventDoc = this.afs.doc('event/' + event_id ); participant_obj = {} participant_obj[`participant_obj.${user_id}`] = true;

Moving Firestore security rule to custom function breaks rule

末鹿安然 提交于 2019-12-24 00:55:06
问题 I have a Firestore security rule that check that an user has the proper code to access another document. service cloud.firestore { match /databases/{database}/documents { match /Orgs/{orgID} { allow read: if get(/databases/$(database)/documents/Users/$(request.auth.uid)).data.OrgCode == resource.data.Code; } } } This works great. However, if I try to move this check into a custom function like so: service cloud.firestore { match /databases/{database}/documents { match /Orgs/{orgID} { allow

Firebase database rules. Allow when wildcard's child === auth.uid

℡╲_俬逩灬. 提交于 2019-12-24 00:15:56
问题 Structure: { "accounts" : { "JGeRgwAUBM..." : { "active" : true, "created" : 1468406951438, "key" : "JGeRgwAUBM..." } } Rules: { "rules": { ".read": false, ".write": false, "accounts": { "$uid": { ".read": "$uid === auth.uid", ".write": "$uid === auth.uid" } } } } Goal: Instead of using the auth.uid as key for the data, I would rather prefer to use the generated key from push().getKey() { "accounts" : { "theKeyIGetFrom: push().getKey()" : { "active" : true, "created" : 1468406951438, "auth

Limit a specific type of user in Firestore to read documents based on time

此生再无相见时 提交于 2019-12-23 22:26:27
问题 Has any way to limit users to read based on time, using Firestore Rules? E.g: Limit a malicious user authenticated as an anonymous user to read a document several times per millisecond. This can cause elevate pricing for this multiples requests 回答1: There is no way to limit the rate of document reads using security rules. If you think someone is abusing the resources in your project, contact Firebase support and explain what you're observing. 来源: https://stackoverflow.com/questions/53227674

firestore transaction throws error for update rule which allows only has one specific field

ぃ、小莉子 提交于 2019-12-23 22:08:04
问题 by execution of firestore runTransaction function on the web, it occurs error below. firestore.googleapis.com/v1beta1/projects/myproject/databases/(default)/documents:commit:1 POST https://firestore.googleapis.com/v1beta1/projects/myproject/databases/(default)/documents:commit 403 i want to allow only update one field for everyone and others are for login user. so update rule uses next. allow update: if request.resource.data.keys().hasOnly(["numPlayed"]) || request.auth.uid != null; and

Firestore query in app gives permission denied, while simulator works fine

折月煮酒 提交于 2019-12-23 15:57:07
问题 In my Firestore based app I use the following query to retrieve some data: FirebaseFirestore.getInstance().collection("events").document( eventId ).collection("instances").get().addOnCompleteListener( .... ) This gives a permission denied stacktrace: FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions. The relevant part of my rules is as follows: match /events/{eventId} { allow create: if isCurrentUser( request.resource.data.owner ); allow read: if isOwner