@coffre/ui 0.14.4 → 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 +24 -19
- 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
package/dist/pages/settings.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ErrorLine, c as Notice, f as Toggletip, l as Spinner, n as ConfirmDialog, s as Modal } from "../chunks/ui-
|
|
3
|
-
import { G as Plus,
|
|
4
|
-
import { t as useShell } from "../chunks/use-shell-
|
|
5
|
-
import {
|
|
6
|
-
import { n as
|
|
7
|
-
import {
|
|
1
|
+
import { n as affects, x as queries } from "../chunks/queries-D1JuimTu.js";
|
|
2
|
+
import { a as ErrorLine, c as Notice, f as Toggletip, l as Spinner, n as ConfirmDialog, s as Modal } from "../chunks/ui-CGdORVzW.js";
|
|
3
|
+
import { G as Pencil, J as RotateBack, K as Plus, M as Info, N as Key, R as Lock, X as Settings, Z as ShieldCheck, _ as Check, i as PageHeader, r as Fact, rt as Trash, t as Card, u as useCoffre } from "../chunks/page-CfhC9Hp1.js";
|
|
4
|
+
import { t as useShell } from "../chunks/use-shell-CPskgi1k.js";
|
|
5
|
+
import { t as PageTabs } from "../chunks/tabs-BmwKfUeK.js";
|
|
6
|
+
import { a as columnInWords, c as ordered, d as reachOf, f as roleIdFrom, g as toggle, h as sameDefinition, i as PERMISSION_WORDS, l as projectWide, n as CARD_ROWS, o as impactExamples, p as roleIdProblem, r as GRID_PERMISSIONS, s as impactInWords } from "../chunks/use-roles-BZnJ9Cq0.js";
|
|
7
|
+
import { n as ScopeField } from "../chunks/role-field-CoCv8wse.js";
|
|
8
|
+
import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
|
|
9
|
+
import { t as useAction } from "../chunks/use-action-BxrHTBZw.js";
|
|
8
10
|
import { useId, useRef, useState } from "react";
|
|
9
11
|
import { Link } from "@tanstack/react-router";
|
|
10
12
|
import { toast } from "sonner";
|
|
@@ -13,90 +15,131 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
|
13
15
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
|
14
16
|
import { CoffreError } from "@coffre/client";
|
|
15
17
|
//#region src/components/role-editor.tsx
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* The instance's project roles, or its global roles (instance roles, in
|
|
20
|
+
* the code and the API): a card each, which opens its editor, under what
|
|
21
|
+
* switches between the two.
|
|
22
|
+
*/
|
|
23
|
+
function RolesSettings({ kind, switcher }) {
|
|
18
24
|
const { data } = useSuspenseQuery(queries.roles(useCoffre()));
|
|
19
|
-
if (!data.ok) return /* @__PURE__ */ jsx(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(RoleList, {
|
|
28
|
-
kind: "role",
|
|
29
|
-
roles: data.roles,
|
|
30
|
-
editable: data.editable
|
|
31
|
-
}), /* @__PURE__ */ jsx(RoleList, {
|
|
32
|
-
kind: "instance-role",
|
|
33
|
-
roles: data.instanceRoles,
|
|
34
|
-
editable: data.editable
|
|
35
|
-
})] });
|
|
25
|
+
if (!data.ok) return /* @__PURE__ */ jsx(ErrorLine, { error: `The roles could not be read. ${data.error}` });
|
|
26
|
+
return /* @__PURE__ */ jsx(RoleList, {
|
|
27
|
+
kind,
|
|
28
|
+
roles: kind === "role" ? data.roles : data.instanceRoles,
|
|
29
|
+
editable: data.editable,
|
|
30
|
+
switcher
|
|
31
|
+
}, kind);
|
|
36
32
|
}
|
|
37
|
-
function RoleList({ kind, roles, editable }) {
|
|
33
|
+
function RoleList({ kind, roles, editable, switcher }) {
|
|
38
34
|
const [open, setOpen] = useState(null);
|
|
39
35
|
const project = kind === "role";
|
|
40
36
|
const opened = open === null || "making" in open ? null : roles.find((role) => role.id === open.role);
|
|
41
|
-
return /* @__PURE__ */ jsxs(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
38
|
+
/* @__PURE__ */ jsxs("div", {
|
|
39
|
+
className: "section-actions",
|
|
40
|
+
children: [switcher, project && editable && /* @__PURE__ */ jsxs("button", {
|
|
41
|
+
className: "btn",
|
|
42
|
+
type: "button",
|
|
43
|
+
onClick: () => setOpen({ making: true }),
|
|
44
|
+
children: [/* @__PURE__ */ jsx(Plus, { size: 14 }), "New role"]
|
|
45
|
+
})]
|
|
50
46
|
}),
|
|
51
|
-
|
|
52
|
-
className: "
|
|
53
|
-
"
|
|
47
|
+
/* @__PURE__ */ jsxs("div", {
|
|
48
|
+
className: "roles-desc",
|
|
49
|
+
children: [/* @__PURE__ */ jsx("p", { children: project ? "Granted on a project or environment; a person or service account can hold several." : "One per person, across every project in its scope; assigned on Users." }), roles.some((role) => GRID_PERMISSIONS.some((permission) => reachOf(role, permission) === "unprotected")) && /* @__PURE__ */ jsxs("p", {
|
|
50
|
+
className: "role-legend",
|
|
51
|
+
"aria-hidden": true,
|
|
52
|
+
children: [/* @__PURE__ */ jsx(Lock, { size: 12 }), "Not in protected environments"]
|
|
53
|
+
})]
|
|
54
|
+
}),
|
|
55
|
+
/* @__PURE__ */ jsx("ul", {
|
|
56
|
+
className: "role-cards",
|
|
57
|
+
"aria-label": project ? "Project roles" : "Global roles",
|
|
54
58
|
children: roles.map((role) => /* @__PURE__ */ jsxs("li", {
|
|
55
|
-
className: "
|
|
56
|
-
children: [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
/* @__PURE__ */
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
role.description
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"aria-label": `${editable && !role.fixed ? "Edit" : "View"} ${role.name}`,
|
|
81
|
-
onClick: () => setOpen({ role: role.id }),
|
|
82
|
-
children: [editable && !role.fixed && /* @__PURE__ */ jsx(Pencil, { size: 14 }), editable && !role.fixed ? "Edit…" : "View"]
|
|
83
|
-
})]
|
|
84
|
-
})]
|
|
59
|
+
className: "role-card",
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ jsxs("p", {
|
|
62
|
+
className: "role-card-title",
|
|
63
|
+
children: [role.name, /* @__PURE__ */ jsx(RoleBadges, { role })]
|
|
64
|
+
}),
|
|
65
|
+
!role.builtin && role.description !== "" && /* @__PURE__ */ jsx("p", {
|
|
66
|
+
className: "role-card-desc",
|
|
67
|
+
children: role.description
|
|
68
|
+
}),
|
|
69
|
+
/* @__PURE__ */ jsx(RoleReach, { role }),
|
|
70
|
+
/* @__PURE__ */ jsxs("div", {
|
|
71
|
+
className: "role-card-foot",
|
|
72
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
73
|
+
className: "role-card-count",
|
|
74
|
+
children: held(kind, role.grants)
|
|
75
|
+
}), /* @__PURE__ */ jsxs("button", {
|
|
76
|
+
className: "btn btn-sm",
|
|
77
|
+
type: "button",
|
|
78
|
+
"aria-label": `${editable && !role.fixed ? "Edit" : "View"} ${role.name}`,
|
|
79
|
+
onClick: () => setOpen({ role: role.id }),
|
|
80
|
+
children: [editable && !role.fixed && /* @__PURE__ */ jsx(Pencil, { size: 14 }), editable && !role.fixed ? "Edit…" : "View"]
|
|
81
|
+
})]
|
|
82
|
+
})
|
|
83
|
+
]
|
|
85
84
|
}, role.id))
|
|
86
|
-
}),
|
|
85
|
+
}),
|
|
86
|
+
open !== null && opened !== void 0 && /* @__PURE__ */ jsx(RoleEditor, {
|
|
87
87
|
kind,
|
|
88
88
|
role: opened,
|
|
89
89
|
roles,
|
|
90
90
|
editable: editable && (opened === null || !opened.fixed),
|
|
91
91
|
onClose: () => setOpen(null)
|
|
92
|
-
}, "making" in open ? "" : `role:${open.role}`)
|
|
93
|
-
});
|
|
92
|
+
}, "making" in open ? "" : `role:${open.role}`)
|
|
93
|
+
] });
|
|
94
94
|
}
|
|
95
95
|
/** "3 grants", "1 person": who a role reaches now. */
|
|
96
96
|
function held(kind, count) {
|
|
97
97
|
if (kind === "instance-role") return count === 0 ? "Nobody" : count === 1 ? "1 person" : `${count} people`;
|
|
98
98
|
return count === 0 ? "No grants" : count === 1 ? "1 grant" : `${count} grants`;
|
|
99
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* What a role can do, on its card: every permission, in the same place on
|
|
102
|
+
* every card, held ones solid, the others a dashed outline, and a lock on
|
|
103
|
+
* one it holds only outside protected environments. A screen reader hears
|
|
104
|
+
* each in full: "Read values: yes, except in protected environments".
|
|
105
|
+
*/
|
|
106
|
+
function RoleReach({ role }) {
|
|
107
|
+
return /* @__PURE__ */ jsx("dl", {
|
|
108
|
+
className: "role-reach",
|
|
109
|
+
children: CARD_ROWS.map((row) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", { children: row.name }), /* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx("ul", {
|
|
110
|
+
role: "list",
|
|
111
|
+
children: row.permissions.map((permission) => {
|
|
112
|
+
const reach = reachOf(role, permission);
|
|
113
|
+
const { label, short } = PERMISSION_WORDS[permission];
|
|
114
|
+
const words = reach === "nowhere" ? "no" : reach === "unprotected" ? "yes, except in protected environments" : "yes";
|
|
115
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
116
|
+
className: `role-perm role-perm-${reach}`,
|
|
117
|
+
title: reach === "unprotected" ? `${label}, not in protected environments` : label,
|
|
118
|
+
children: [
|
|
119
|
+
/* @__PURE__ */ jsxs("span", {
|
|
120
|
+
className: "role-perm-shown",
|
|
121
|
+
"aria-hidden": true,
|
|
122
|
+
children: [short, reach === "unprotected" && /* @__PURE__ */ jsx(Lock, { size: 11 })]
|
|
123
|
+
}),
|
|
124
|
+
/* @__PURE__ */ jsxs("span", {
|
|
125
|
+
className: "role-perm-widest",
|
|
126
|
+
"aria-hidden": true,
|
|
127
|
+
children: [short, !projectWide(permission) && /* @__PURE__ */ jsx(Lock, { size: 11 })]
|
|
128
|
+
}),
|
|
129
|
+
/* @__PURE__ */ jsxs("span", {
|
|
130
|
+
className: "visually-hidden",
|
|
131
|
+
children: [
|
|
132
|
+
label,
|
|
133
|
+
": ",
|
|
134
|
+
words
|
|
135
|
+
]
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
}, permission);
|
|
139
|
+
})
|
|
140
|
+
}) })] }, row.name))
|
|
141
|
+
});
|
|
142
|
+
}
|
|
100
143
|
/** Where a role comes from, and whether it is as it shipped. */
|
|
101
144
|
function RoleBadges({ role }) {
|
|
102
145
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
@@ -357,7 +400,7 @@ function RoleEditor({ kind, role, roles, editable, onClose }) {
|
|
|
357
400
|
}),
|
|
358
401
|
editable && /* @__PURE__ */ jsxs("p", {
|
|
359
402
|
className: "hint",
|
|
360
|
-
children: ["Reading takes using, and a protected environment holds no more than any other: the boxes keep both true.", instance ? "
|
|
403
|
+
children: ["Reading takes using, and a protected environment holds no more than any other: the boxes keep both true.", instance ? " A global role reaches every project its holder’s scope takes in." : ""]
|
|
361
404
|
}),
|
|
362
405
|
role !== null && role.edited && /* @__PURE__ */ jsxs(Notice, {
|
|
363
406
|
tone: "info",
|
|
@@ -582,70 +625,132 @@ function RoleGrid({ name, columns, editable, onChange }) {
|
|
|
582
625
|
}
|
|
583
626
|
//#endregion
|
|
584
627
|
//#region src/pages/settings.tsx
|
|
585
|
-
|
|
628
|
+
var Route = pageRoute();
|
|
629
|
+
/**
|
|
630
|
+
* The instance's settings, a tab each: General, the instance and who
|
|
631
|
+
* creates service accounts; Roles, the project roles or the global ones;
|
|
632
|
+
* Keys, for whoever runs the instance. Your own settings are under
|
|
633
|
+
* Account, at the sidebar's foot.
|
|
634
|
+
*/
|
|
586
635
|
function SettingsPage() {
|
|
636
|
+
const { tab, roles } = Route.useSearch();
|
|
637
|
+
const { capabilities } = useShell();
|
|
638
|
+
const current = {
|
|
639
|
+
exact: true,
|
|
640
|
+
includeSearch: true
|
|
641
|
+
};
|
|
642
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
643
|
+
/* @__PURE__ */ jsx(PageHeader, { title: "Settings" }),
|
|
644
|
+
/* @__PURE__ */ jsx(PageTabs, {
|
|
645
|
+
label: "Settings sections",
|
|
646
|
+
children: [
|
|
647
|
+
/* @__PURE__ */ jsxs(Link, {
|
|
648
|
+
to: "/settings",
|
|
649
|
+
search: {},
|
|
650
|
+
activeOptions: current,
|
|
651
|
+
children: [/* @__PURE__ */ jsx(Settings, { size: 15 }), "General"]
|
|
652
|
+
}, "general"),
|
|
653
|
+
/* @__PURE__ */ jsxs(Link, {
|
|
654
|
+
to: "/settings",
|
|
655
|
+
search: { tab: "roles" },
|
|
656
|
+
activeOptions: { includeSearch: true },
|
|
657
|
+
children: [/* @__PURE__ */ jsx(ShieldCheck, { size: 15 }), "Roles"]
|
|
658
|
+
}, "roles"),
|
|
659
|
+
capabilities.runsInstance && /* @__PURE__ */ jsxs(Link, {
|
|
660
|
+
to: "/settings",
|
|
661
|
+
search: { tab: "keys" },
|
|
662
|
+
activeOptions: current,
|
|
663
|
+
children: [/* @__PURE__ */ jsx(Key, { size: 15 }), "Keys"]
|
|
664
|
+
}, "keys")
|
|
665
|
+
]
|
|
666
|
+
}),
|
|
667
|
+
tab === void 0 ? /* @__PURE__ */ jsx(General, {}) : tab === "keys" ? /* @__PURE__ */ jsx(KeysTab, {}) : /* @__PURE__ */ jsx(RolesSettings, {
|
|
668
|
+
kind: roles === "global" ? "instance-role" : "role",
|
|
669
|
+
switcher: /* @__PURE__ */ jsxs("nav", {
|
|
670
|
+
className: "segmented",
|
|
671
|
+
"aria-label": "Roles",
|
|
672
|
+
children: [/* @__PURE__ */ jsx(Link, {
|
|
673
|
+
to: "/settings",
|
|
674
|
+
search: { tab: "roles" },
|
|
675
|
+
activeOptions: current,
|
|
676
|
+
children: "Project roles"
|
|
677
|
+
}), /* @__PURE__ */ jsx(Link, {
|
|
678
|
+
to: "/settings",
|
|
679
|
+
search: {
|
|
680
|
+
tab: "roles",
|
|
681
|
+
roles: "global"
|
|
682
|
+
},
|
|
683
|
+
activeOptions: current,
|
|
684
|
+
children: "Global roles"
|
|
685
|
+
})]
|
|
686
|
+
})
|
|
687
|
+
})
|
|
688
|
+
] });
|
|
689
|
+
}
|
|
690
|
+
/** The instance, as its deployment set it up, and who creates service accounts. */
|
|
691
|
+
function General() {
|
|
587
692
|
const { auth, capabilities } = useShell();
|
|
588
693
|
const client = useCoffre();
|
|
589
694
|
const { data: directory } = useSuspenseQuery(queries.directory(client, capabilities.canManageGrants));
|
|
590
|
-
const { data: keys } = useSuspenseQuery(queries.auditKeys(client, capabilities.runsInstance));
|
|
591
695
|
const { data: settings } = useSuspenseQuery(queries.settings(client, capabilities.runsInstance));
|
|
592
696
|
const providers = auth?.signin?.providers.map((provider) => provider.label) ?? [];
|
|
593
697
|
const principals = directory?.ok === true ? directory.principals : null;
|
|
594
698
|
const users = principals?.filter((entry) => entry.principalType === "user").length ?? 0;
|
|
595
699
|
const tokens = principals?.filter((entry) => entry.principalType === "service").length ?? 0;
|
|
596
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
children: /* @__PURE__ */
|
|
603
|
-
|
|
604
|
-
children: [/* @__PURE__ */ jsx(
|
|
605
|
-
label: "
|
|
606
|
-
children: /* @__PURE__ */
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
})
|
|
638
|
-
}),
|
|
639
|
-
/* @__PURE__ */ jsx(RolesSettings, {}),
|
|
640
|
-
settings?.ok === true && /* @__PURE__ */ jsx(ServiceSetup, { scope: settings.serviceAccounts }),
|
|
641
|
-
keys?.ok === true && /* @__PURE__ */ jsx(Keys, { keys })
|
|
642
|
-
] });
|
|
700
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Card, {
|
|
701
|
+
labelledBy: "instance",
|
|
702
|
+
title: "Instance",
|
|
703
|
+
description: "Set in the deployment's configuration, not here.",
|
|
704
|
+
children: /* @__PURE__ */ jsxs("dl", {
|
|
705
|
+
className: "facts",
|
|
706
|
+
children: [/* @__PURE__ */ jsx(Fact, {
|
|
707
|
+
label: "Sign-in",
|
|
708
|
+
children: /* @__PURE__ */ jsxs("span", { children: [auth?.signin ? providers.join(", ") : "Cloudflare Access", /* @__PURE__ */ jsx(Toggletip, {
|
|
709
|
+
label: auth?.signin ? "coffre’s own sign-in. Only invited members get in." : "Cloudflare Access signs people in, and coffre verifies each request.",
|
|
710
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
711
|
+
type: "button",
|
|
712
|
+
className: "fact-tip",
|
|
713
|
+
"aria-label": "About sign-in",
|
|
714
|
+
children: /* @__PURE__ */ jsx(Info, { size: 14 })
|
|
715
|
+
})
|
|
716
|
+
})] })
|
|
717
|
+
}), principals !== null && /* @__PURE__ */ jsx(Fact, {
|
|
718
|
+
label: "Directory",
|
|
719
|
+
children: /* @__PURE__ */ jsxs("span", { children: [
|
|
720
|
+
/* @__PURE__ */ jsxs(Link, {
|
|
721
|
+
to: "/users",
|
|
722
|
+
children: [
|
|
723
|
+
users,
|
|
724
|
+
" user",
|
|
725
|
+
users === 1 ? "" : "s"
|
|
726
|
+
]
|
|
727
|
+
}),
|
|
728
|
+
" · ",
|
|
729
|
+
/* @__PURE__ */ jsxs(Link, {
|
|
730
|
+
to: "/service-accounts",
|
|
731
|
+
children: [
|
|
732
|
+
tokens,
|
|
733
|
+
" service account",
|
|
734
|
+
tokens === 1 ? "" : "s"
|
|
735
|
+
]
|
|
736
|
+
})
|
|
737
|
+
] })
|
|
738
|
+
})]
|
|
739
|
+
})
|
|
740
|
+
}), settings?.ok === true && /* @__PURE__ */ jsx(ServiceSetup, { scope: settings.serviceAccounts })] });
|
|
643
741
|
}
|
|
644
742
|
/**
|
|
645
|
-
* Who
|
|
646
|
-
* holds access, inside this scope, giving one at most what they
|
|
647
|
-
* Narrowed, the rest takes an Admin whose own scope reaches it.
|
|
743
|
+
* Who creates service accounts without running the instance, and where:
|
|
744
|
+
* anyone who holds access, inside this scope, giving one at most what they
|
|
745
|
+
* hold there. Narrowed, the rest takes an Admin whose own scope reaches it.
|
|
648
746
|
*/
|
|
747
|
+
function serviceSetupInWords(scope) {
|
|
748
|
+
if (unscoped(scope)) return "Anyone with access, in every project and environment";
|
|
749
|
+
const { projects, environments } = scope;
|
|
750
|
+
if (projects !== "all" && "only" in projects && projects.only.length === 0 || environments !== "all" && "only" in environments && environments.only.length === 0) return "Admins only";
|
|
751
|
+
const where = scopeInWords(scope);
|
|
752
|
+
return `Anyone with access, in ${where.charAt(0).toLowerCase()}${where.slice(1)}; elsewhere, Admins`;
|
|
753
|
+
}
|
|
649
754
|
function ServiceSetup({ scope }) {
|
|
650
755
|
const client = useCoffre();
|
|
651
756
|
const [open, setOpen] = useState(false);
|
|
@@ -659,24 +764,24 @@ function ServiceSetup({ scope }) {
|
|
|
659
764
|
return /* @__PURE__ */ jsxs(Card, {
|
|
660
765
|
labelledBy: "service-setup",
|
|
661
766
|
title: "Service accounts",
|
|
662
|
-
description: "Anyone who holds access sets up service accounts for CI where this lets them: the account, its tokens and its OIDC trust, giving it at most what they hold. Elsewhere, an Admin whose scope reaches it does.",
|
|
663
|
-
actions: /* @__PURE__ */ jsxs("button", {
|
|
664
|
-
className: "btn",
|
|
665
|
-
type: "button",
|
|
666
|
-
onClick: () => setOpen(true),
|
|
667
|
-
children: [/* @__PURE__ */ jsx(Pencil, { size: 14 }), "Edit"]
|
|
668
|
-
}),
|
|
669
767
|
children: [/* @__PURE__ */ jsx("dl", {
|
|
670
768
|
className: "facts",
|
|
671
769
|
children: /* @__PURE__ */ jsx(Fact, {
|
|
672
|
-
label: "
|
|
673
|
-
|
|
770
|
+
label: "Who creates them",
|
|
771
|
+
action: /* @__PURE__ */ jsxs("button", {
|
|
772
|
+
className: "btn btn-sm",
|
|
773
|
+
type: "button",
|
|
774
|
+
onClick: () => setOpen(true),
|
|
775
|
+
"aria-label": "Edit who creates service accounts",
|
|
776
|
+
children: [/* @__PURE__ */ jsx(Pencil, { size: 14 }), "Edit"]
|
|
777
|
+
}),
|
|
778
|
+
children: /* @__PURE__ */ jsx("span", { children: serviceSetupInWords(scope) })
|
|
674
779
|
})
|
|
675
780
|
}), /* @__PURE__ */ jsx(Modal, {
|
|
676
781
|
open,
|
|
677
782
|
onOpenChange: (next) => next ? setOpen(true) : close(),
|
|
678
|
-
title: "Who
|
|
679
|
-
description: "
|
|
783
|
+
title: "Who creates service accounts",
|
|
784
|
+
description: "Anyone with access creates service accounts in these projects and environments, giving them at most what they hold there; elsewhere, Admins do. All except prod keeps prod's to Admins.",
|
|
680
785
|
children: /* @__PURE__ */ jsxs("form", {
|
|
681
786
|
className: "form",
|
|
682
787
|
onSubmit: (event) => {
|
|
@@ -684,7 +789,7 @@ function ServiceSetup({ scope }) {
|
|
|
684
789
|
run(() => client.settings.set({ serviceAccounts: draft }), {
|
|
685
790
|
affects: affects.settings(),
|
|
686
791
|
onSuccess: () => {
|
|
687
|
-
toast.success("Saved
|
|
792
|
+
toast.success("Saved who creates service accounts");
|
|
688
793
|
setOpen(false);
|
|
689
794
|
setError(null);
|
|
690
795
|
}
|
|
@@ -716,6 +821,26 @@ function ServiceSetup({ scope }) {
|
|
|
716
821
|
})]
|
|
717
822
|
});
|
|
718
823
|
}
|
|
824
|
+
function KeysTab() {
|
|
825
|
+
const { capabilities } = useShell();
|
|
826
|
+
const { data: keys } = useSuspenseQuery(queries.auditKeys(useCoffre(), capabilities.runsInstance));
|
|
827
|
+
if (keys === null) return null;
|
|
828
|
+
return keys.ok ? /* @__PURE__ */ jsx(Keys, { keys }) : /* @__PURE__ */ jsx(ErrorLine, { error: `The keys could not be read. ${keys.error}` });
|
|
829
|
+
}
|
|
830
|
+
/** Where a vault key is kept, in words: the deployment's own, or a key service's. */
|
|
831
|
+
function keptIn(provider) {
|
|
832
|
+
if (provider === "local") return "kept in the deployment's configuration";
|
|
833
|
+
if (provider === "aws-kms") return "kept in AWS KMS";
|
|
834
|
+
return `kept in ${provider}`;
|
|
835
|
+
}
|
|
836
|
+
/** A key's identifier by its end, `…3f9a2c`, enough to tell it from another; the whole of it a hover away. */
|
|
837
|
+
function KeyId({ id }) {
|
|
838
|
+
return /* @__PURE__ */ jsx("span", {
|
|
839
|
+
className: "mono",
|
|
840
|
+
title: id,
|
|
841
|
+
children: id.length <= 8 ? id : `…${id.slice(-6)}`
|
|
842
|
+
});
|
|
843
|
+
}
|
|
719
844
|
/**
|
|
720
845
|
* What the keys you keep are checked against: no secret, so shown. The keys
|
|
721
846
|
* themselves are checked by `coffre verify keys`, on your machine: a vault
|
|
@@ -730,37 +855,32 @@ function Keys({ keys }) {
|
|
|
730
855
|
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
731
856
|
"To check your vault key and app key against these, run ",
|
|
732
857
|
/* @__PURE__ */ jsx("code", { children: "coffre verify keys" }),
|
|
733
|
-
".
|
|
858
|
+
"."
|
|
734
859
|
] }),
|
|
735
860
|
children: /* @__PURE__ */ jsxs("dl", {
|
|
736
861
|
className: "facts",
|
|
737
|
-
children: [
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
/* @__PURE__ */ jsx(Fact, {
|
|
746
|
-
label: "Vault key",
|
|
747
|
-
children: /* @__PURE__ */ jsxs("span", { children: [
|
|
748
|
-
"Held by ",
|
|
749
|
-
/* @__PURE__ */ jsx("span", {
|
|
750
|
-
className: "mono",
|
|
751
|
-
children: current.provider
|
|
752
|
-
}),
|
|
753
|
-
replaced > 0 && `; ${replaced} earlier vault key${replaced === 1 ? "" : "s"} still checkable`
|
|
754
|
-
] })
|
|
755
|
-
}),
|
|
756
|
-
/* @__PURE__ */ jsx(Fact, {
|
|
757
|
-
label: "App key",
|
|
758
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
759
|
-
className: "mono",
|
|
760
|
-
children: keys.app.keyId
|
|
862
|
+
children: [/* @__PURE__ */ jsxs(Fact, {
|
|
863
|
+
label: "Vault key",
|
|
864
|
+
children: [/* @__PURE__ */ jsxs("span", { children: [
|
|
865
|
+
/* @__PURE__ */ jsx(KeyId, { id: current.vaultId }),
|
|
866
|
+
" ",
|
|
867
|
+
/* @__PURE__ */ jsxs("span", {
|
|
868
|
+
className: "muted",
|
|
869
|
+
children: ["· ", keptIn(current.provider)]
|
|
761
870
|
})
|
|
762
|
-
})
|
|
763
|
-
|
|
871
|
+
] }), replaced > 0 && /* @__PURE__ */ jsxs("span", {
|
|
872
|
+
className: "muted",
|
|
873
|
+
children: [
|
|
874
|
+
replaced,
|
|
875
|
+
" earlier vault key",
|
|
876
|
+
replaced === 1 ? "" : "s",
|
|
877
|
+
" still checkable"
|
|
878
|
+
]
|
|
879
|
+
})]
|
|
880
|
+
}), /* @__PURE__ */ jsx(Fact, {
|
|
881
|
+
label: "App key",
|
|
882
|
+
children: /* @__PURE__ */ jsx(KeyId, { id: keys.app.keyId })
|
|
883
|
+
})]
|
|
764
884
|
})
|
|
765
885
|
});
|
|
766
886
|
}
|