Track reasons why things fail
Description
See: #16
This implements the automatic discovery of failure reasons in a structured result format, with the introduction of a new Policy#explain
method.
Calling explain
returns the policy result, as well a list of things that prevented the policy.
No effort is made to render these reasons into human readable text, or to provide reason aliases/messages - such things would be future work.
While this is a significant piece of new functionality, the core API remains backwards compatible, and reasons are strictly opt-in.
Prior art: other authorization frameworks allow automatic failure reason discovery - ActionPolicy
is a good example of this.
Related Issues
See: #16
Suggested version bump
-
Major (backwards incompatible changes) -
Minor (backwards compatible changes) -
Patch (API compatible changes)
Checklist
-
Tests have been added or updated to cover any changes in behavior -
This does not change the API to consume this library, or a suggested version bump has been provided -
The CHANGELOG.md
has been updated -
No new runtime dependencies have been introduced
Edited by Alex Kalderimis