Skip to content

Instantly share code, notes, and snippets.

@ryanpbrewster
ryanpbrewster / Cargo.toml
Last active June 5, 2019 07:37
faye-websocket client race condition issue
[package]
name = "helloworld"
version = "0.1.0"
authors = ["Ryan Brewster <ryanpbrewster@gmail.com>"]
edition = "2018"
[dependencies]
actix = "0.8.3"
actix-web = "1.0.0"
actix-web-actors = "1.0.0"
import java.net.URI
import java.util
import com.google.api.gax.core.FixedCredentialsProvider
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider
import com.google.auth.Credentials
import com.google.cloud.firestore.{CollectionReference, FirestoreOptions}
import com.google.common.collect.{ImmutableList, ImmutableMap}
import io.grpc.ManagedChannelBuilder
service cloud.firestore {
match /databases/{database}/documents {
function isValidRoomName(roomName, userId) {
return roomName.matches(".*" + userId + ".*");
}
match /users/{userId} {
allow read;
allow write: if isValidRoomName(request.resource.data.room[4], userId);
}
}
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read;
allow write: if exists(request.resource.data.room);
}
match /rooms/{roomId} {
allow read, write;
}
}
service cloud.firestore {
match /databases/{database}/documents {
function getUserData() {
return get(/databases/$(database)/documents/users/$(request.auth.uid)).data
}
match /tenants/{tenantId} {
function isSignedIn() {
return request.auth != null;
}
function isUserInTenant(rsc) {
const firebase = require("@firebase/testing");
async function main() {
const projectId = "my-test-project";
await firebase.loadFirestoreRules({
projectId,
rules: `
service cloud.firestore {
match /databases/{database}/documents {
match /users/{company} {
index = {
"me" : {
"id" : "180922ae-7aab-4622-b4ad-131e9c901fa6",
"firstName" : "Ryan",
"lastName" : "Brewster",
"pictureName" : "8qBhJ.jpg",
"username" : "ryanpbrewster"
},
"spaces" : [ {
"org" : {
keeps["k6LtZplP42BP"] = {
"id" : "k6LtZplP42BP",
"keptAt" : 1450124151000,
"lastActivityAt" : 1450136608000,
"title" : "BKS Iyengar - Google Search",
"url" : "https://www.google.com/search?q=BKS+Iyengar&oi=ddle&ct=bks-iyengars-97th-birthday-5749978756546560-hp&hl=en",
"note" : null,
"tags" : [ ],
"libraries" : [ "l4Ucs258jBwL" ],
"summary" : "Ramamani. Children. Geeta and 5 others. Bellur Krishnamachar Sundararaja Iyengar (14 December 1918 - 20 August 2014), better known as B.K.S. Iyengar, was the founder of the style of yoga known as \" Iyengar Yoga\" and was considered one of the foremost yoga teachers in the world.",
libraries["lDqTLC8xZQ8g"] = {
"id" : "lDqTLC8xZQ8g",
"name" : "The River Bend",
"description" : "A collection of water-related links",
"numKeeps" : 13,
"visibility": "published",
"slug": "the-river-bend",
"kind": "user_created",
"keeps" : [ "kIQFYKlZha6Q", "kBGiqTPuxJVT", "kzIPMrXS9S1a", "k8YKZMtEZ6nm", "k6kG2oFUqpEC", "k1hHZKtnTA8r", "kBZm7WHI0nvs", "k1jGnwdiFFhO", "k7OeeD7oknho", "k3ID5yZvNt9M", "k0CfhKj66BFn", "k442LEj9lhWw", "kBrFMEFdRAOs" ]
}
orgs["ozusIbCoQ9Od"] = {
"id" : "ozusIbCoQ9Od",
"ownerId" : "180922ae-7aab-4622-b4ad-131e9c901fa6",
"handle" : "brewster-corp",
"name" : "BrewsterCorp",
"description" : "Tardigrade Appreciation Society",
"avatarPath" : "oa/b4a637fec29148b54032a2fbd5bbbe1e_1552x1552-124x0-200x200_cs.jpg",
"libraries" : [ "l3e2f3ssdVsz", "lDqTLC8xZQ8g", "lFQ3GouIOeD0", "lCAicdFkSCL9", "l4Ucs258jBwL" ]
}