Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

biscuit v2 #19

Merged
merged 39 commits into from
Oct 6, 2021
Merged

biscuit v2 #19

merged 39 commits into from
Oct 6, 2021

Conversation

divarvel
Copy link
Collaborator

@divarvel divarvel commented Sep 1, 2021

biscuit-auth/biscuit#72

ToDo

  • serialization
  • new crypto
  • scoped evaluation
  • symbols removal
  • post-update cleanup

According to the biscuit v2 _feuille de route_, the datalog is now
evaluated in a staged process: each block is ran in sequence, with
its checks. This way, a new block cannot generate new facts that
could interfere with previous blocks rules and checks.

In effects, this makes `#authority` and `#ambient` flagging
automatic, and generalized to every block, not just the authority.
`validateBiscuit` and friends don't care at all about the proof type
since it has already been validated.

`serializeBiscuit` and friends already know how to handle both open
and sealed tokens, it was just a matter of automatically projecting
Open and Sealed tokens to the main case, with a little typeclass.

This allows to remove most of the `fromOpen` / `fromSealed` uses.
`Biscuit'` and `BiscuitProof` where not exposed and prevented external
libs from exposing polymorphic helpers.
The three layers of type aliases were hard to follow and did a
poor job of hiding the doubly-primed base types.
The benefits are two fold:

- when multiple public keys are available (and chosen through `rootKeyId`),
  it allows keeping track of which one was used
- the `check` type param in `Biscuit` is no longer a phantom type, and proper
  types are used, instead of promoted constructors. This removes the need for
  `DataKinds` and ticked types in user code.
This will allow lib users to query a verified biscuit to extract
information

Todo: add tests to make sure relevant facts are there
- improved wording
- additional explanation paragraphs
- fixed code examples
- reordered exports
The haskell lib was not computing the signature the way the spec
and the rust impl did.
this will pave the way for accepting different signature algorithms
The spec mandates url-compatible b64, hex was only there for internal
debugging purposes
Revocation ids are block signatures, which are available in the
outermost protobuf encoding. This allows to skip the whole parsing
altogether for already revoked biscuits
It can work on any biscuit, regardless of its proof type or
verification status
There were already `fromSealed` and `toSealed` to generalize
biscuits to `OpenOrSealed`. The new helpers do the opposite operation:
from an `OpenOrSealed` biscuit, they try to specialize it to
`Open` or `Sealed`.
The computation itself does not care about whether the biscuit
was checked or not, but the exposed helpers are monomorphic, to
avoid unknowingly consume an unchecked biscuit.
Namely:

 - `seal`
 - `sealUnchecked`
 - `addBlockUnchecked`

This required removing the open import for the `Crypto` module
It used to take a backwards list (authority at the end) to make
test code easier to implement. The test code `Token` (and friends)
was moved to a test module, and `verifyBlocks` now has a more
predictable behaviour.
This is more in line with the vocabulary around signature verification
@divarvel divarvel merged commit b5d25f4 into main Oct 6, 2021
@divarvel divarvel deleted the secret-project branch October 6, 2021 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant