firestore : Security Rules

78 views
Skip to first unread message

webcre...@gmail.com

unread,
Aug 28, 2018, 10:14:04 AM8/28/18
to Firebase Google Group
hie,


I have a problem with Security Rules



I get this error for any access to any data (articles, categories...)

ERROR FirebaseError: "Missing or insufficient permissions."

why ??


articles
         key
             name
             
...
             uid  
(key user)
categories
         key
             
...
...



service cloud.firestore {
  match /databases/{database}/documents {
  
    match /articles/{key} {
      allow read, create: if isSignedIn();
      allow update, delete:     if isOwner();
    }
  }
}

function isOwner() {
  return request.auth.uid == incomingData().uid
}

function isSignedIn() {
  return request.auth.uid != null
}


please, help ! :)

Samuel Stern

unread,
Aug 28, 2018, 12:24:05 PM8/28/18
to fireba...@googlegroups.com
Could you show the code you're running that gives you the permission denied error?  Is it a write or a read?  That will help us figure out why you're getting permission denied.

Also what is "incomingData()" in your security rules?  I don't see that defined anywhere.

- Sam

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/456db0e9-e959-4ccf-a7a1-1e945b7731ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

webcre...@gmail.com

unread,
Aug 29, 2018, 11:03:11 AM8/29/18
to Firebase Google Group

Samuel Stern

unread,
Aug 30, 2018, 12:01:56 PM8/30/18
to fireba...@googlegroups.com
Unfortunately that gist link does not load for me (404), maybe it's private?  Also could you show the app code resulting in permission denied?

- Sam

On Wed, Aug 29, 2018 at 8:03 AM <webcre...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.

webcre...@gmail.com

unread,
Aug 30, 2018, 3:30:43 PM8/30/18
to Firebase Google Group
sorry

i forgot this part:

function incomingData() {


  return request.resource.data;
}



service cloud.firestore {
        match /databases/{database}/documents {

        match /articles/{key} {
            allow read, create:    if isSignedIn();
            allow update, delete:  if isOwner();
        }

    }
}

function isOwner() {

    return request.auth.uid == incomingData().uid
}

function isSignedIn() {

    return request.auth.uid != null
}

function incomingData() {

  return request.resource.data;
}



now it looks like it works !

thk



Reply all
Reply to author
Forward
0 new messages