Skip to content

Refactor grants / rights - don't use a ResourceArray #476

@joepio

Description

@joepio

The Document demo invite is becoming slow. It starts impacting the tests. This is because the ResourceArray of write Agents in the document is starting to contain a lot of URLs. Every time we add one item to it, the back-end has to process quite a bit of data. I know I can find some ways to improve this performance, but the architecture is fundamentally unscalable. Keeping Agent references inside Resources will severely limit how many people will get access to one document.

Basically, currently we use node-based rights. We should consider going to edge-based rights.

One solution is to introduce Groups or Roles.

Another solutions is to put the relationship of Resource :write -> User in a seperate Grant resource: Resource <- :forResource Grant :forUser -> User.

This will be quite the refactor! But I think it needs to be done...

Grant Datamodel

  • resource (resource): the resource that grants are applied to
  • who (resource, Agent): the Agent who receives the rights
  • read (bool): allows viewing the data
  • write (bool): allows any edits (including deletion) and any children
  • append (bool): allows creating children

Thoughts:

  • Maybe make the rights an enum instead of a bunch of booleans, as write means that append is always true. Also, does a write of true combined with a read of false make any sense?
  • Should we allow multiple Agents in who? If we do, we may get the same problem that we're currently trying to solve.

Editing, querying and viewing Grants

Inspiration for testing scenarios:

  • When a Grant is edited, we need to check if the Agent requesting this has the rights to do this.
  • We should probably prevent items from being grant-less: that nobody can edit them.
  • Asking if someone has rigths to edit or view some resource should be very cheap.

What needs to be changed

  • Create the Grant datamodel
  • Make sure that Grants can only be created, read and edited by the right Agents.
  • Update the share / rights view in Atomic-Data-Browser
  • Update the invite flow
  • Migrate existing data (or do we keep the old functionality?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions