feat: record access decisions, not just denials
- add an outcome column and migration so allowed and denied decisions share one audit trail - fail closed when an allowed decision cannot be recorded - expose outcome filtering in the API and dashboard Route chat through the recording authorizer so its decisions are audited too.
This commit is contained in:
17 files changed
+291
-98
No files matched your search
@@ -9,6 +9,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
@@ -21,6 +22,7 @@ const { denials, filters, more, loading, error } = storeToRefs(store);
|
||||
const columns: DataTableColumn<Denial>[] = [
|
||||
{ id: "at", label: "When", fixed: true, width: "9rem", sort: (d) => d.at },
|
||||
{ id: "principal", label: "Principal", fixed: true, width: "auto", class: "whitespace-normal" },
|
||||
{ id: "outcome", label: "Outcome", width: "7rem" },
|
||||
{ id: "action", label: "Action", width: "12rem" },
|
||||
{ id: "resource", label: "Resource", width: "14rem", class: "whitespace-normal" },
|
||||
{ id: "level", label: "Level", width: "6rem" },
|
||||
@@ -33,7 +35,7 @@ onMounted(() => void store.load());
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader title="Denials">
|
||||
<PageHeader title="Access decisions">
|
||||
<Button variant="outline" size="sm" :disabled="loading" @click="store.load()">Refresh</Button>
|
||||
</PageHeader>
|
||||
|
||||
@@ -44,6 +46,14 @@ onMounted(() => void store.load());
|
||||
<Input v-model="filters.principal" class="w-48" aria-label="Principal" placeholder="Principal" />
|
||||
<Input v-model="filters.action" class="w-36" aria-label="Action" placeholder="Action" />
|
||||
<Input v-model="filters.kind" class="w-36" aria-label="Resource kind" placeholder="Resource kind" />
|
||||
<Select v-model="filters.outcome">
|
||||
<SelectTrigger class="w-32" aria-label="Outcome"><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="any">Any outcome</SelectItem>
|
||||
<SelectItem value="allowed">Allowed</SelectItem>
|
||||
<SelectItem value="denied">Denied</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Input v-model="filters.since" type="datetime-local" class="w-52" aria-label="From" />
|
||||
<Input v-model="filters.until" type="datetime-local" class="w-52" aria-label="Until" />
|
||||
<Button type="submit" size="sm" :disabled="loading">Filter</Button>
|
||||
@@ -51,22 +61,25 @@ onMounted(() => void store.load());
|
||||
</form>
|
||||
<div class="flex flex-col gap-3">
|
||||
<p v-if="loading && !denials.length" class="flex items-center gap-2 text-label text-fg-muted">
|
||||
<Spinner />Loading denials…
|
||||
<Spinner />Loading decisions…
|
||||
</p>
|
||||
<Empty v-else-if="!error && !denials.length">
|
||||
<EmptyHeader><EmptyTitle>No denials recorded</EmptyTitle></EmptyHeader>
|
||||
<EmptyHeader><EmptyTitle>No decisions recorded</EmptyTitle></EmptyHeader>
|
||||
</Empty>
|
||||
<DataTable
|
||||
v-else-if="!error || denials.length"
|
||||
:columns="columns"
|
||||
:rows="denials"
|
||||
:row-key="(d) => `${d.at}:${d.principal}:${d.action}:${d.kind}:${d.resource}`"
|
||||
:row-key="(d) => `${d.at}:${d.principal}:${d.action}:${d.kind}:${d.resource}:${d.outcome}`"
|
||||
storage-key="denials"
|
||||
>
|
||||
<template #empty>
|
||||
<Empty><EmptyHeader><EmptyTitle>No denials recorded</EmptyTitle></EmptyHeader></Empty>
|
||||
<Empty><EmptyHeader><EmptyTitle>No decisions recorded</EmptyTitle></EmptyHeader></Empty>
|
||||
</template>
|
||||
<template #cell-at="{ row }"><Timestamp :at="row.at" /></template>
|
||||
<template #cell-outcome="{ row }">
|
||||
<Badge :variant="row.outcome === 'allowed' ? 'ok' : 'danger'">{{ row.outcome === "allowed" ? "Allowed" : "Denied" }}</Badge>
|
||||
</template>
|
||||
<template #cell-action="{ row }"><span class="font-mono text-caption">{{ row.action }}</span></template>
|
||||
<template #cell-principal="{ row }"><span class="font-mono text-caption">{{ row.principal }}</span></template>
|
||||
<template #cell-resource="{ row }"><span class="font-mono text-caption">{{ denialResource(row) }}</span></template>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/** Access denials as the dashboard reads them from /api/access/denials:
|
||||
* one recorded refusal, coalesced per minute into a count. */
|
||||
/** Access decisions as the dashboard reads them from /api/access/denials:
|
||||
* one recorded outcome, coalesced per minute into a count. */
|
||||
export interface Denial {
|
||||
principal: string;
|
||||
org: string;
|
||||
action: string;
|
||||
kind: string;
|
||||
resource: string;
|
||||
outcome: "allowed" | "denied";
|
||||
level: string;
|
||||
policies: string[];
|
||||
at: string;
|
||||
@@ -14,7 +15,7 @@ export interface Denial {
|
||||
|
||||
export interface DenialsResponse {
|
||||
denials: Denial[];
|
||||
/** Whether older refusals match beyond this page. */
|
||||
/** Whether older decisions match beyond this page. */
|
||||
more: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const stores = {
|
||||
denials: {
|
||||
unavailable: "Denial records are unavailable.",
|
||||
unavailable: "Decision records are unavailable.",
|
||||
},
|
||||
settings: {
|
||||
conflict: "Changed elsewhere. Latest values loaded.",
|
||||
|
||||
@@ -285,9 +285,9 @@ export const routes: RouteRecordRaw[] = [
|
||||
component: DenialsPage,
|
||||
meta: {
|
||||
section: "org_denials",
|
||||
label: "Denials",
|
||||
label: "Access decisions",
|
||||
navPath: "/org",
|
||||
description: "Access requests the policy chain refused, newest first.",
|
||||
description: "Access requests the policy chain allowed or refused, newest first.",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -13,15 +13,17 @@ export interface DenialFilters {
|
||||
principal: string;
|
||||
action: string;
|
||||
kind: string;
|
||||
/** "any", or one outcome the server records. */
|
||||
outcome: string;
|
||||
since: string;
|
||||
until: string;
|
||||
}
|
||||
|
||||
const noFilters = (): DenialFilters => ({ principal: "", action: "", kind: "", since: "", until: "" });
|
||||
const noFilters = (): DenialFilters => ({ principal: "", action: "", kind: "", outcome: "any", since: "", until: "" });
|
||||
|
||||
const toISO = (local: string): string => (local ? new Date(local).toISOString() : "");
|
||||
|
||||
/** The caller's org's recorded access denials, newest first, a page at a time. */
|
||||
/** The caller's org's recorded access decisions, newest first, a page at a time. */
|
||||
export const useDenialsStore = defineStore("denials", () => {
|
||||
const denials = ref<Denial[]>([]);
|
||||
const filters = reactive<DenialFilters>(noFilters());
|
||||
@@ -40,6 +42,7 @@ export const useDenialsStore = defineStore("denials", () => {
|
||||
principal: filters.principal.trim(),
|
||||
action: filters.action.trim(),
|
||||
kind: filters.kind.trim(),
|
||||
outcome: filters.outcome === "any" ? "" : filters.outcome,
|
||||
since: toISO(filters.since),
|
||||
until: toISO(filters.until),
|
||||
limit: PAGE,
|
||||
|
||||
Reference in new issue
Block a user