Rework Secrets page into browser and detail panes

- Two panes: folder browser on the left, access detail card on the right, so
  selecting a secret no longer shifts the page. Stacks on narrow screens.
- Mount is the first crumb; the mount dropdown only shows with several engines.
- Drop emoji for chevrons; capability chips, red for delete/sudo; identity type
  tags; root token collapsed to "full access".

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
mattandClaude Sonnet 5.5 committed 2026-10-20 12:10:58 +01:00
1 parent fbe9cc9262
commit 68e564eb6c
4 files changed
+151 -32

No files matched your search

+44 -19
View File
@@ -10,22 +10,31 @@ interface Props {
secret: string secret: string
} }
// Capabilities that let someone change or remove the secret, or bypass policy checks.
const RISKY = new Set(['delete', 'sudo'])
export function AccessPanel({ client, mount, secret }: Props) { export function AccessPanel({ client, mount, secret }: Props) {
const data = useAccessInputs(client) const data = useAccessInputs(client)
if (data.isPending) return <p>Loading access…</p>
if (data.error) return <p role="alert">Could not load access: {data.error.message}</p>
const path = dataPath(mount, secret) const path = dataPath(mount, secret)
const entries = accessForPath(data.data.identities, data.data.policies, path, pathMatches)
return ( return (
<section aria-label="Access"> <section aria-label="Access" className="secret-detail">
<h2>Access to {secret}</h2> <header>
<p> <h2>{secret}</h2>
Evaluated against <code>{path}</code> <code>{path}</code>
</p> </header>
{data.data.notes.map((n) => ( {data.isPending && <p className="hint">Loading access…</p>}
{data.error && <p role="alert">Could not load access: {data.error.message}</p>}
{data.data && <Entries data={data.data} path={path} />}
</section>
)
}
function Entries({ data, path }: { data: NonNullable<ReturnType<typeof useAccessInputs>['data']>; path: string }) {
const entries = accessForPath(data.identities, data.policies, path, pathMatches)
return (
<>
{data.notes.map((n) => (
<p key={n} role="alert"> <p key={n} role="alert">
Incomplete: could not read {n} Incomplete: could not read {n}
</p> </p>
@@ -33,22 +42,38 @@ export function AccessPanel({ client, mount, secret }: Props) {
{entries.length === 0 ? ( {entries.length === 0 ? (
<p>No identity can reach this secret.</p> <p>No identity can reach this secret.</p>
) : ( ) : (
<table> <table aria-label="Who can access this secret">
<thead> <thead>
<tr> <tr>
<th>Identity</th> <th>Identity</th>
<th>Type</th>
<th>Via policy</th> <th>Via policy</th>
<th>Capabilities</th> <th>Can</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{entries.map((e) => ( {entries.map((e) => (
<tr key={`${e.identity.kind}:${e.identity.name}:${e.policy}`}> <tr key={`${e.identity.kind}:${e.identity.name}:${e.policy}`}>
<td>{e.identity.name}</td> <td>
<td>{e.identity.kind}</td> <span>{e.identity.name}</span> <span className="tag">{e.identity.kind}</span>
<td>{e.policy}</td> </td>
<td>{e.capabilities.join(', ')}</td> <td>
<code>{e.policy}</code>
</td>
<td>
{e.policy === 'root' ? (
<ul className="chips">
<li className="risky">full access</li>
</ul>
) : (
<ul className="chips">
{e.capabilities.map((c) => (
<li key={c} className={RISKY.has(c) ? 'risky' : undefined}>
{c}
</li>
))}
</ul>
)}
</td>
</tr> </tr>
))} ))}
</tbody> </tbody>
@@ -57,6 +82,6 @@ export function AccessPanel({ client, mount, secret }: Props) {
<p className="hint"> <p className="hint">
Only the most specific matching policy path applies, as in OpenBao. Parameter constraints and templated paths are approximated. Only the most specific matching policy path applies, as in OpenBao. Parameter constraints and templated paths are approximated.
</p> </p>
</section> </>
) )
} }
+2 -1
View File
@@ -66,7 +66,8 @@ test('navigates folders and shows who can reach a secret', async () => {
const panel = await screen.findByRole('region', { name: 'Access' }) const panel = await screen.findByRole('region', { name: 'Access' })
const row = (await within(panel).findByText('alice')).closest('tr')! const row = (await within(panel).findByText('alice')).closest('tr')!
expect(within(row).getByText('app-rw')).toBeInTheDocument() expect(within(row).getByText('app-rw')).toBeInTheDocument()
expect(within(row).getByText('read, update')).toBeInTheDocument() expect(within(row).getByText('read')).toBeInTheDocument()
expect(within(row).getByText('update')).toBeInTheDocument()
expect(within(panel).queryByText('bob')).not.toBeInTheDocument() expect(within(panel).queryByText('bob')).not.toBeInTheDocument()
expect(within(panel).getByText('secret/data/app/db')).toBeInTheDocument() expect(within(panel).getByText('secret/data/app/db')).toBeInTheDocument()
}) })
+24 -12
View File
@@ -28,11 +28,15 @@ function Browser({ client }: { client: BaoClient }) {
if (mounts.isPending) return <p>Loading…</p> if (mounts.isPending) return <p>Loading…</p>
if (!mount) return <p>No KV v2 secrets engines are mounted.</p> if (!mount) return <p>No KV v2 secrets engines are mounted.</p>
const where = prefix ? `${mount}${prefix}` : mount
return ( return (
<> <div className="secrets-layout">
<label> <div className="secrets-browser">
Mount <nav aria-label="Path" className="crumbs">
{mounts.data.length > 1 && (
<select <select
aria-label="Mount"
value={mount} value={mount}
onChange={(e) => { onChange={(e) => {
setMount(e.target.value) setMount(e.target.value)
@@ -43,8 +47,7 @@ function Browser({ client }: { client: BaoClient }) {
<option key={m.path}>{m.path}</option> <option key={m.path}>{m.path}</option>
))} ))}
</select> </select>
</label> )}
<nav aria-label="Path" className="crumbs">
<button type="button" onClick={() => go('')}> <button type="button" onClick={() => go('')}>
{mount} {mount}
</button> </button>
@@ -54,24 +57,33 @@ function Browser({ client }: { client: BaoClient }) {
</button> </button>
))} ))}
</nav> </nav>
{entries.isPending && <p className="hint">Loading…</p>}
{entries.error && <p role="alert">{entries.error.message}</p>} {entries.error && <p role="alert">{entries.error.message}</p>}
{entries.data?.length === 0 && <p>Nothing here.</p>} {entries.data?.length === 0 && <p className="hint">No secrets in {where} yet.</p>}
<ul className="entries"> {!!entries.data?.length && (
{entries.data?.map((e) => ( <ul className="entries" aria-label={`Contents of ${where}`}>
{entries.data.map((e) => (
<li key={e.path}> <li key={e.path}>
<button <button
type="button" type="button"
aria-pressed={selected === e.path} className={e.isFolder ? 'entry-folder' : undefined}
aria-pressed={e.isFolder ? undefined : selected === e.path}
onClick={() => (e.isFolder ? go(e.path) : setSelected(e.path))} onClick={() => (e.isFolder ? go(e.path) : setSelected(e.path))}
> >
{e.isFolder ? '📁 ' : '🔑 '}
{e.name} {e.name}
{e.isFolder && <span aria-hidden="true">›</span>}
</button> </button>
</li> </li>
))} ))}
</ul> </ul>
{selected && <AccessPanel client={client} mount={mount} secret={selected} />} )}
</> </div>
{selected ? (
<AccessPanel client={client} mount={mount} secret={selected} />
) : (
<p className="secret-placeholder">Select a secret to see who can reach it.</p>
)}
</div>
) )
} }
+81
View File
@@ -870,3 +870,84 @@ button.link:hover:not(:disabled) {
background: none; background: none;
filter: brightness(1.15); filter: brightness(1.15);
} }
/* ---------- Secrets page ---------- */
.secrets-layout {
display: grid;
grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr);
gap: var(--s5);
align-items: start;
}
.secrets-browser .crumbs {
margin-top: 0;
}
.secrets-browser .crumbs select {
min-width: 0;
}
.secrets-browser .entries {
max-height: 70vh;
overflow-y: auto;
}
.secret-detail {
padding: var(--s5);
background: var(--surface);
border: 1px solid var(--line);
border-radius: var(--radius);
}
.secret-detail header {
display: grid;
gap: var(--s1);
margin-bottom: var(--s4);
}
.secret-detail h2 {
margin: 0;
font-family: var(--mono);
overflow-wrap: anywhere;
}
.secret-detail header code {
color: var(--ink-faint);
overflow-wrap: anywhere;
}
.secret-detail table {
margin-bottom: var(--s3);
}
.secret-placeholder {
margin: 0;
padding: var(--s6) var(--s5);
border: 1px dashed var(--line-strong);
border-radius: var(--radius);
color: var(--ink-faint);
text-align: center;
}
.tag {
padding: 0 var(--s2);
margin-left: var(--s1);
background: var(--surface-sunken);
border: 1px solid var(--line);
border-radius: 999px;
color: var(--ink-soft);
font-size: var(--text-sm);
}
/* Capabilities that change or remove data, or bypass policy checks. */
.chips li.risky {
background: var(--danger-soft);
color: var(--danger);
}
@media (max-width: 60rem) {
.secrets-layout {
grid-template-columns: minmax(0, 1fr);
}
}