Multiple matches for complex firestore security rules?

292 views
Skip to first unread message

Kevin Burton

unread,
Jun 15, 2019, 11:07:09 AM6/15/19
to Firebase Google Group
I don't think it's possible but it would be nice to have multiple match statements separated by comments for more complex matches.

I have 3-4 tables that each  have 5-6 allow rules and there's no way to consolidate them now unfortunately.

Kato Richardson

unread,
Jun 17, 2019, 9:59:36 AM6/17/19
to Firebase Google Group
Hi Kevin,

Assuming that you mean you want something like this:

/match/foo/{bar} {
    allow read: if ...condition 1...
}

// or...

/match/foo/{bar} {
    allow read: if ...condition 2...
}

Then I think you could just do this instead?

function condition1() {
    return ... condition 1...
}

function condition2() {
   return ...condition 2...
}

/match/foo/{bar} {
   allow read: if condition1() || condition2();
}

☼, Kato

On Sat, Jun 15, 2019 at 8:07 AM Kevin Burton <burto...@gmail.com> wrote:
I don't think it's possible but it would be nice to have multiple match statements separated by comments for more complex matches.

I have 3-4 tables that each  have 5-6 allow rules and there's no way to consolidate them now unfortunately.

--
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/22ad893b-6436-49e6-bade-f2cacd6cf35e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Sam Stern

unread,
Jun 17, 2019, 11:41:09 AM6/17/19
to Firebase Google Group
Hey Kevin,

If I understand your question correctly, this already works in the way you want it to. If a single request matches more than one "match {}" block then the conditions are "OR"ed together.  So actually the two examples Kato gave are the same.

- Sam

Reply all
Reply to author
Forward
0 new messages