I am trying to implement sharing model like in Google Docs. That is:
- "Documents" are private by default.
- Some documents are accessible to everybody.
- Some documents are shared with users.
Right now my database stores document metadata in the database in per-user collections (${userid}/docs/${docid}
) and Firebase Storage is used to store assets under similar paths. I set up trivial security rules to manage that.
Now I am trying to figure out sharing:
- Should I move all documents into a global docs collection and have security rules check ACLs that are in the docs metadata?
- Should I try to replicate shared documents in each user collection? Seems brittle but cloud functions should help with synchronizing data.
- Keep documents under owning users and have security rules check permissions.
Is it even possible to have Firebase Storage security rules consult Firebase to fetch metadata?
Obviously, I am trying not to go overboard with database access, money is tight.