Add Access Graph view with filters, details panel and revoke
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5180e1bb74
commit
265c618884
11 files changed
+731
-54
No files matched your search
@@ -1,11 +1,8 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import type { BaoClient } from '../../api/bao'
|
||||
import { listEntities, listGroups, listPolicyNames, listUsers } from '../../api/identities'
|
||||
import { dataPath, readPolicyHcl } from '../../api/secrets'
|
||||
import { listTokens } from '../../api/tokens'
|
||||
import { dataPath } from '../../api/secrets'
|
||||
import { accessForPath } from '../../model/graph'
|
||||
import { resolveIdentities } from '../../model/identities'
|
||||
import { pathMatches } from '../../model/policy'
|
||||
import { useAccessInputs } from '../shared/useAccessInputs'
|
||||
|
||||
interface Props {
|
||||
client: BaoClient
|
||||
@@ -14,37 +11,7 @@ interface Props {
|
||||
}
|
||||
|
||||
export function AccessPanel({ client, mount, secret }: Props) {
|
||||
const data = useQuery({
|
||||
queryKey: ['access-inputs'],
|
||||
queryFn: async () => {
|
||||
// Each source can be forbidden for a limited admin, so a failure degrades to "none" with a note.
|
||||
const soft = async <T,>(label: string, p: Promise<T>, fallback: T) => {
|
||||
try {
|
||||
return { value: await p, note: null }
|
||||
} catch (e) {
|
||||
return { value: fallback, note: `${label}: ${e instanceof Error ? e.message : String(e)}` }
|
||||
}
|
||||
}
|
||||
const [users, entities, groups, tokens, names] = await Promise.all([
|
||||
soft('users', listUsers(client), []),
|
||||
soft('entities', listEntities(client), []),
|
||||
soft('groups', listGroups(client), []),
|
||||
soft('tokens', listTokens(client), []),
|
||||
listPolicyNames(client),
|
||||
])
|
||||
const policies = await Promise.all(names.map(async (name) => ({ name, hcl: await readPolicyHcl(client, name) })))
|
||||
return {
|
||||
identities: resolveIdentities({
|
||||
users: users.value,
|
||||
entities: entities.value,
|
||||
groups: groups.value,
|
||||
tokens: tokens.value,
|
||||
}),
|
||||
policies,
|
||||
notes: [users, entities, groups, tokens].flatMap((r) => (r.note ? [r.note] : [])),
|
||||
}
|
||||
},
|
||||
})
|
||||
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>
|
||||
|
||||
Reference in new issue
Block a user