firebase-security

Can i use this claim in firebase database security rules?

只谈情不闲聊 提交于 2019-12-25 01:43:45
问题 I have use this firebase to set a custom claim const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(); exports.sellerCustomClaim = functions.database.ref('/Users/{userNumber}') .onCreate((data, context) => { const sellerNumber = context.params.userNumber; const uid = context.auth.uid; const customClaims = { number: sellerNumber, }; console.log(`Uid: ${uid}, number: ${sellerNumber}`); console.log(`before Seller number: ${sellerNumber}`);

Firebase security rules for child items in arrays

女生的网名这么多〃 提交于 2019-12-24 23:39:12
问题 I have the following data structure in my firebase: { "groups" : { "-KEFQ7rTQscPX4hqn6ec" : { "createdBy" : "b5cd3a86-108e-4ef3-9ab8-8a1e4da7491c", "description" : "Test", "isPublic" : true, "title" : "T1" }, "-KEFQao_Wd-Y-nLzIx2e" : { "createdBy" : "b5cd3a86-108e-4ef3-9ab8-8a1e4da7491c", "description" : "B", "isPublic" : false, "title" : "E" } } and am trying to achieve the following: Everybody can read all groups with "isPublic" == true Only logged in users can see the groups that they have

How to save, with anonymous authentication, to Firebase database - using Flutter

梦想的初衷 提交于 2019-12-24 23:16:08
问题 I'm getting permission denied after I have authenticated with Anonymous Auth [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception: E/flutter (21033): PlatformException(-3, Permission denied, ) ... _getCurrentUser: FirebaseUser({providerId: firebase, uid: DOIL...............u54j1, displayName: , email: , isAnonymous: true, isEmailVerified: false, providerData: [{providerId: firebase, uid: DOIL//////////////54j1, displayName: , email: }]}) My rules on the Firebase DB are {

Check if request.resource.data is a list of strings in Firebase Firestore

依然范特西╮ 提交于 2019-12-24 23:13:45
问题 How do I check if a field is of type string[] in firestore rules? I have a tags field in a document, which should be a list of strings, and I want to enforce that. Normally, I can say request.resource.data is int if I want to see if the field is an int , but I can't find an equivalent for lists . Thanks! 回答1: There is no explicit type check in the rules language (at least as far as I know). So the best I can come up with is trying to find a way to distinguish between a List (the type of an

Checking a users custom claims (is an admin) on login with React, Redux and Firebase

不羁岁月 提交于 2019-12-24 20:00:01
问题 I was wondering if someone could help me. I am currently building an admin dashboard, which can only be accessed by admins. I am using React, Redux and Firebase. I have managed to set custom claims on specific users in a cloud function like so: exports.addSuperAdminRole = functions.https.onCall((data, context) => { return admin.auth().getUserByEmail(data.email).then(user => { return admin.auth().setCustomUserClaims(user.uid, { superAdmin: true }) }).then(() => { return { message: `Success! $

Create hidden user node using firebase realtime

大城市里の小女人 提交于 2019-12-24 19:58:34
问题 I am having some issues with Firebase security rules. I want any user to be able to create an account using my iOS app at the same time once he or she establishes the account I want to have two nodes one is private, and one is public. I want the public to be accessed by anyone, including the user its self, but the user that created the account only accesses the private node. I have tried a lot of things, but none of my work seems to work. I want to fetch all the public node values by just

limit number of children with storage rules

 ̄綄美尐妖づ 提交于 2019-12-24 19:13:36
问题 I want to limit user to upload at most 4 images. storage rules can limit a number of children in specific node? this is my storage rules without children limitation. service firebase.storage { match /b/{bucket}/o { match /users/{uid}/{filename} { allow read, write: if request.auth.uid == uid; } } } thanks in advance 回答1: The short answer is no, there isn't a way to achieve this using storage security according to the documentation for storage security rules. The related question Frank linked

Firebase can't push data given the ruleset

徘徊边缘 提交于 2019-12-24 18:54:10
问题 I'm trying to create a password protected chat room and found this SO answer to user as an example: Firebase: approach to storing room passwords The problem is, given the ruleset in the answer, I can't figure out how to push new data. My rules looks like this: { "rules": { "myApp":{ "chatRooms" : { "$roomID" : { "password": { ".read": "false", ".write": "root.child('myApp/chatRooms/' + $roomID + 'chatInfo').child('admin').val() == auth.uid" }, "chatInfo" : { ".read":true, ".write": "data

Firestore security rules email_verified not working

末鹿安然 提交于 2019-12-24 18:52:36
问题 If I create a new user with createUserWithEmailAndPassword , even though I didn't verify the mail yet, that user is already logged in. And his .emailVerified === false , and until here all good. Now, I go to the mail, verify it using the link, go back to the web app, it is still .emailVerified === false so I refresh the page, now .emailVerified === true . So I try to reach this doc: public async getPublicUserDetails() { const currentUserId = this._angularFireAuth.auth.currentUser.uid; try {

Restrict Firestore gmail sign in to specific domain

荒凉一梦 提交于 2019-12-24 14:36:36
问题 I want to restrict the users to be able to sign in in my Firestore application using the specific gmail domain. I found the similar question here but that is totally different from the Firestore. So let me explain my requirement what I want. Suppose one company called abc.com are using the gmail services and they have integrated their all email accounts to gmail. So they can use gmail email services using that account. So I want to restrict to users that only use the username@abc.com gmail