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:
1 parent
fbe9cc9262
commit
68e564eb6c
4 files changed
+180
-61
No files matched your search
@@ -10,22 +10,31 @@ interface Props {
|
||||
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) {
|
||||
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 entries = accessForPath(data.data.identities, data.data.policies, path, pathMatches)
|
||||
|
||||
return (
|
||||
<section aria-label="Access">
|
||||
<h2>Access to {secret}</h2>
|
||||
<p>
|
||||
Evaluated against <code>{path}</code>
|
||||
</p>
|
||||
{data.data.notes.map((n) => (
|
||||
<section aria-label="Access" className="secret-detail">
|
||||
<header>
|
||||
<h2>{secret}</h2>
|
||||
<code>{path}</code>
|
||||
</header>
|
||||
{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">
|
||||
Incomplete: could not read {n}
|
||||
</p>
|
||||
@@ -33,22 +42,38 @@ export function AccessPanel({ client, mount, secret }: Props) {
|
||||
{entries.length === 0 ? (
|
||||
<p>No identity can reach this secret.</p>
|
||||
) : (
|
||||
<table>
|
||||
<table aria-label="Who can access this secret">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Identity</th>
|
||||
<th>Type</th>
|
||||
<th>Via policy</th>
|
||||
<th>Capabilities</th>
|
||||
<th>Can</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{entries.map((e) => (
|
||||
<tr key={`${e.identity.kind}:${e.identity.name}:${e.policy}`}>
|
||||
<td>{e.identity.name}</td>
|
||||
<td>{e.identity.kind}</td>
|
||||
<td>{e.policy}</td>
|
||||
<td>{e.capabilities.join(', ')}</td>
|
||||
<td>
|
||||
<span>{e.identity.name}</span> <span className="tag">{e.identity.kind}</span>
|
||||
</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>
|
||||
))}
|
||||
</tbody>
|
||||
@@ -57,6 +82,6 @@ export function AccessPanel({ client, mount, secret }: Props) {
|
||||
<p className="hint">
|
||||
Only the most specific matching policy path applies, as in OpenBao. Parameter constraints and templated paths are approximated.
|
||||
</p>
|
||||
</section>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -66,7 +66,8 @@ test('navigates folders and shows who can reach a secret', async () => {
|
||||
const panel = await screen.findByRole('region', { name: 'Access' })
|
||||
const row = (await within(panel).findByText('alice')).closest('tr')!
|
||||
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).getByText('secret/data/app/db')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
@@ -28,50 +28,62 @@ function Browser({ client }: { client: BaoClient }) {
|
||||
if (mounts.isPending) return <p>Loading…</p>
|
||||
if (!mount) return <p>No KV v2 secrets engines are mounted.</p>
|
||||
|
||||
const where = prefix ? `${mount}${prefix}` : mount
|
||||
|
||||
return (
|
||||
<>
|
||||
<label>
|
||||
Mount
|
||||
<select
|
||||
value={mount}
|
||||
onChange={(e) => {
|
||||
setMount(e.target.value)
|
||||
go('')
|
||||
}}
|
||||
>
|
||||
{mounts.data.map((m) => (
|
||||
<option key={m.path}>{m.path}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<nav aria-label="Path" className="crumbs">
|
||||
<button type="button" onClick={() => go('')}>
|
||||
{mount}
|
||||
</button>
|
||||
{crumbs.map((c, i) => (
|
||||
<button key={i} type="button" onClick={() => go(crumbs.slice(0, i + 1).join('/') + '/')}>
|
||||
{c}/
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
{entries.error && <p role="alert">{entries.error.message}</p>}
|
||||
{entries.data?.length === 0 && <p>Nothing here.</p>}
|
||||
<ul className="entries">
|
||||
{entries.data?.map((e) => (
|
||||
<li key={e.path}>
|
||||
<button
|
||||
type="button"
|
||||
aria-pressed={selected === e.path}
|
||||
onClick={() => (e.isFolder ? go(e.path) : setSelected(e.path))}
|
||||
<div className="secrets-layout">
|
||||
<div className="secrets-browser">
|
||||
<nav aria-label="Path" className="crumbs">
|
||||
{mounts.data.length > 1 && (
|
||||
<select
|
||||
aria-label="Mount"
|
||||
value={mount}
|
||||
onChange={(e) => {
|
||||
setMount(e.target.value)
|
||||
go('')
|
||||
}}
|
||||
>
|
||||
{e.isFolder ? '📁 ' : '🔑 '}
|
||||
{e.name}
|
||||
{mounts.data.map((m) => (
|
||||
<option key={m.path}>{m.path}</option>
|
||||
))}
|
||||
</select>
|
||||
)}
|
||||
<button type="button" onClick={() => go('')}>
|
||||
{mount}
|
||||
</button>
|
||||
{crumbs.map((c, i) => (
|
||||
<button key={i} type="button" onClick={() => go(crumbs.slice(0, i + 1).join('/') + '/')}>
|
||||
{c}/
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{selected && <AccessPanel client={client} mount={mount} secret={selected} />}
|
||||
</>
|
||||
))}
|
||||
</nav>
|
||||
{entries.isPending && <p className="hint">Loading…</p>}
|
||||
{entries.error && <p role="alert">{entries.error.message}</p>}
|
||||
{entries.data?.length === 0 && <p className="hint">No secrets in {where} yet.</p>}
|
||||
{!!entries.data?.length && (
|
||||
<ul className="entries" aria-label={`Contents of ${where}`}>
|
||||
{entries.data.map((e) => (
|
||||
<li key={e.path}>
|
||||
<button
|
||||
type="button"
|
||||
className={e.isFolder ? 'entry-folder' : undefined}
|
||||
aria-pressed={e.isFolder ? undefined : selected === e.path}
|
||||
onClick={() => (e.isFolder ? go(e.path) : setSelected(e.path))}
|
||||
>
|
||||
{e.name}
|
||||
{e.isFolder && <span aria-hidden="true">›</span>}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
{selected ? (
|
||||
<AccessPanel client={client} mount={mount} secret={selected} />
|
||||
) : (
|
||||
<p className="secret-placeholder">Select a secret to see who can reach it.</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -870,3 +870,84 @@ button.link:hover:not(:disabled) {
|
||||
background: none;
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user