Skip to main content

Decision explainer

A panel that answers "why was this refused?" with the rule that decided and the next step.

PatternReadyView source
Works with
Reactshadcn/ui
Runs on sample data, with the neutral theme of shadcn/ui.

Identity systems refuse often. This panel turns a refusal into something that a developer or an administrator can act on: the question, the reason, what decided, and the next step.

Installation​

The command adds the file to your project, with the shadcn/ui components that it uses. Your project needs shadcn/ui.

pnpm dlx shadcn@latest add https://examples.lumoauth.dev/r/decision-explainer.json

Usage​

fromAskResult maps the answer of the Ask API. Add the next steps that make sense in your app.

components/refusal.tsx
import { DecisionExplainer, fromAskResult } from '@/components/decision-explainer';

export function Refusal({ agentName, answer, onAskApproval }: { agentName: string; answer: any; onAskApproval: () => void }) {
return (
<DecisionExplainer
decision={fromAskResult(agentName, answer)}
nextSteps={answer.decided_by === 'deny_override' ? [] : [{ label: 'Ask for approval', onClick: onAskApproval }]}
/>
);
}

Offer no approval for a deny rule: a deny rule wins over every grant, so an approval cannot lift it.

Where the data comes from​

What the pattern showsCall
A decision for an agentagent.ask(action, context): allowed, reason, decided_by, audit_id
A decision for a personlumo.permissions.checkDetailed()
The audit recordAdmin API, audit logs

States​

Runs on sample data, with the neutral theme of shadcn/ui.
  • Allowed.
  • Refused by a policy.
  • Refused by a deny rule, with the audit ID.

Props​

PropTypeDescription
decisionrequiredDecisionDataThe decision.
nextSteps{ label: string; onClick?: () => void; href?: string }[]What the reader can do next. A step with href is a link, the others are buttons.
classNamestringClass name for the panel.

DecisionData​

OptionTypeDescription
allowedrequiredbooleanThe answer.
subjectrequiredstringWho asked: the name of the agent or of the person.
actionrequiredstringThe action that was asked about.
resourcestring | nullThe resource, when the question named one.
reasonstring | nullThe reason that LumoAuth gave.
decidedBy'capability' | 'pdp' | 'deny_override'What decided: a capability of the agent, a policy, or a deny rule.
auditIdstring | nullThe ID of the audit record.