Skip to content

Datalog playground #49

@divarvel

Description

@divarvel

While #9 is about having the CLI serve a web page with an interactive playground, this issue is about having the CLI provide a way to run datalog code without having to provide a token.

Currently, when I want to author datalog from my text editor, I use an empty token, along with the corresponding public key and feed them to biscuit inspect, along with the datalog file I'm authoring. This works, but is really not satisfying.
The alternative would be to use the web playground, but this is not as convenient as using my text editor.

What I'd like is a dedicated subcommand that centers on running datalog, without requiring a token:

biscuit playground --authorize-with FILENAME --query QUERY, etc.

Output

Same as in the web playground, the output would be first the authorization results, then the query results, then the complete set of generated facts

The tricky part

As long as no block scoping is needed, this works well. It becomes a little bit tricky when it comes to working with several blocks:

# same option name: the block order is easy to retrieve
biscuit playground --block-file FILENAME --block-file FILENAME --query QUERY
# different option names: the block order is harder to retrieve
biscuit playground --block DATALOG --block-file FILENAME --block DATALOG --query QUERY
# how to handle third-party blocks?
???

The different options I see are:

For the block order part:

  • only allow the authorizer block and forego scoping entirely
  • try to extract the original order information from clap (to mix --block-file and --block)
  • only allow using files to trivially keep the block definition order

For third-party blocks:

  • forego third-party blocks entirely
  • use a specific comment in datalog to extract the private key from the block source before parsing it
  • use position-aware parsing of options to pass a --sign-with / --sign-with-file option after the --block-file / --block option

Using position-aware options seems possible in clap, but I'm not keen on doing that. The two options that i like best for now are:

  • no blocks, only zuul the authorizer
  • only block files + a magic comment at the top of the file containing the private key

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