diff --git a/src/features/secrets/AccessPanel.tsx b/src/features/secrets/AccessPanel.tsx index d2dab8f..b0fe5fb 100644 --- a/src/features/secrets/AccessPanel.tsx +++ b/src/features/secrets/AccessPanel.tsx @@ -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

Loading access…

- if (data.error) return

Could not load access: {data.error.message}

- const path = dataPath(mount, secret) - const entries = accessForPath(data.data.identities, data.data.policies, path, pathMatches) return ( -
-

Access to {secret}

-

- Evaluated against {path} -

- {data.data.notes.map((n) => ( +
+
+

{secret}

+ {path} +
+ {data.isPending &&

Loading access…

} + {data.error &&

Could not load access: {data.error.message}

} + {data.data && } +
+ ) +} + +function Entries({ data, path }: { data: NonNullable['data']>; path: string }) { + const entries = accessForPath(data.identities, data.policies, path, pathMatches) + return ( + <> + {data.notes.map((n) => (

Incomplete: could not read {n}

@@ -33,22 +42,38 @@ export function AccessPanel({ client, mount, secret }: Props) { {entries.length === 0 ? (

No identity can reach this secret.

) : ( - +
- - + {entries.map((e) => ( - - - - + + + ))} @@ -57,6 +82,6 @@ export function AccessPanel({ client, mount, secret }: Props) {

Only the most specific matching policy path applies, as in OpenBao. Parameter constraints and templated paths are approximated.

- + ) } diff --git a/src/features/secrets/SecretsPage.test.tsx b/src/features/secrets/SecretsPage.test.tsx index 1008e5d..b6a86a4 100644 --- a/src/features/secrets/SecretsPage.test.tsx +++ b/src/features/secrets/SecretsPage.test.tsx @@ -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() }) diff --git a/src/features/secrets/SecretsPage.tsx b/src/features/secrets/SecretsPage.tsx index cef05c0..aa2cda2 100644 --- a/src/features/secrets/SecretsPage.tsx +++ b/src/features/secrets/SecretsPage.tsx @@ -28,50 +28,62 @@ function Browser({ client }: { client: BaoClient }) { if (mounts.isPending) return

Loading…

if (!mount) return

No KV v2 secrets engines are mounted.

+ const where = prefix ? `${mount}${prefix}` : mount + return ( - <> - - - {entries.error &&

{entries.error.message}

} - {entries.data?.length === 0 &&

Nothing here.

} - - {selected && } - + ))} + + {entries.isPending &&

Loading…

} + {entries.error &&

{entries.error.message}

} + {entries.data?.length === 0 &&

No secrets in {where} yet.

} + {!!entries.data?.length && ( +
    + {entries.data.map((e) => ( +
  • + +
  • + ))} +
+ )} + + {selected ? ( + + ) : ( +

Select a secret to see who can reach it.

+ )} + ) } diff --git a/src/index.css b/src/index.css index dab43ca..8ce28e2 100644 --- a/src/index.css +++ b/src/index.css @@ -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); + } +}
IdentityType Via policyCapabilitiesCan
{e.identity.name}{e.identity.kind}{e.policy}{e.capabilities.join(', ')} + {e.identity.name} {e.identity.kind} + + {e.policy} + + {e.policy === 'root' ? ( +
    +
  • full access
  • +
+ ) : ( +
    + {e.capabilities.map((c) => ( +
  • + {c} +
  • + ))} +
+ )} +