feat(access): denial retention knob, State Store sweep and dashboard denials page (#1842)
Add [access].denial_retention (default 90 days, matching the audit-retention seed) wired through config defaults and validation; the State Store sweeps denial records older than the configured age hourly via the new access.DenialPruner / PruneDenials store query. The dashboard gains GET /api/access/denials (read_audit-gated, so org admins/owners see their org's records; the store scopes by the credential's org) and an /org/denials page backed by a Pinia store.
This commit is contained in:
1 parent
f7926cde15
commit
003771ca48
28 files changed
+625
-116
No files matched your search
@@ -0,0 +1,73 @@
|
||||
<script setup lang="ts">
|
||||
import { storeToRefs } from "pinia";
|
||||
import { onMounted } from "vue";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { useDenialsStore } from "@/stores/denials";
|
||||
import { denialResource, type Denial } from "./denials";
|
||||
|
||||
const store = useDenialsStore();
|
||||
const { denials, loading, error } = storeToRefs(store);
|
||||
|
||||
const columns: DataTableColumn<Denial>[] = [
|
||||
{ id: "at", label: "When", fixed: true, sort: (d) => d.at },
|
||||
{ id: "principal", label: "Principal", fixed: true, class: "whitespace-normal" },
|
||||
{ id: "action", label: "Action" },
|
||||
{ id: "resource", label: "Resource", class: "whitespace-normal" },
|
||||
{ id: "level", label: "Level" },
|
||||
{ id: "policies", label: "Deciding policies", class: "hidden md:table-cell whitespace-normal" },
|
||||
{ id: "count", label: "Count", sort: (d) => d.count },
|
||||
];
|
||||
|
||||
onMounted(() => void store.load());
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader title="Denials">
|
||||
<Button variant="outline" size="sm" :disabled="loading" @click="store.load()">Refresh</Button>
|
||||
</PageHeader>
|
||||
|
||||
<div v-if="error" role="alert" class="mb-4 text-sm text-danger">
|
||||
<p>{{ error }}</p>
|
||||
<Button variant="outline" size="sm" @click="store.load()">Retry</Button>
|
||||
</div>
|
||||
|
||||
<Section>
|
||||
<div class="flex flex-col gap-3">
|
||||
<p v-if="loading && !denials.length" class="flex items-center gap-2 text-sm text-fg-muted">
|
||||
<Spinner />Loading denials…
|
||||
</p>
|
||||
<Empty v-else-if="!error && !denials.length">
|
||||
<EmptyHeader><EmptyTitle>No denials recorded</EmptyTitle></EmptyHeader>
|
||||
</Empty>
|
||||
<DataTable
|
||||
v-else
|
||||
:columns="columns"
|
||||
:rows="denials"
|
||||
:row-key="(d) => `${d.at}:${d.principal}:${d.action}:${d.kind}:${d.resource}`"
|
||||
storage-key="denials"
|
||||
>
|
||||
<template #empty>
|
||||
<Empty><EmptyHeader><EmptyTitle>No denials recorded</EmptyTitle></EmptyHeader></Empty>
|
||||
</template>
|
||||
<template #cell-at="{ row }"><Timestamp :at="row.at" /></template>
|
||||
<template #cell-principal="{ row }"><span class="font-mono text-xs">{{ row.principal }}</span></template>
|
||||
<template #cell-resource="{ row }"><span class="font-mono text-xs">{{ denialResource(row) }}</span></template>
|
||||
<template #cell-level="{ row }"><Badge variant="idle">{{ row.level }}</Badge></template>
|
||||
<template #cell-policies="{ row }">
|
||||
<span class="font-mono text-xs text-fg-muted">{{ row.policies.join(", ") || "–" }}</span>
|
||||
</template>
|
||||
<template #cell-count="{ row }"><span class="tabular-nums">{{ row.count }}</span></template>
|
||||
</DataTable>
|
||||
</div>
|
||||
</Section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,22 @@
|
||||
/** Access denials as the dashboard reads them from /api/access/denials:
|
||||
* one recorded refusal, coalesced per minute into a count. */
|
||||
export interface Denial {
|
||||
principal: string;
|
||||
org: string;
|
||||
action: string;
|
||||
kind: string;
|
||||
resource: string;
|
||||
level: string;
|
||||
policies: string[];
|
||||
at: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface DenialsResponse {
|
||||
denials: Denial[];
|
||||
}
|
||||
|
||||
/** The resource column: the kind and id together, or just the kind. */
|
||||
export function denialResource(d: Denial): string {
|
||||
return d.resource ? `${d.kind}/${d.resource}` : d.kind;
|
||||
}
|
||||
@@ -175,6 +175,8 @@ export const api = {
|
||||
health: <T = unknown>() => request<T>("/health/detailed"),
|
||||
services: <T = unknown>() => request<T>("/api/services"),
|
||||
policies: <T = unknown>() => request<T>("/api/access/policies"),
|
||||
denials: <T = unknown>(limit?: number) =>
|
||||
request<T>(`/api/access/denials${limit ? `?limit=${limit}` : ""}`),
|
||||
putPolicy: (policy: unknown) =>
|
||||
request<{ version: number }>("/api/access/policies", { method: "PUT", body: policy }),
|
||||
deletePolicy: (policy: unknown) =>
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ const orgSpecs: NavSpec[] = [
|
||||
sections: [
|
||||
{
|
||||
label: "People & access",
|
||||
paths: ["/org/members", "/org/agents", "/org/workspaces", "/org/policies", "/org/audit"],
|
||||
paths: ["/org/members", "/org/agents", "/org/workspaces", "/org/policies", "/org/denials", "/org/audit"],
|
||||
},
|
||||
{
|
||||
label: "Connections & models",
|
||||
|
||||
@@ -6,6 +6,7 @@ import DashboardPage from "@/dashboard/DashboardPage.vue";
|
||||
import EventsPage from "@/events/EventsPage.vue";
|
||||
import LogsPage from "@/logs/LogsPage.vue";
|
||||
import AuditPage from "@/audit/AuditPage.vue";
|
||||
import DenialsPage from "@/audit/DenialsPage.vue";
|
||||
import OrgShell from "@/org/OrgShell.vue";
|
||||
import OrgOverviewPage from "@/org/OrgOverviewPage.vue";
|
||||
import OrgMembersPage from "@/org/OrgMembersPage.vue";
|
||||
@@ -216,6 +217,17 @@ const routes = [
|
||||
description: "Settings, access, identity and runtime events.",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "denials",
|
||||
name: "org-denials",
|
||||
component: DenialsPage,
|
||||
meta: {
|
||||
section: "org_denials",
|
||||
label: "Denials",
|
||||
navPath: "/org",
|
||||
description: "Access requests the policy chain refused, newest first.",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "workspaces",
|
||||
name: "org-workspaces",
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
|
||||
import type { Denial, DenialsResponse } from "@/audit/denials";
|
||||
import { ApiError, api } from "@/lib/api";
|
||||
|
||||
/** The caller's org's recorded access denials, newest first. */
|
||||
export const useDenialsStore = defineStore("denials", () => {
|
||||
const denials = ref<Denial[]>([]);
|
||||
const loading = ref(false);
|
||||
const error = ref("");
|
||||
|
||||
async function load(): Promise<void> {
|
||||
loading.value = true;
|
||||
try {
|
||||
denials.value = (await api.denials<DenialsResponse>()).denials ?? [];
|
||||
error.value = "";
|
||||
} catch (err) {
|
||||
if (err instanceof ApiError && err.status === 503) {
|
||||
error.value = "Denial records are unavailable.";
|
||||
} else {
|
||||
error.value = err instanceof Error && err.message ? err.message : String(err);
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
return { denials, loading, error, load };
|
||||
});
|
||||
Reference in new issue
Block a user