Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

Conditional grants #11

Closed
pixelspark opened this issue Jun 14, 2017 · 2 comments
Closed

Conditional grants #11

pixelspark opened this issue Jun 14, 2017 · 2 comments

Comments

@pixelspark
Copy link
Owner

pixelspark commented Jun 14, 2017

In the grants table, add an expression column that optionally contains an expression that restricts any action performed using the grant, so you can:

  • Grant a user to only DELETE/UPDATE rows that adhere to a condition (when the grant is used to perform a DELETE/UPDATE query, the restricting expression should be ANDed to the original WHERE statement)
  • Grant a user the right to only INSERT rows with certain values
  • Grant a user to only CREATE tables with a certain name

The expression should be able to contain special variables to check certain things, e.g.:

  • $invoker: the public key of the user invoking the transaction. A grant with expression "$invoker=owner" would only allow modifications to rows that have the public key of the invoker in the 'owner' column. This could be made more complex, e.g. (CASE WHEN $owner=x THEN ... WHEN $owner=y THEN ... ELSE 0 END).
  • $index: the index of the block this transaction is part of (useful for allowing transactions only after a certain amount of time)
@pixelspark pixelspark modified the milestone: v1.next Jun 14, 2017
@pixelspark pixelspark modified the milestone: v1.next Jun 19, 2017
@pixelspark
Copy link
Owner Author

See also #8, the expression could be a hash of an allowed statement template instead.

@pixelspark pixelspark modified the milestones: v0.2, v0.3 Aug 17, 2017
pixelspark added a commit that referenced this issue Aug 21, 2017
…ock time

11 is not dividable by two, always leaving a middle value when there are enough blocks; no averaging of median values is required past block #11.
@pixelspark pixelspark mentioned this issue Aug 24, 2017
@pixelspark
Copy link
Owner Author

Needs top-level 'CASE WHEN' support, e.g.:

CASE WHEN (?amount > 0) AND (?from <> ?to) THEN 
UPDATE balances SET balance = balance + (CASE WHEN account = ?from THEN -amount ELSE amount END) WHERE account = ?from OR account = ?to
ELSE FAIL END;

(Note the above does not check whether the from account has the required funds; it only guarantees that the total amount of funds is constant over the execution of this query as long as account is a unique key for the table).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant