Polish pass: identity forms, confirm dialogs, policy chips, merged grants, narrow screens
- Tokens: bigger show-once token with primary Copy; warn when no policies are selected (OpenBao then inherits the creator's policies). - Identity forms get headings, wider cards and two-column policy lists. - Replace window.confirm with an in-app confirm dialog (falls back to window.confirm without a provider). - Show policies, aliases and members as chips in the identity tables. - Access panel: one row per secret instead of separate data/metadata rules. - Stack graph details below 60rem; phone-width rules for tables, nav, toolbar. - New favicon and page title; label the root "*" path as "everything". Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d67a9c9b62
commit
0a2054eb41
19 files changed
+551
-67
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { expect, test } from 'vitest'
|
||||
import { groupGrants } from './grantRows'
|
||||
|
||||
test('folds a KV data rule and its metadata rule into one row', () => {
|
||||
const rows = groupGrants(
|
||||
[
|
||||
{ path: 'secret/data/team-a/*', capabilities: ['read', 'update'] },
|
||||
{ path: 'secret/metadata/team-a/*', capabilities: ['list'] },
|
||||
],
|
||||
['secret/'],
|
||||
)
|
||||
expect(rows).toEqual([
|
||||
{
|
||||
display: 'secret/team-a/*',
|
||||
wildcard: true,
|
||||
capabilities: ['read', 'update', 'list'],
|
||||
paths: ['secret/data/team-a/*', 'secret/metadata/team-a/*'],
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
test('a secret with only a data rule is one row', () => {
|
||||
const [row] = groupGrants([{ path: 'secret/data/app/db', capabilities: ['read'] }], ['secret/'])
|
||||
expect(row).toMatchObject({ display: 'secret/app/db', wildcard: false, paths: ['secret/data/app/db'] })
|
||||
})
|
||||
|
||||
test('paths outside a known KV mount keep their raw path', () => {
|
||||
const [row] = groupGrants([{ path: 'sys/health', capabilities: ['read'] }], ['secret/'])
|
||||
expect(row).toMatchObject({ display: 'sys/health', paths: ['sys/health'] })
|
||||
})
|
||||
|
||||
test('keeps different secrets and mounts apart', () => {
|
||||
const rows = groupGrants(
|
||||
[
|
||||
{ path: 'secret/data/a', capabilities: ['read'] },
|
||||
{ path: 'kv/data/a', capabilities: ['read'] },
|
||||
],
|
||||
['secret/', 'kv/'],
|
||||
)
|
||||
expect(rows.map((r) => r.display)).toEqual(['secret/a', 'kv/a'])
|
||||
})
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { Grant } from './managed'
|
||||
import { CAPABILITIES, type Capability } from './policy'
|
||||
|
||||
/** One line in the "granted by EnvBao" list: a secret path with everything granted on it. */
|
||||
export interface GrantRow {
|
||||
/** Where the grant applies as a user thinks of it, e.g. "secret/app/*" (not "secret/data/app/*"). */
|
||||
display: string
|
||||
wildcard: boolean
|
||||
capabilities: Capability[]
|
||||
/** The policy paths behind this row; revoking the row removes all of them. */
|
||||
paths: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* KV v2 grants are stored as a `data/` rule and a `metadata/` rule per secret. Fold each pair into one row
|
||||
* keyed by the secret's own path; grants outside a known KV mount keep their raw path.
|
||||
*/
|
||||
export function groupGrants(grants: Grant[], mounts: string[]): GrantRow[] {
|
||||
const rows = new Map<string, GrantRow>()
|
||||
for (const g of grants) {
|
||||
let display = g.path
|
||||
for (const m of mounts) {
|
||||
const mount = m.endsWith('/') ? m : `${m}/`
|
||||
for (const kind of ['data', 'metadata']) {
|
||||
const prefix = `${mount}${kind}/`
|
||||
if (g.path.startsWith(prefix)) display = mount + g.path.slice(prefix.length)
|
||||
}
|
||||
}
|
||||
const row = rows.get(display) ?? { display, wildcard: display.endsWith('*'), capabilities: [], paths: [] }
|
||||
row.capabilities = CAPABILITIES.filter((c) => row.capabilities.includes(c) || g.capabilities.includes(c))
|
||||
row.paths.push(g.path)
|
||||
rows.set(display, row)
|
||||
}
|
||||
return [...rows.values()]
|
||||
}
|
||||
Reference in new issue
Block a user