@coffre/ui 0.14.5 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{audit-sentence-JgJEwQEC.js → actions-log-DupYCEyV.js} +186 -21
- package/dist/chunks/actions-log-DupYCEyV.js.map +1 -0
- package/dist/chunks/{connected-apps-IJdunsu8.js → connected-apps-CGUQlFMx.js} +5 -5
- package/dist/chunks/{connected-apps-IJdunsu8.js.map → connected-apps-CGUQlFMx.js.map} +1 -1
- package/dist/chunks/{delete-place-dIVoK87I.js → delete-place-CswZ-meh.js} +5 -5
- package/dist/chunks/{delete-place-dIVoK87I.js.map → delete-place-CswZ-meh.js.map} +1 -1
- package/dist/chunks/{directory-BM8yoiJN.js → directory-DrswWQLT.js} +15 -15
- package/dist/chunks/directory-DrswWQLT.js.map +1 -0
- package/dist/chunks/environment-actions-8rL9Cw6X.js +576 -0
- package/dist/chunks/environment-actions-8rL9Cw6X.js.map +1 -0
- package/dist/chunks/{folders-D3A1NGpt.js → folders-A6sbR_PG.js} +3 -3
- package/dist/chunks/{folders-D3A1NGpt.js.map → folders-A6sbR_PG.js.map} +1 -1
- package/dist/chunks/{grants-CjVmOgb2.js → grants-C0cb2oii.js} +8 -8
- package/dist/chunks/grants-C0cb2oii.js.map +1 -0
- package/dist/chunks/{multi-combobox-B0JzP1QN.js → multi-combobox-B3SEv1gq.js} +3 -3
- package/dist/chunks/{multi-combobox-B0JzP1QN.js.map → multi-combobox-B3SEv1gq.js.map} +1 -1
- package/dist/chunks/{offboarding-DbozhPym.js → offboarding-C1jbG_dk.js} +72 -67
- package/dist/chunks/offboarding-C1jbG_dk.js.map +1 -0
- package/dist/chunks/{page-JTORvh-N.js → page-CfhC9Hp1.js} +11 -6
- package/dist/chunks/page-CfhC9Hp1.js.map +1 -0
- package/dist/chunks/{personal-tokens-zWZOzLIC.js → personal-tokens-xC9wulhg.js} +5 -5
- package/dist/chunks/{personal-tokens-zWZOzLIC.js.map → personal-tokens-xC9wulhg.js.map} +1 -1
- package/dist/chunks/{principal-DFBswTBr.js → principal-CI17XK13.js} +2 -2
- package/dist/chunks/{principal-DFBswTBr.js.map → principal-CI17XK13.js.map} +1 -1
- package/dist/chunks/{principal-page-jJ0RVFg8.js → principal-page-CdSeftGD.js} +17 -127
- package/dist/chunks/principal-page-CdSeftGD.js.map +1 -0
- package/dist/chunks/{project-page-BjwEoXfU.js → project-page-CHxjBE97.js} +3 -3
- package/dist/chunks/{project-page-BjwEoXfU.js.map → project-page-CHxjBE97.js.map} +1 -1
- package/dist/chunks/{queries-2jdgTwfZ.js → queries-D1JuimTu.js} +82 -26
- package/dist/chunks/queries-D1JuimTu.js.map +1 -0
- package/dist/chunks/{references-CRT2BsOS.js → references-D5llUGQL.js} +5 -5
- package/dist/chunks/{references-CRT2BsOS.js.map → references-D5llUGQL.js.map} +1 -1
- package/dist/chunks/{role-field-DswIpPqY.js → role-field-CoCv8wse.js} +5 -5
- package/dist/chunks/role-field-CoCv8wse.js.map +1 -0
- package/dist/chunks/{row-state-xtRGFnDc.js → row-state-CYH7kZHl.js} +3 -3
- package/dist/chunks/{row-state-xtRGFnDc.js.map → row-state-CYH7kZHl.js.map} +1 -1
- package/dist/chunks/{theme-Ck45wzWB.js → theme-rF44Wbmm.js} +3 -3
- package/dist/chunks/{theme-Ck45wzWB.js.map → theme-rF44Wbmm.js.map} +1 -1
- package/dist/chunks/{ui-D-blFWfx.js → ui-CGdORVzW.js} +2 -2
- package/dist/chunks/{ui-D-blFWfx.js.map → ui-CGdORVzW.js.map} +1 -1
- package/dist/chunks/{use-action-CXEFFjx5.js → use-action-BxrHTBZw.js} +3 -3
- package/dist/chunks/{use-action-CXEFFjx5.js.map → use-action-BxrHTBZw.js.map} +1 -1
- package/dist/chunks/{use-change-BC4xo02c.js → use-change-BorW2R6C.js} +4 -4
- package/dist/chunks/{use-change-BC4xo02c.js.map → use-change-BorW2R6C.js.map} +1 -1
- package/dist/chunks/{use-roles-DswiNxBk.js → use-roles-BZnJ9Cq0.js} +56 -13
- package/dist/chunks/use-roles-BZnJ9Cq0.js.map +1 -0
- package/dist/chunks/{use-shell-zpjE_MKh.js → use-shell-CPskgi1k.js} +3 -3
- package/dist/chunks/{use-shell-zpjE_MKh.js.map → use-shell-CPskgi1k.js.map} +1 -1
- package/dist/index.d.ts +46 -2
- package/dist/index.js +30 -11
- package/dist/index.js.map +1 -1
- package/dist/pages/account.js +11 -11
- package/dist/pages/account.js.map +1 -1
- package/dist/pages/approval.js +2 -2
- package/dist/pages/audit.js +55 -21
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +2 -2
- package/dist/pages/environment.js +228 -389
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +3 -3
- package/dist/pages/oauth-authorize.js +2 -2
- package/dist/pages/project-access.js +11 -11
- package/dist/pages/project-environments.js +28 -359
- package/dist/pages/project-environments.js.map +1 -1
- package/dist/pages/project-settings.js +8 -8
- package/dist/pages/project.js +3 -3
- package/dist/pages/projects.js +8 -8
- package/dist/pages/service-account.js +11 -10
- package/dist/pages/service-account.js.map +1 -1
- package/dist/pages/service-accounts.js +7 -6
- package/dist/pages/service-accounts.js.map +1 -1
- package/dist/pages/settings.d.ts +6 -1
- package/dist/pages/settings.js +284 -164
- package/dist/pages/settings.js.map +1 -1
- package/dist/pages/unregistered.js +2 -2
- package/dist/pages/user.js +7 -6
- package/dist/pages/user.js.map +1 -1
- package/dist/pages/users.js +7 -6
- package/dist/pages/users.js.map +1 -1
- package/package.json +3 -3
- package/src/components/actions-log.tsx +61 -8
- package/src/components/directory.tsx +5 -5
- package/src/components/environment-actions.tsx +508 -0
- package/src/components/grants.tsx +2 -2
- package/src/components/icons.tsx +2 -0
- package/src/components/offboarding.tsx +7 -0
- package/src/components/page.tsx +3 -2
- package/src/components/principal-page.tsx +1 -1
- package/src/components/protected.tsx +52 -39
- package/src/components/role-editor.tsx +99 -68
- package/src/components/role-field.tsx +1 -1
- package/src/lib/audit-sentences.ts +21 -18
- package/src/lib/queries.ts +85 -21
- package/src/lib/roles.ts +36 -10
- package/src/options.ts +19 -3
- package/src/pages/account.tsx +1 -1
- package/src/pages/audit.tsx +56 -16
- package/src/pages/environment.tsx +227 -352
- package/src/pages/project-environments.tsx +20 -322
- package/src/pages/service-accounts.tsx +1 -1
- package/src/pages/settings.tsx +129 -48
- package/src/pages/users.tsx +1 -1
- package/src/parity.ts +18 -11
- package/src/styles/globals.css +271 -89
- package/dist/chunks/audit-sentence-JgJEwQEC.js.map +0 -1
- package/dist/chunks/directory-BM8yoiJN.js.map +0 -1
- package/dist/chunks/grants-CjVmOgb2.js.map +0 -1
- package/dist/chunks/offboarding-DbozhPym.js.map +0 -1
- package/dist/chunks/page-JTORvh-N.js.map +0 -1
- package/dist/chunks/principal-page-jJ0RVFg8.js.map +0 -1
- package/dist/chunks/protected-y7KVhtHd.js +0 -77
- package/dist/chunks/protected-y7KVhtHd.js.map +0 -1
- package/dist/chunks/queries-2jdgTwfZ.js.map +0 -1
- package/dist/chunks/role-field-DswIpPqY.js.map +0 -1
- package/dist/chunks/use-roles-DswiNxBk.js.map +0 -1
|
@@ -5,76 +5,89 @@ import { keys } from '../lib/queries';
|
|
|
5
5
|
import { protectionInWords } from '../lib/roles';
|
|
6
6
|
import { useChange, useChangeStatus } from '../lib/use-change';
|
|
7
7
|
import { useRoles } from '../lib/use-roles';
|
|
8
|
-
import { useShell } from '../lib/use-shell';
|
|
9
8
|
import { Lock } from './icons';
|
|
10
|
-
import {
|
|
9
|
+
import { ConfirmDialog, Toggletip } from './ui';
|
|
11
10
|
|
|
12
11
|
const MEANING = 'Protected: each person here holds their role’s protected column, which an Owner sets in Settings › Roles. Service accounts hold their role as anywhere else.';
|
|
13
12
|
const WHO_UNPROTECTS = 'Only an Owner of its project takes protection off.';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* note says what it means and who changes it, and nothing while it is off.
|
|
22
|
-
* A personal config has none of its own: it is as its parent is.
|
|
15
|
+
* Whether you change an environment's protection: whoever manages the
|
|
16
|
+
* project's environments protects one, and only an Owner of its project,
|
|
17
|
+
* or of the whole instance, takes it off, as the server says
|
|
18
|
+
* (`unprotectable`). A personal config has none of its own: it is as its
|
|
19
|
+
* parent is.
|
|
23
20
|
*/
|
|
24
|
-
export function
|
|
25
|
-
const { projects } = useShell();
|
|
21
|
+
export function changesProtection(projects: readonly { slug: string; permissions: readonly string[] }[], project: string, environment: ProjectEnvironment): boolean {
|
|
26
22
|
const manages = projects.find((entry) => entry.slug === project)?.permissions.includes('environment.manage') === true;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
return manages && environment.details !== null && environment.personal !== true && (!environment.protected || environment.unprotectable === true);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* An environment's protection (docs/design/roles.md), while it is on: a
|
|
28
|
+
* tag on its page, a lock on its card, whose note says what it means and
|
|
29
|
+
* who takes it off. Nothing while it is off. It is changed from the
|
|
30
|
+
* environment's actions menu (`ProtectDialog`).
|
|
31
|
+
*/
|
|
32
|
+
export function Protection({ environment, compact = false }: { environment: ProjectEnvironment; compact?: boolean }) {
|
|
33
|
+
if (!environment.protected) return null;
|
|
33
34
|
return (
|
|
34
35
|
<Toggletip label={`${MEANING} ${WHO_UNPROTECTS}`}>
|
|
35
|
-
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
{compact ? (
|
|
37
|
+
<button type="button" className="protected-mark" aria-label="Protected">
|
|
38
|
+
<Lock size={13} />
|
|
39
|
+
</button>
|
|
40
|
+
) : (
|
|
41
|
+
<button type="button" className="tag tag-amber tag-button">
|
|
42
|
+
<Lock size={11} />
|
|
43
|
+
Protected
|
|
44
|
+
</button>
|
|
45
|
+
)}
|
|
39
46
|
</Toggletip>
|
|
40
47
|
);
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
/**
|
|
44
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Protecting the environment, or taking it off, once confirmed: shown at
|
|
52
|
+
* once on its card and its page, which say if the server refuses. Once a
|
|
53
|
+
* change is on its way, another waits for its answer: the later of two
|
|
54
|
+
* would otherwise land as it likes.
|
|
55
|
+
*/
|
|
56
|
+
export function ProtectDialog({
|
|
57
|
+
project,
|
|
58
|
+
environment,
|
|
59
|
+
open,
|
|
60
|
+
onOpenChange,
|
|
61
|
+
}: {
|
|
62
|
+
project: string;
|
|
63
|
+
environment: ProjectEnvironment;
|
|
64
|
+
open: boolean;
|
|
65
|
+
onOpenChange: (open: boolean) => void;
|
|
66
|
+
}) {
|
|
45
67
|
const { roles } = useRoles();
|
|
46
68
|
const protect = useChange(protectEnvironment(useCoffre(), project));
|
|
47
69
|
const { status } = useChangeStatus(keys.projects);
|
|
48
70
|
const protection = protectionInWords(roles);
|
|
49
|
-
const
|
|
71
|
+
const { slug, protected: guarded } = environment;
|
|
50
72
|
return (
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
type="button"
|
|
55
|
-
className={`tag tag-button tag-control ${guarded ? 'tag-amber' : 'tag-outline'}`}
|
|
56
|
-
aria-label={guarded ? `Protected: unprotect ${place}…` : `Protect ${place}…`}
|
|
57
|
-
>
|
|
58
|
-
<Lock size={11} />
|
|
59
|
-
{guarded ? 'Protected' : 'Protect…'}
|
|
60
|
-
</button>
|
|
61
|
-
}
|
|
62
|
-
// Once a change is on its way, the tag shows it already; another waits for its answer.
|
|
63
|
-
disabled={status(environmentId(project, slug)).state === 'pending'}
|
|
73
|
+
<ConfirmDialog
|
|
74
|
+
open={open}
|
|
75
|
+
onOpenChange={onOpenChange}
|
|
64
76
|
title={
|
|
65
77
|
<>
|
|
66
|
-
{guarded ? 'Unprotect' : 'Protect'} <span className="mono">{
|
|
78
|
+
{guarded ? 'Unprotect' : 'Protect'} <span className="mono">{project}/{slug}</span>?
|
|
67
79
|
</>
|
|
68
80
|
}
|
|
69
81
|
body={
|
|
70
82
|
guarded
|
|
71
83
|
? 'People holding a role here get its full column again, as in any other environment. Service accounts are unaffected.'
|
|
72
84
|
: `People holding a role here get its protected column${protection === null ? ', which for now holds what the other does' : `: ${protection}`}. Service accounts are unaffected.${
|
|
73
|
-
|
|
85
|
+
environment.unprotectable === true ? '' : ` ${WHO_UNPROTECTS}`
|
|
74
86
|
}`
|
|
75
87
|
}
|
|
76
88
|
confirmLabel={guarded ? 'Unprotect' : 'Protect'}
|
|
77
89
|
destructive={guarded}
|
|
90
|
+
confirmDisabled={status(environmentId(project, slug)).state === 'pending'}
|
|
78
91
|
onConfirm={() => protect({ slug, protected: !guarded })}
|
|
79
92
|
/>
|
|
80
93
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useId, useRef, useState } from 'react';
|
|
1
|
+
import { useId, useRef, useState, type ReactNode } from 'react';
|
|
2
2
|
import { CoffreError, type RoleImpact, type RoleView } from '@coffre/client';
|
|
3
3
|
import { definitionProblem, type Permission, type RoleDefinition } from '@coffre/core/access';
|
|
4
4
|
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
@@ -7,6 +7,7 @@ import { toast } from 'sonner';
|
|
|
7
7
|
import { useCoffre } from '../lib/coffre';
|
|
8
8
|
import { affects, queries } from '../lib/queries';
|
|
9
9
|
import {
|
|
10
|
+
CARD_ROWS,
|
|
10
11
|
columnInWords,
|
|
11
12
|
GRID_PERMISSIONS,
|
|
12
13
|
impactExamples,
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
ordered,
|
|
15
16
|
PERMISSION_WORDS,
|
|
16
17
|
projectWide,
|
|
18
|
+
reachOf,
|
|
17
19
|
roleIdFrom,
|
|
18
20
|
roleIdProblem,
|
|
19
21
|
sameDefinition,
|
|
@@ -22,89 +24,70 @@ import {
|
|
|
22
24
|
type Columns,
|
|
23
25
|
} from '../lib/roles';
|
|
24
26
|
import { useAction } from '../lib/use-action';
|
|
25
|
-
import { Card } from './page';
|
|
26
27
|
import { Check, Lock, Pencil, Plus, RotateBack, Trash } from './icons';
|
|
27
28
|
import { ConfirmDialog, ErrorLine, Modal, Notice, Spinner } from './ui';
|
|
28
29
|
|
|
29
|
-
// Settings › Roles (docs/design/roles.md): what each role
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
30
|
+
// Settings › Roles (docs/design/roles.md): what each role can do, in an
|
|
31
|
+
// environment and in a protected one, which a person holds there; a
|
|
32
|
+
// service account holds the first everywhere. Any member reads them; an
|
|
33
|
+
// Owner of the whole instance edits them, each change weighed first
|
|
34
|
+
// (`?dryRun=1`) and said in words before it is confirmed.
|
|
34
35
|
|
|
35
|
-
type Kind = 'role' | 'instance-role';
|
|
36
|
+
export type Kind = 'role' | 'instance-role';
|
|
36
37
|
|
|
37
|
-
/**
|
|
38
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The instance's project roles, or its global roles (instance roles, in
|
|
40
|
+
* the code and the API): a card each, which opens its editor, under what
|
|
41
|
+
* switches between the two.
|
|
42
|
+
*/
|
|
43
|
+
export function RolesSettings({ kind, switcher }: { kind: Kind; switcher: ReactNode }) {
|
|
39
44
|
const { data } = useSuspenseQuery(queries.roles(useCoffre()));
|
|
40
|
-
if (!data.ok) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<div className="card-row">
|
|
44
|
-
<ErrorLine error={`The roles could not be read. ${data.error}`} />
|
|
45
|
-
</div>
|
|
46
|
-
</Card>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return (
|
|
50
|
-
<>
|
|
51
|
-
<RoleList kind="role" roles={data.roles} editable={data.editable} />
|
|
52
|
-
<RoleList kind="instance-role" roles={data.instanceRoles} editable={data.editable} />
|
|
53
|
-
</>
|
|
54
|
-
);
|
|
45
|
+
if (!data.ok) return <ErrorLine error={`The roles could not be read. ${data.error}`} />;
|
|
46
|
+
// Keyed by kind: an editor open on one, its draft included, never outlives it into the other's role of the same id.
|
|
47
|
+
return <RoleList key={kind} kind={kind} roles={kind === 'role' ? data.roles : data.instanceRoles} editable={data.editable} switcher={switcher} />;
|
|
55
48
|
}
|
|
56
49
|
|
|
57
|
-
function RoleList({ kind, roles, editable }: { kind: Kind; roles: RoleView[]; editable: boolean }) {
|
|
50
|
+
function RoleList({ kind, roles, editable, switcher }: { kind: Kind; roles: RoleView[]; editable: boolean; switcher: ReactNode }) {
|
|
58
51
|
// The role open in the editor, by id, or one being made: never a role's id, which `new` may be.
|
|
59
52
|
const [open, setOpen] = useState<{ role: string } | { making: true } | null>(null);
|
|
60
53
|
const project = kind === 'role';
|
|
61
54
|
const opened = open === null || 'making' in open ? null : roles.find((role) => role.id === open.role);
|
|
62
55
|
return (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<>
|
|
68
|
-
{project
|
|
69
|
-
? 'What a grant gives, on a project or one of its environments. In a protected environment a person holds the second column; a service account always holds the first.'
|
|
70
|
-
: 'What a person holds, by their instance role, in every project its scope takes in, before any grant adds to it.'}
|
|
71
|
-
{!editable && ' Only an Owner of the whole instance edits them.'}
|
|
72
|
-
</>
|
|
73
|
-
}
|
|
74
|
-
actions={
|
|
75
|
-
project && editable && (
|
|
56
|
+
<>
|
|
57
|
+
<div className="section-actions">
|
|
58
|
+
{switcher}
|
|
59
|
+
{project && editable && (
|
|
76
60
|
<button className="btn" type="button" onClick={() => setOpen({ making: true })}>
|
|
77
61
|
<Plus size={14} />
|
|
78
62
|
New role
|
|
79
63
|
</button>
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
)}
|
|
65
|
+
</div>
|
|
66
|
+
<div className="roles-desc">
|
|
67
|
+
<p>
|
|
68
|
+
{project
|
|
69
|
+
? 'Granted on a project or environment; a person or service account can hold several.'
|
|
70
|
+
: 'One per person, across every project in its scope; assigned on Users.'}
|
|
71
|
+
</p>
|
|
72
|
+
{roles.some((role) => GRID_PERMISSIONS.some((permission) => reachOf(role, permission) === 'unprotected')) && (
|
|
73
|
+
<p className="role-legend" aria-hidden>
|
|
74
|
+
<Lock size={12} />
|
|
75
|
+
Not in protected environments
|
|
76
|
+
</p>
|
|
77
|
+
)}
|
|
78
|
+
</div>
|
|
79
|
+
<ul className="role-cards" aria-label={project ? 'Project roles' : 'Global roles'}>
|
|
84
80
|
{roles.map((role) => (
|
|
85
|
-
<li key={role.id} className="
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<dd>{columnInWords(role.permissions)}</dd>
|
|
96
|
-
</div>
|
|
97
|
-
<div>
|
|
98
|
-
<dt>
|
|
99
|
-
<Lock size={12} />
|
|
100
|
-
In protected environments
|
|
101
|
-
</dt>
|
|
102
|
-
<dd>{columnInWords(role.protected)}</dd>
|
|
103
|
-
</div>
|
|
104
|
-
</dl>
|
|
105
|
-
</div>
|
|
106
|
-
<div className="role-row-side">
|
|
107
|
-
<span className="role-row-count">{held(kind, role.grants)}</span>
|
|
81
|
+
<li key={role.id} className="role-card">
|
|
82
|
+
<p className="role-card-title">
|
|
83
|
+
{role.name}
|
|
84
|
+
<RoleBadges role={role} />
|
|
85
|
+
</p>
|
|
86
|
+
{/* A built-in role's own words would go stale as an Owner edits what it can; a custom one's are its maker's. */}
|
|
87
|
+
{!role.builtin && role.description !== '' && <p className="role-card-desc">{role.description}</p>}
|
|
88
|
+
<RoleReach role={role} />
|
|
89
|
+
<div className="role-card-foot">
|
|
90
|
+
<span className="role-card-count">{held(kind, role.grants)}</span>
|
|
108
91
|
<button
|
|
109
92
|
className="btn btn-sm"
|
|
110
93
|
type="button"
|
|
@@ -129,7 +112,7 @@ function RoleList({ kind, roles, editable }: { kind: Kind; roles: RoleView[]; ed
|
|
|
129
112
|
onClose={() => setOpen(null)}
|
|
130
113
|
/>
|
|
131
114
|
)}
|
|
132
|
-
|
|
115
|
+
</>
|
|
133
116
|
);
|
|
134
117
|
}
|
|
135
118
|
|
|
@@ -139,6 +122,54 @@ function held(kind: Kind, count: number): string {
|
|
|
139
122
|
return count === 0 ? 'No grants' : count === 1 ? '1 grant' : `${count} grants`;
|
|
140
123
|
}
|
|
141
124
|
|
|
125
|
+
/**
|
|
126
|
+
* What a role can do, on its card: every permission, in the same place on
|
|
127
|
+
* every card, held ones solid, the others a dashed outline, and a lock on
|
|
128
|
+
* one it holds only outside protected environments. A screen reader hears
|
|
129
|
+
* each in full: "Read values: yes, except in protected environments".
|
|
130
|
+
*/
|
|
131
|
+
function RoleReach({ role }: { role: RoleView }) {
|
|
132
|
+
return (
|
|
133
|
+
<dl className="role-reach">
|
|
134
|
+
{CARD_ROWS.map((row) => (
|
|
135
|
+
<div key={row.name}>
|
|
136
|
+
<dt>{row.name}</dt>
|
|
137
|
+
<dd>
|
|
138
|
+
{/* Safari reads a list without bullets as no list, unless told. */}
|
|
139
|
+
<ul role="list">
|
|
140
|
+
{row.permissions.map((permission) => {
|
|
141
|
+
const reach = reachOf(role, permission);
|
|
142
|
+
const { label, short } = PERMISSION_WORDS[permission];
|
|
143
|
+
const words = reach === 'nowhere' ? 'no' : reach === 'unprotected' ? 'yes, except in protected environments' : 'yes';
|
|
144
|
+
return (
|
|
145
|
+
<li
|
|
146
|
+
key={permission}
|
|
147
|
+
className={`role-perm role-perm-${reach}`}
|
|
148
|
+
title={reach === 'unprotected' ? `${label}, not in protected environments` : label}
|
|
149
|
+
>
|
|
150
|
+
<span className="role-perm-shown" aria-hidden>
|
|
151
|
+
{short}
|
|
152
|
+
{reach === 'unprotected' && <Lock size={11} />}
|
|
153
|
+
</span>
|
|
154
|
+
{/* Its widest look, unseen: a chip is as wide on every card, whatever the role holds, and wraps alike. */}
|
|
155
|
+
<span className="role-perm-widest" aria-hidden>
|
|
156
|
+
{short}
|
|
157
|
+
{!projectWide(permission) && <Lock size={11} />}
|
|
158
|
+
</span>
|
|
159
|
+
<span className="visually-hidden">
|
|
160
|
+
{label}: {words}
|
|
161
|
+
</span>
|
|
162
|
+
</li>
|
|
163
|
+
);
|
|
164
|
+
})}
|
|
165
|
+
</ul>
|
|
166
|
+
</dd>
|
|
167
|
+
</div>
|
|
168
|
+
))}
|
|
169
|
+
</dl>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
142
173
|
/** Where a role comes from, and whether it is as it shipped. */
|
|
143
174
|
function RoleBadges({ role }: { role: RoleView }) {
|
|
144
175
|
return (
|
|
@@ -377,7 +408,7 @@ function RoleEditor({
|
|
|
377
408
|
{editable && (
|
|
378
409
|
<p className="hint">
|
|
379
410
|
Reading takes using, and a protected environment holds no more than any other: the boxes keep both true.
|
|
380
|
-
{instance ? '
|
|
411
|
+
{instance ? ' A global role reaches every project its holder’s scope takes in.' : ''}
|
|
381
412
|
</p>
|
|
382
413
|
)}
|
|
383
414
|
{role !== null && role.edited && (
|
|
@@ -22,7 +22,7 @@ export function RoleField({ value, onChange }: { value: RoleVars; onChange: (val
|
|
|
22
22
|
return (
|
|
23
23
|
<>
|
|
24
24
|
<label className="field">
|
|
25
|
-
<span className="label">
|
|
25
|
+
<span className="label">Global role</span>
|
|
26
26
|
<select
|
|
27
27
|
className="select"
|
|
28
28
|
value={role}
|
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
* A sentence is parts rather than a string, so the page can make the people
|
|
8
8
|
* and places in it links. `plain` flattens it, for tests and titles.
|
|
9
9
|
*/
|
|
10
|
-
import { shownMember, type AuditEntryView } from '@coffre/client';
|
|
10
|
+
import { runLabel, shownMember, type AuditEntryView } from '@coffre/client';
|
|
11
11
|
import { INSTANCE_ROLES, isBuiltinRole, isInstanceRole, isScope, ROLES, scopeInWords, type Scope } from '@coffre/core/access';
|
|
12
12
|
|
|
13
|
+
/** The run an entry was written for, said beside who did it: one rule for the pages and the CLI. */
|
|
14
|
+
export { runLabel };
|
|
15
|
+
|
|
13
16
|
/** What a sentence is made from: an entry of the log, as `GET /api/audit` gives it. */
|
|
14
17
|
export type AuditEntry = Pick<
|
|
15
18
|
AuditEntryView,
|
|
@@ -364,7 +367,7 @@ const TEMPLATES: Record<string, Template> = {
|
|
|
364
367
|
const by = entry.metadata.replacedBy as { role?: unknown } | undefined;
|
|
365
368
|
if (by === undefined) return [];
|
|
366
369
|
const role = typeof by.role === 'string' ? roleName(by.role) : null;
|
|
367
|
-
return [role === null || role === 'Member' ? ', replaced by project grants' : `, replaced by the
|
|
370
|
+
return [role === null || role === 'Member' ? ', replaced by project grants' : `, replaced by the global role ${role}`];
|
|
368
371
|
},
|
|
369
372
|
},
|
|
370
373
|
'member.add': {
|
|
@@ -441,6 +444,14 @@ const TEMPLATES: Record<string, Template> = {
|
|
|
441
444
|
tried: 'stop trusting CI runs to sign in as',
|
|
442
445
|
what: (facts) => subject(facts.entry),
|
|
443
446
|
},
|
|
447
|
+
// A service signed in through one of its bindings, by its platform's proof: a CI run's, or a workload's session bound
|
|
448
|
+
// to its key. Its run is said beside who did it (`runLabel`).
|
|
449
|
+
'token.exchange': {
|
|
450
|
+
did: 'signed in',
|
|
451
|
+
tried: 'sign in',
|
|
452
|
+
what: ({ entry }) => [entry.metadata.proof === 'aws' ? 'with its AWS identity' : `with an ID token from ${issuerName(entry)}`],
|
|
453
|
+
then: ({ entry }) => (entry.metadata.kind === 'workload' ? [', for a session bound to its key'] : []),
|
|
454
|
+
},
|
|
444
455
|
'vault.tampered': {
|
|
445
456
|
did: 'found',
|
|
446
457
|
tried: 'check',
|
|
@@ -622,7 +633,7 @@ function policyOf(entry: AuditEntry): { verb: keyof typeof POLICY_VERBS; what: P
|
|
|
622
633
|
const verb = change.definition === null || entry.metadata.definition === null || entry.reason === 'role_granted'
|
|
623
634
|
? (shipped ? 'reset' : 'delete')
|
|
624
635
|
: before.definition === null ? 'make' : 'edit';
|
|
625
|
-
return { verb, what: [name === null ? 'a role' : `the ${name} ${instance ? '
|
|
636
|
+
return { verb, what: [name === null ? 'a role' : `the ${name} ${instance ? 'global role' : 'role'}`] };
|
|
626
637
|
}
|
|
627
638
|
|
|
628
639
|
/** An object of the metadata's, or an empty one for anything else. */
|
|
@@ -656,6 +667,13 @@ function reaching(entry: AuditEntry, none = ''): Part[] {
|
|
|
656
667
|
return [`, reaching ${[...byRole].map(([role, count]) => `${role} on ${plural(count, 'place')}`).join(', ')}`];
|
|
657
668
|
}
|
|
658
669
|
|
|
670
|
+
/** The issuer an ID token came from, by its host: `token.actions.githubusercontent.com`. */
|
|
671
|
+
function issuerName(entry: AuditEntry): string {
|
|
672
|
+
const issuer = text(entry.metadata.issuer);
|
|
673
|
+
if (issuer === null) return 'its platform';
|
|
674
|
+
return URL.canParse(issuer) && new URL(issuer).host !== '' ? new URL(issuer).host : issuer;
|
|
675
|
+
}
|
|
676
|
+
|
|
659
677
|
/** The GitHub environment a binding takes its runs from, when it names one. */
|
|
660
678
|
function inGitHubEnvironment(entry: AuditEntry): Part[] {
|
|
661
679
|
const environment = text((entry.metadata.claims as Record<string, unknown> | undefined)?.environment);
|
|
@@ -882,18 +900,3 @@ export function plain(parts: Part[]): string {
|
|
|
882
900
|
)
|
|
883
901
|
.join('');
|
|
884
902
|
}
|
|
885
|
-
|
|
886
|
-
/**
|
|
887
|
-
* The CI run an entry was written for, as its issuer stated it at the
|
|
888
|
-
* exchange: `acme/api run 7001 at 3f2a9c1`, a GitLab pipeline, or the
|
|
889
|
-
* token's subject. Null for an entry no trust binding's credential wrote.
|
|
890
|
-
*/
|
|
891
|
-
export function runLabel(run: { claims: Record<string, string | number> } | null): string | null {
|
|
892
|
-
if (run === null) return null;
|
|
893
|
-
const { claims } = run;
|
|
894
|
-
const text = (name: string) => (typeof claims[name] === 'string' || typeof claims[name] === 'number' ? String(claims[name]) : null);
|
|
895
|
-
const at = text('sha') === null ? '' : ` at ${text('sha')!.slice(0, 7)}`;
|
|
896
|
-
if (text('repository') !== null && text('run_id') !== null) return `${text('repository')} run ${text('run_id')}${at}`;
|
|
897
|
-
if (text('project_path') !== null && text('pipeline_id') !== null) return `${text('project_path')} pipeline ${text('pipeline_id')}${at}`;
|
|
898
|
-
return text('sub') === null ? 'a CI run' : `CI run ${text('sub')}`;
|
|
899
|
-
}
|
package/src/lib/queries.ts
CHANGED
|
@@ -101,7 +101,7 @@ function grantRows(members: Member[]): GrantRow[] {
|
|
|
101
101
|
|
|
102
102
|
function listDirectory(client: CoffreClient) {
|
|
103
103
|
return uiResult(async () => {
|
|
104
|
-
const { members, removed } = await client.members.list();
|
|
104
|
+
const { members, removed, reads } = await client.members.list();
|
|
105
105
|
const principals: DirectoryPrincipal[] = members.map(
|
|
106
106
|
({ principalType, principalId, instanceRole, scope, tampered, managed, declared, grants }) => ({
|
|
107
107
|
principalType,
|
|
@@ -114,7 +114,8 @@ function listDirectory(client: CoffreClient) {
|
|
|
114
114
|
grants: grants.map(({ project, environment }) => ({ project, environment })),
|
|
115
115
|
}),
|
|
116
116
|
);
|
|
117
|
-
|
|
117
|
+
// How far reads are listed, under 0.15's log, which the counts of what the removed saw are as of (T166).
|
|
118
|
+
return { principals, removed, ...(reads === undefined ? {} : { reads }) };
|
|
118
119
|
});
|
|
119
120
|
}
|
|
120
121
|
|
|
@@ -125,6 +126,12 @@ export type ProjectsResult = Awaited<ReturnType<typeof readProjects>>;
|
|
|
125
126
|
|
|
126
127
|
export type AuditSearch = { decision?: 'deny'; actorId?: string; detail?: '1' };
|
|
127
128
|
|
|
129
|
+
/** Settings' tabs past the first, General, by their `?tab=`. */
|
|
130
|
+
export const SETTINGS_TABS = ['roles', 'keys'] as const;
|
|
131
|
+
export type SettingsTab = (typeof SETTINGS_TABS)[number];
|
|
132
|
+
/** Settings' search: its tab, and on Roles, `roles=global` for the global roles rather than the project roles. */
|
|
133
|
+
export type SettingsSearch = { tab?: SettingsTab; roles?: 'global' };
|
|
134
|
+
|
|
128
135
|
export const AUDIT_PAGE_SIZE = 200;
|
|
129
136
|
|
|
130
137
|
export const queries = {
|
|
@@ -334,6 +341,8 @@ export const queries = {
|
|
|
334
341
|
decision: search.decision,
|
|
335
342
|
actor: search.actorId,
|
|
336
343
|
detail: search.detail,
|
|
344
|
+
// What 0.15's sealed log alone records too: sign-ins through trust bindings, tokens' issues, revokes and sign-outs.
|
|
345
|
+
sealed: '1',
|
|
337
346
|
}),
|
|
338
347
|
),
|
|
339
348
|
}),
|
|
@@ -371,19 +380,57 @@ export const queries = {
|
|
|
371
380
|
* checked as a chain, so for them it is a fact about the page, not a fault.
|
|
372
381
|
*/
|
|
373
382
|
async function verifyChain(client: CoffreClient) {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
383
|
+
const [chain, trees] = await Promise.allSettled([client.audit.verify(), client.audit.verifyTrees()]);
|
|
384
|
+
if (chain.status === 'rejected') return chainUnknown(chain.reason);
|
|
385
|
+
return withTrees(chain.value, false, trees);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* 0.14's verdict with 0.15's check beside it, each settled apart: a check
|
|
390
|
+
* of 0.15's log that could not run says so beside 0.14's verdict, never in
|
|
391
|
+
* its place, on a visit and after a walk alike.
|
|
392
|
+
*/
|
|
393
|
+
export function withTrees(chain: Awaited<ReturnType<CoffreClient['audit']['verify']>>, whole: boolean, trees: PromiseSettledResult<TreesResult>) {
|
|
394
|
+
if (trees.status === 'fulfilled') return chainResult(chain, whole, trees.value);
|
|
395
|
+
// Whatever turned it away, a refusal included (access narrowed between the two, review r11): not checked, never "Verified".
|
|
396
|
+
const failed = chainUnknown(trees.reason);
|
|
397
|
+
const problem = failed.integrity === 'unknown' ? failed.problem : 'the request was refused (HTTP 403)';
|
|
398
|
+
return { ...chainResult(chain, whole), ...(chain.ok ? { treesFailed: `coffre could not check the sealed log: ${problem}` } : {}) };
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/** 0.15's log as its check found it (`audit.verifyTrees`): `kept` false where the instance keeps 0.14's alone. */
|
|
402
|
+
export type TreesResult = Awaited<ReturnType<CoffreClient['audit']['verifyTrees']>>;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* 0.15's log checked whole, as a walk from the first entry has it: its trees
|
|
406
|
+
* from the newest checkpoint, and the reads the pages list held to the uses
|
|
407
|
+
* it sealed (`audit.verifyReads`, T166), whose problems are the log's.
|
|
408
|
+
*/
|
|
409
|
+
export async function wholeTrees(client: CoffreClient): Promise<TreesResult> {
|
|
410
|
+
const [trees, reads] = await Promise.all([client.audit.verifyTrees(), client.audit.verifyReads()]);
|
|
411
|
+
if (!trees.kept || !reads.kept || reads.ok) return trees;
|
|
412
|
+
return { ...trees, ok: false, problems: [...trees.problems, ...reads.problems.map((problem) => `the reads' listing: ${problem}`)] };
|
|
379
413
|
}
|
|
380
414
|
|
|
381
415
|
/**
|
|
382
416
|
* A verdict as the page shows it: `whole` when it comes from the walk
|
|
383
417
|
* from the first entry, which someone asked for, not from the newest
|
|
384
|
-
* checkpoint's.
|
|
418
|
+
* checkpoint's. Where the instance keeps 0.15's log too, its check
|
|
419
|
+
* (`trees`) is part of it: what it finds breaks the log as 0.14's would.
|
|
385
420
|
*/
|
|
386
|
-
export function chainResult(result: Awaited<ReturnType<CoffreClient['audit']['verify']>>, whole: boolean) {
|
|
421
|
+
export function chainResult(result: Awaited<ReturnType<CoffreClient['audit']['verify']>>, whole: boolean, trees: TreesResult = { kept: false }) {
|
|
422
|
+
// More entries above the newest checkpoint than a check reads: a checkpointer behind, not a break (review r4 of W240).
|
|
423
|
+
const behind = trees.kept && trees.capped;
|
|
424
|
+
if (result.ok && trees.kept && trees.problems.length > 0) {
|
|
425
|
+
const more = trees.problems.length - 1;
|
|
426
|
+
return {
|
|
427
|
+
integrity: 'broken' as const,
|
|
428
|
+
through: result.through,
|
|
429
|
+
failedAtSeq: null,
|
|
430
|
+
author: 'vault' as const,
|
|
431
|
+
reason: `the sealed log: ${trees.problems[0]}${more > 0 ? ` (and ${more} more)` : ''}`,
|
|
432
|
+
};
|
|
433
|
+
}
|
|
387
434
|
return result.ok
|
|
388
435
|
? {
|
|
389
436
|
integrity: 'intact' as const,
|
|
@@ -395,6 +442,17 @@ export function chainResult(result: Awaited<ReturnType<CoffreClient['audit']['ve
|
|
|
395
442
|
remaining: result.remaining ?? 0,
|
|
396
443
|
checkpoint: result.checkpoint,
|
|
397
444
|
pending: result.pending ?? 0,
|
|
445
|
+
/**
|
|
446
|
+
* Why the check of 0.15's log could not run, or stopped short of its head (`treesBehind`): the chain's verdict
|
|
447
|
+
* stands, the sealed log's is not known.
|
|
448
|
+
*/
|
|
449
|
+
treesFailed: behind
|
|
450
|
+
? `coffre checked the sealed log's first ${trees.unsealed.toLocaleString('en')} entries above its newest checkpoint, not the rest: the checkpointer is behind`
|
|
451
|
+
: (null as string | null),
|
|
452
|
+
/** The sealed log checked, but not to its head: more entries wait above its newest checkpoint than a check reads. */
|
|
453
|
+
treesBehind: behind,
|
|
454
|
+
/** 0.15's log, where it is kept: the newest pair its check reached. */
|
|
455
|
+
trees: trees.kept ? { checkpoint: trees.checkpoint, pending: trees.capped ? trees.unsealed : 0 } : null,
|
|
398
456
|
}
|
|
399
457
|
: {
|
|
400
458
|
integrity: 'broken' as const,
|
|
@@ -413,13 +471,17 @@ export function chainResult(result: Awaited<ReturnType<CoffreClient['audit']['ve
|
|
|
413
471
|
* log whole too does the walk's verdict, which read further back, stand
|
|
414
472
|
* over it.
|
|
415
473
|
*
|
|
416
|
-
* whole broken
|
|
417
|
-
* whole intact, quick intact
|
|
418
|
-
* whole intact, quick anything else
|
|
474
|
+
* whole broken → whole
|
|
475
|
+
* whole intact, quick intact, 0 remaining, sealed log checked → whole
|
|
476
|
+
* whole intact, quick anything else → quick
|
|
477
|
+
*
|
|
478
|
+
* A newer check that could not check the sealed log (review r10) is
|
|
479
|
+
* "anything else": the walk's seal would stand over a log nobody can now
|
|
480
|
+
* say holds.
|
|
419
481
|
*/
|
|
420
482
|
export function shownChain(quick: ChainResult, whole: ChainResult | null): ChainResult {
|
|
421
483
|
if (whole === null || whole.integrity === 'broken') return whole ?? quick;
|
|
422
|
-
return quick.integrity === 'intact' && quick.remaining === 0 && whole.integrity === 'intact' ? whole : quick;
|
|
484
|
+
return quick.integrity === 'intact' && quick.remaining === 0 && quick.treesFailed === null && whole.integrity === 'intact' ? whole : quick;
|
|
423
485
|
}
|
|
424
486
|
|
|
425
487
|
/** Why the log's verdict is not known: closed to the caller, or no answer. */
|
|
@@ -569,14 +631,16 @@ export async function loadDirectory(queryClient: QueryClient, client: CoffreClie
|
|
|
569
631
|
}
|
|
570
632
|
|
|
571
633
|
/** The instance's settings: the directory's counts, where people set up service accounts, and what its keys are checked against. */
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
await
|
|
575
|
-
|
|
576
|
-
queryClient.fetchQuery(queries.settings(client,
|
|
577
|
-
|
|
578
|
-
queryClient.fetchQuery(queries.
|
|
579
|
-
|
|
634
|
+
/** What a tab of Settings reads, its own alone: General the directory and the instance's settings, Roles the roles, project and global alike, Keys the key checks. */
|
|
635
|
+
export async function loadSettings(queryClient: QueryClient, client: CoffreClient, tab: SettingsTab | undefined) {
|
|
636
|
+
const { capabilities } = await loadShell(queryClient, client);
|
|
637
|
+
if (tab === undefined) {
|
|
638
|
+
await Promise.all([loadDirectory(queryClient, client), queryClient.fetchQuery(queries.settings(client, capabilities.runsInstance))]);
|
|
639
|
+
} else if (tab === 'keys') {
|
|
640
|
+
await queryClient.fetchQuery(queries.auditKeys(client, capabilities.runsInstance));
|
|
641
|
+
} else {
|
|
642
|
+
await queryClient.fetchQuery(queries.roles(client));
|
|
643
|
+
}
|
|
580
644
|
}
|
|
581
645
|
|
|
582
646
|
/** Whether the Service accounts page lists anyone: to admins and owners, and to whoever sets one up, those they manage. */
|