biscuit-auth / biscuit-rust

Rust implementation of the Biscuit authorization token
https://www.biscuitsec.org
209 stars 29 forks source link

Merging block builders with scope annotations #196

Open divarvel opened 11 months ago

divarvel commented 11 months ago

Blocks can start with a trusting annotation that will apply to all the rule bodies with no trusting annotation.

trusting authority, <public_key>;
check if fact(true); // equivalent to `check if fact(true) trusting authority, <public key>;`

What should happen when merging trusting authority; check if fact(true); into trusting <public key>; check if fact(false); or check if fact(true); into trusting <public key>; check if fact(false); ?

i see several possibilities:

  1. ignore the trusting annotation of the second block (current behaviour)
  2. modify the rules with no scope annotations of the second block to inject the scope annotations before adding them to the first block
    • if the second block does not have a scope annotation, then don't do anything (rules will then default to the scope annotation of the first block)
    • if the second block does not have a scope annotation, then inject the default trusted scopes in rules (rules will then not default to the scope annotation of the first block)
  3. if the second block has a scope annotation, raise an error (this would require modifying the signature of BlockBuilder.merge()