Adds automatic execution of obligation handlers after permit decisions:
-
New
Guard.register_obligation_handler(type, handler)API for registering sync or async callbacks -
Handlers are invoked automatically for permit decisions, in obligation order
-
ObligationNotMetErrornow flips the decision todenywithreason="obligation_failed" -
Optional
challengeis propagated toDecision.challenge -
Any other exception is logged and also fails closed
-
First failing handler short-circuits remaining handlers
-
Conditional obligations are respected:
- handler is skipped when the obligation condition evaluates to
False
- handler is skipped when the obligation condition evaluates to
-
Unregistered obligation types remain in
Decision.obligationsfor manual handling -
Registering a handler for an existing type replaces the previous one
New public exception
-
rbacx.core.engine.ObligationNotMetError- raised by obligation handlers to signal that an obligation was not met
- accepts optional
challenge=keyword argument
No breaking changes
Upgrade
pip install -U rbacx