horizon icon indicating copy to clipboard operation
horizon copied to clipboard

Give some way for permissions to look at data other than the current document

Open deontologician opened this issue 8 years ago • 3 comments

There have been a couple of mentions about how the validators are a bit limited at the moment since you can only look at the document and the context. There are a couple ways I can think of to modify this:

  1. Allow whatever reql you want from the validator. This has the problem that validators would no longer be synchronous. It's also probably pretty hard to optimize, since the validator is a black box that can do basically anything.
  2. Allow specifying extra reql queries you want to be passed to the validator. This has the benefit of giving us more we can statically optimize (maybe creating a changefeed on the data so we don't have to run it each time data come through). But it extends the config language a bit more, pushing us into "huge bloated config language" territory (maybe).
  3. RethinkDB might grow ref types (see rethinkdb/rethinkdb#4853). This would keep everything mostly the same on the Horizon end, but users could get data from other tables in the document itself. (They'd have to add out-references though, so this may still put some restrictions on how the users design their data scheme)
  4. Do nothing, say you need to do custom validation and write your own backend if you want this flexibility.

deontologician avatar May 24 '16 02:05 deontologician

3 for me.

  1. It keeps everything synchronous
  2. It doesn't complicate anything for those who don't need relations
  3. It simplifies and solves relational permissions
  4. ref's could sort relational queries on the client?
  5. It seems like a best-practice approach to both permission configuration and client queries

jakobrosenberg avatar May 27 '16 06:05 jakobrosenberg

sharing my use case - I'm trying to build a multi-tenant content management system, and want to make 'collections' of documents that can be edited only by some users. I store metadata regarding my collections in a table called 'collections', which contains which users are allowed to edit which docs. So I'd like to allow writes/reads to a collection(/table) only if the user is in a field in a corresponding field in the 'collections' table.

So 2 things prevent me from doing this in horizon right now -

  • the ability to specify wildcards/regexes for collection names in query templates (since collections can be created on the fly)
  • async/reql validation, based on data in another table

I'm ok with validation being asynchronous/a black box. As an example implementation detail, the validator function could take an optional done callback, to be called by the validator when it's finished.

threepointone avatar Jun 01 '16 10:06 threepointone

Looking forward to a solution for this too.

My use case is very similar to @threepointone's. The schema is pretty complex and has different layers of access.

mfferreira avatar Oct 29 '16 22:10 mfferreira