-
Notifications
You must be signed in to change notification settings - Fork 7
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
Better verifier results #12
Better verifier results #12
Conversation
5f730d2
to
560b2f8
Compare
There are two things I'm not 100% sure of with the new
|
560b2f8
to
3a6aa52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an aside, and related to #1, I wonder if the proposed structure can accommodate attaching discharge macaroons to the result, and recursively verify all the macaroons.
I think it is feasible without the need for a complete refactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that OutstandingCaveat
should bear the hole caveat.
For first-party caveats this is equivalent to storing just the id, but for third-party it could be useful to group the non-discharged caveats by origin
We can leave 3rd party caveats for another PR I think |
This allows to get rid of an ill-defined monoid instance as well as providing more detailed information about the validation errors, while structurally eliminating impossible cases.
This lets the users use arbitrary monads (including `MonadIO` instances), but this also allows to use `Identity`. A `verifySync` helper is provided to have synchronous verification, freeing the user to use `Identity` themselves
8a66a16
to
87598f1
Compare
I've renamed I've tried to keep the new extensions to a minimum, this PR currently adds:
|
87598f1
to
7095680
Compare
I've thought a bit more about a monad tranformer and zippers, I don't have a clear view of what's going to be possible yet, so I'll keep to the current scope for this PR. I have a few ideas for both transformers and zippers, I can discuss them in relevant issues. |
I've opened issue #13 to sum up my ideas about zippers. |
@jtanguy so, what's left to do? |
I gave a shot at improving the verifiers API, as per #11
I'll try to split up changes in separated commits. There is one commit for imports cleanup, don't pay it too much attention.
ToDo:
ValidationError
monadIO
constraintFirst change: split up
ValidationError
into:VerifierResult
(for… well… verifier results).VerifierError
for caveats understood, but not dischargedValidationError
for macaroon validation errors (either an issue with the macaroon itself, or with caveats discharge. Caveat discharge errors are accumulated in aNonEmpty (Caveat, [VerifierError])
case, which allows to know which caveats failed and why.This allows to drop the
Monoid ValidationError
previously necessary for error accumulation. It was lossy, and some combinations didn't make sense (to the point that the first<>
implementation was partial). The caveats validation is now a bit cleaner (even though keeping the caveats around makes it more complex than it could be).Second change: relax the unused
MonadIO
constraint. This allows to have synchronous verification thanks toIdentity
(I've added a helper to make it even easier).Third change: introduce a monad transformer to encapsulate both the effects needed for verifier computation and for the verifier results (maybe through a
MonadError
constraint). I'm not convinced it's really necessary, as it would increase complexity a lot, while providing little benefit IMO (macaroon validation errors should be treated right away, not carried on in the context).