Score:0

Optimal Firebase Realtime Database user groups and permissions design

US flag

I'm attempting to design a Realtime Database with Firebase that will be scalable as our company grows, and I'm not sure what will be most beneficial long term.

I'm looking to create user groups to restrict access to different nodes in the database and have some way of bypassing those rules with exceptions. The current idea is to have groups define what users can access and then have the option to apply exceptions to specific users to allow them access beyond what their group does.

Is this bad practice? Would it be better to have both roles and groups?

I'd also appreciate some feedback on the structure, I've thought of two different ways I could do this (there are probably hundreds of others, but in the interest of sanity, I limited it to two). Keep in mind, I'm trying to keep the structure flat in compliance with the Firebase docs:

STRUCTURE A
permissions:
  groups:
    admin:
      woody: true
      buzz: true
    accounts:
      slinky: true
      jessie: true
  rules:
    root:
      admin:
        read: true
        write: true
    purchasing:
      accounts:
        read: true
        write: true
  exceptions:
    root:
      jessie:
        read: true

STRUCTURE B
groups:
  admin:
    members:
      woody: true
      buzz: true
    rules:
      root:
        read: true
        write: true
  accounts:
    members:
      slinky: true
      jessie: true
    rules:
      purchasing:
        read: true
        write: true

The rationale behind the two is this: in Structure A, I can predefine a bunch of permissions that stay there always, regardless of if no groups have access to them, they are clearly defined. Structure B lacks that, but it also seems a little cleaner to me.

Hopefully that makes sense, if not, please feel free to ask clarifying questions. Cheers!

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.