@coffre/ui 0.4.6 → 0.5.1
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/{affordances-DAvsVz7u.js → affordances-Bqdevf7w.js} +10 -5
- package/dist/chunks/affordances-Bqdevf7w.js.map +1 -0
- package/dist/chunks/{audit-sentence-DIztXvbU.js → audit-sentence-Cm5nby5k.js} +105 -7
- package/dist/chunks/audit-sentence-Cm5nby5k.js.map +1 -0
- package/dist/chunks/{connected-apps-AZsX9Zvv.js → connected-apps-DTNS7YmY.js} +2 -2
- package/dist/chunks/{connected-apps-AZsX9Zvv.js.map → connected-apps-DTNS7YmY.js.map} +1 -1
- package/dist/chunks/{delete-place-D6LIZkg9.js → delete-place-CIaOq0mt.js} +3 -3
- package/dist/chunks/{delete-place-D6LIZkg9.js.map → delete-place-CIaOq0mt.js.map} +1 -1
- package/dist/chunks/{directory-B6FuiCir.js → directory-DSVt5Tya.js} +54 -60
- package/dist/chunks/directory-DSVt5Tya.js.map +1 -0
- package/dist/chunks/{folders-DvSqBhuu.js → folders-CoGK9oqg.js} +2 -2
- package/dist/chunks/{folders-DvSqBhuu.js.map → folders-CoGK9oqg.js.map} +1 -1
- package/dist/chunks/grants-CRU7yZhL.js +164 -0
- package/dist/chunks/grants-CRU7yZhL.js.map +1 -0
- package/dist/chunks/{offboarding-CLJaNTcD.js → offboarding-DVBSiJRZ.js} +7 -3
- package/dist/chunks/offboarding-DVBSiJRZ.js.map +1 -0
- package/dist/chunks/{principal-page-1yMztIcc.js → principal-page-BEBr_zW7.js} +350 -91
- package/dist/chunks/principal-page-BEBr_zW7.js.map +1 -0
- package/dist/chunks/{project-page-C4cEaRFa.js → project-page-B3TZ5_ig.js} +2 -2
- package/dist/chunks/{project-page-C4cEaRFa.js.map → project-page-B3TZ5_ig.js.map} +1 -1
- package/dist/chunks/{queries-Dew8mIeo.js → queries-DE5nK2y4.js} +132 -54
- package/dist/chunks/queries-DE5nK2y4.js.map +1 -0
- package/dist/chunks/{references-DWDnXNoW.js → references-uv4Mli9z.js} +4 -3
- package/dist/chunks/{references-DWDnXNoW.js.map → references-uv4Mli9z.js.map} +1 -1
- package/dist/chunks/role-field-DWhkRY6n.js +192 -0
- package/dist/chunks/role-field-DWhkRY6n.js.map +1 -0
- package/dist/chunks/use-action-BRgvbUWt.js +49 -0
- package/dist/chunks/use-action-BRgvbUWt.js.map +1 -0
- package/dist/chunks/{use-change-C4bGRhHY.js → use-change-BJ3dCFHb.js} +40 -14
- package/dist/chunks/use-change-BJ3dCFHb.js.map +1 -0
- package/dist/chunks/{use-shell-Dkv89nW1.js → use-shell-BO4ZTr1y.js} +2 -2
- package/dist/chunks/{use-shell-Dkv89nW1.js.map → use-shell-BO4ZTr1y.js.map} +1 -1
- package/dist/chunks/validation-DiHIwZRA.js +37 -0
- package/dist/chunks/validation-DiHIwZRA.js.map +1 -0
- package/dist/index.d.ts +111 -88
- package/dist/index.js +40 -21
- package/dist/index.js.map +1 -1
- package/dist/pages/account.js +8 -7
- package/dist/pages/account.js.map +1 -1
- package/dist/pages/audit.js +2 -2
- package/dist/pages/environment.js +8 -7
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +2 -2
- package/dist/pages/login.js.map +1 -1
- package/dist/pages/project-access.js +7 -7
- package/dist/pages/project-environments.js +26 -21
- package/dist/pages/project-environments.js.map +1 -1
- package/dist/pages/project-settings.js +9 -8
- package/dist/pages/project-settings.js.map +1 -1
- package/dist/pages/project.js +1 -1
- package/dist/pages/projects.js +8 -13
- package/dist/pages/projects.js.map +1 -1
- package/dist/pages/service-account.js +294 -88
- package/dist/pages/service-account.js.map +1 -1
- package/dist/pages/service-accounts.js +7 -7
- package/dist/pages/service-accounts.js.map +1 -1
- package/dist/pages/settings.js +91 -9
- package/dist/pages/settings.js.map +1 -1
- package/dist/pages/unregistered.d.ts +1 -1
- package/dist/pages/unregistered.js +4 -4
- package/dist/pages/unregistered.js.map +1 -1
- package/dist/pages/user.d.ts +2 -0
- package/dist/pages/user.js +21 -3
- package/dist/pages/user.js.map +1 -1
- package/dist/pages/users.js +4 -4
- package/package.json +3 -3
- package/src/components/affordances.ts +7 -3
- package/src/components/command-palette.tsx +2 -0
- package/src/components/directory.tsx +58 -63
- package/src/components/grants.tsx +9 -9
- package/src/components/offboarding.tsx +3 -1
- package/src/components/principal-page.tsx +124 -74
- package/src/components/role-field.tsx +183 -0
- package/src/components/scope-picker.tsx +73 -0
- package/src/components/service-tokens.tsx +20 -9
- package/src/components/shell.tsx +6 -10
- package/src/components/trusted-workloads.tsx +121 -42
- package/src/index.ts +1 -0
- package/src/lib/audit-sentences.ts +104 -3
- package/src/lib/bindings.ts +33 -10
- package/src/lib/capabilities.ts +28 -8
- package/src/lib/changes.ts +22 -13
- package/src/lib/project-access.ts +21 -0
- package/src/lib/queries.ts +121 -44
- package/src/lib/service-setup.ts +41 -0
- package/src/lib/validation.ts +7 -0
- package/src/options.ts +31 -11
- package/src/pages/account.tsx +3 -2
- package/src/pages/login.tsx +1 -1
- package/src/pages/project-environments.tsx +12 -15
- package/src/pages/project-settings.tsx +3 -3
- package/src/pages/projects.tsx +1 -5
- package/src/pages/service-account.tsx +7 -5
- package/src/pages/service-accounts.tsx +8 -4
- package/src/pages/settings.tsx +80 -4
- package/src/pages/unregistered.tsx +3 -3
- package/src/pages/user.tsx +24 -1
- package/src/parity.ts +5 -1
- package/src/register.ts +3 -1
- package/src/shared/models.ts +8 -4
- package/src/styles/globals.css +100 -27
- package/dist/chunks/affordances-DAvsVz7u.js.map +0 -1
- package/dist/chunks/audit-sentence-DIztXvbU.js.map +0 -1
- package/dist/chunks/directory-B6FuiCir.js.map +0 -1
- package/dist/chunks/grants-9kIV6uZ7.js +0 -669
- package/dist/chunks/grants-9kIV6uZ7.js.map +0 -1
- package/dist/chunks/offboarding-CLJaNTcD.js.map +0 -1
- package/dist/chunks/principal-page-1yMztIcc.js.map +0 -1
- package/dist/chunks/queries-Dew8mIeo.js.map +0 -1
- package/dist/chunks/use-change-C4bGRhHY.js.map +0 -1
- package/dist/chunks/validation-DvPinn8V.js +0 -87
- package/dist/chunks/validation-DvPinn8V.js.map +0 -1
- package/src/components/every-project.tsx +0 -287
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unregistered.js","names":[],"sources":["../../src/pages/unregistered.tsx"],"sourcesContent":["import { useShell } from '../lib/use-shell';\n\nimport { ClosedDoor } from '../components/page';\nimport { User } from '../components/icons';\n\n/**\n * Cloudflare Access has authenticated this person, but Coffre has not\n * registered them as a member. Keep this deliberately actionless: registration is\n * an
|
|
1
|
+
{"version":3,"file":"unregistered.js","names":[],"sources":["../../src/pages/unregistered.tsx"],"sourcesContent":["import { useShell } from '../lib/use-shell';\n\nimport { ClosedDoor } from '../components/page';\nimport { User } from '../components/icons';\n\n/**\n * Cloudflare Access has authenticated this person, but Coffre has not\n * registered them as a member. Keep this deliberately actionless: registration is\n * an admin's decision, not a self-service privilege escalation path.\n */\nexport function UnregisteredPage() {\n const { principal, accessTampered } = useShell();\n\n if (accessTampered) {\n return (\n <ClosedDoor icon={<User size={18} />} label=\"Integrity check failed\" title=\"Your access is on hold\">\n <p>\n Your access record\n {principal !== null && (\n <>\n {' '}\n (<span className=\"mono\">{principal.id}</span>)\n </>\n )}{' '}\n was changed outside coffre, so the vault refuses it and you have no access.\n </p>\n <p>To start over, ask a coffre admin to remove you under Users and add you again.</p>\n </ClosedDoor>\n );\n }\n\n return (\n <ClosedDoor\n icon={<User size={18} />}\n label=\"Registration required\"\n title=\"You are not a member yet\"\n >\n <p>\n Cloudflare Access knows who you are\n {principal !== null && (\n <>\n {' '}\n (<span className=\"mono\">{principal.id}</span>)\n </>\n )}\n , but coffre has not added you.\n </p>\n <p>\n Ask a coffre admin or root admin to add your Access email under Users.\n </p>\n </ClosedDoor>\n );\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,mBAAmB;CACjC,MAAM,EAAE,WAAW,mBAAmB,SAAS;CAE/C,IAAI,gBACF,OACE,qBAAC,YAAD;EAAY,MAAM,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;EAAG,OAAM;EAAyB,OAAM;YAA3E,CACE,qBAAC,KAAD,EAAA,UAAA;GAAG;GAEA,cAAc,QACb,qBAAA,UAAA,EAAA,UAAA;IACG;IAAI;IACJ,oBAAC,QAAD;KAAM,WAAU;eAAQ,UAAU;IAAS,CAAA;IAAC;GAC7C,EAAA,CAAA;GACD;GAAI;EAEN,EAAA,CAAA,GACH,oBAAC,KAAD,EAAA,UAAG,iFAAiF,CAAA,CAC1E;;CAIhB,OACE,qBAAC,YAAD;EACE,MAAM,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;EACvB,OAAM;EACN,OAAM;YAHR,CAKE,qBAAC,KAAD,EAAA,UAAA;GAAG;GAEA,cAAc,QACb,qBAAA,UAAA,EAAA,UAAA;IACG;IAAI;IACJ,oBAAC,QAAD;KAAM,WAAU;eAAQ,UAAU;IAAS,CAAA;IAAC;GAC7C,EAAA,CAAA;GACF;EAED,EAAA,CAAA,GACH,oBAAC,KAAD,EAAA,UAAG,yEAEA,CAAA,CACO;;AAEhB"}
|
package/dist/pages/user.d.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
export declare function UserLayout(): import("react").JSX.Element;
|
|
4
4
|
/** Their first tab: their access, or once removed, their offboarding. */
|
|
5
5
|
export declare function UserAccessPage(): import("react").JSX.Element;
|
|
6
|
+
/** The MCP clients they connected, for an owner, who may disconnect any of them. */
|
|
7
|
+
export declare function UserAppsPage(): import("react").JSX.Element | null;
|
|
6
8
|
/** Everything they did, from the audit log. */
|
|
7
9
|
export declare function UserActivityPage(): import("react").JSX.Element;
|
|
8
10
|
//#endregion
|
package/dist/pages/user.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { s as memberRef } from "../chunks/page-DvsgZ2Hd.js";
|
|
1
|
+
import { s as memberRef, u as useCoffre } from "../chunks/page-DvsgZ2Hd.js";
|
|
2
|
+
import { g as queries } from "../chunks/queries-DE5nK2y4.js";
|
|
3
|
+
import { t as useShell } from "../chunks/use-shell-BO4ZTr1y.js";
|
|
4
|
+
import { d as disconnectMemberApp } from "../chunks/use-change-BJ3dCFHb.js";
|
|
5
|
+
import { t as ConnectedAppsCard } from "../chunks/connected-apps-DTNS7YmY.js";
|
|
2
6
|
import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
|
|
3
|
-
import { n as PrincipalLayout, r as ActionsLog, t as PrincipalAccess } from "../chunks/principal-page-
|
|
7
|
+
import { n as PrincipalLayout, r as ActionsLog, t as PrincipalAccess } from "../chunks/principal-page-BEBr_zW7.js";
|
|
4
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { useSuspenseQuery } from "@tanstack/react-query";
|
|
5
10
|
//#region src/pages/user.tsx
|
|
6
11
|
var Route = pageRoute();
|
|
7
12
|
/** A user's page, around its tabs. */
|
|
@@ -18,11 +23,24 @@ function UserAccessPage() {
|
|
|
18
23
|
principalId: Route.useParams().user
|
|
19
24
|
});
|
|
20
25
|
}
|
|
26
|
+
/** The MCP clients they connected, for an owner, who may disconnect any of them. */
|
|
27
|
+
function UserAppsPage() {
|
|
28
|
+
const client = useCoffre();
|
|
29
|
+
const member = memberRef("user", Route.useParams().user);
|
|
30
|
+
const { data: report } = useSuspenseQuery(queries.report(client, member, useShell().capabilities.runsInstance));
|
|
31
|
+
if (report?.ok !== true || report.report === null) return null;
|
|
32
|
+
return /* @__PURE__ */ jsx(ConnectedAppsCard, {
|
|
33
|
+
apps: report.report.apps,
|
|
34
|
+
change: disconnectMemberApp(client, member),
|
|
35
|
+
description: "AI assistants and other MCP clients they connected. Removing them from coffre disconnects every one.",
|
|
36
|
+
empty: "They have connected none."
|
|
37
|
+
});
|
|
38
|
+
}
|
|
21
39
|
/** Everything they did, from the audit log. */
|
|
22
40
|
function UserActivityPage() {
|
|
23
41
|
return /* @__PURE__ */ jsx(ActionsLog, { member: memberRef("user", Route.useParams().user) });
|
|
24
42
|
}
|
|
25
43
|
//#endregion
|
|
26
|
-
export { UserAccessPage, UserActivityPage, UserLayout };
|
|
44
|
+
export { UserAccessPage, UserActivityPage, UserAppsPage, UserLayout };
|
|
27
45
|
|
|
28
46
|
//# sourceMappingURL=user.js.map
|
package/dist/pages/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","names":[],"sources":["../../src/pages/user.tsx"],"sourcesContent":["import { ActionsLog } from '../components/actions-log';\nimport { PrincipalAccess, PrincipalLayout } from '../components/principal-page';\nimport { memberRef } from '../lib/coffre';\nimport { pageRoute } from '../lib/page-route';\nimport type { user } from '../options';\n\nconst Route = pageRoute<typeof user>();\n\n/** A user's page, around its tabs. */\nexport function UserLayout() {\n return <PrincipalLayout principalType=\"user\" principalId={Route.useParams().user} />;\n}\n\n/** Their first tab: their access, or once removed, their offboarding. */\nexport function UserAccessPage() {\n return <PrincipalAccess principalType=\"user\" principalId={Route.useParams().user} />;\n}\n\n/** Everything they did, from the audit log. */\nexport function UserActivityPage() {\n return <ActionsLog member={memberRef('user', Route.useParams().user)} />;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"user.js","names":[],"sources":["../../src/pages/user.tsx"],"sourcesContent":["import { useSuspenseQuery } from '@tanstack/react-query';\n\nimport { ActionsLog } from '../components/actions-log';\nimport { ConnectedAppsCard } from '../components/connected-apps';\nimport { PrincipalAccess, PrincipalLayout } from '../components/principal-page';\nimport { disconnectMemberApp } from '../lib/changes';\nimport { memberRef, useCoffre } from '../lib/coffre';\nimport { pageRoute } from '../lib/page-route';\nimport { queries } from '../lib/queries';\nimport { useShell } from '../lib/use-shell';\nimport type { user } from '../options';\n\nconst Route = pageRoute<typeof user>();\n\n/** A user's page, around its tabs. */\nexport function UserLayout() {\n return <PrincipalLayout principalType=\"user\" principalId={Route.useParams().user} />;\n}\n\n/** Their first tab: their access, or once removed, their offboarding. */\nexport function UserAccessPage() {\n return <PrincipalAccess principalType=\"user\" principalId={Route.useParams().user} />;\n}\n\n/** The MCP clients they connected, for an owner, who may disconnect any of them. */\nexport function UserAppsPage() {\n const client = useCoffre();\n const member = memberRef('user', Route.useParams().user);\n const { data: report } = useSuspenseQuery(queries.report(client, member, useShell().capabilities.runsInstance));\n // Their layout says why there is no report.\n if (report?.ok !== true || report.report === null) return null;\n return (\n <ConnectedAppsCard\n apps={report.report.apps}\n change={disconnectMemberApp(client, member)}\n description=\"AI assistants and other MCP clients they connected. Removing them from coffre disconnects every one.\"\n empty=\"They have connected none.\"\n />\n );\n}\n\n/** Everything they did, from the audit log. */\nexport function UserActivityPage() {\n return <ActionsLog member={memberRef('user', Route.useParams().user)} />;\n}\n"],"mappings":";;;;;;;;;;AAYA,IAAM,QAAQ,UAAuB;;AAGrC,SAAgB,aAAa;CAC3B,OAAO,oBAAC,iBAAD;EAAiB,eAAc;EAAO,aAAa,MAAM,UAAU,CAAC,CAAC;CAAO,CAAA;AACrF;;AAGA,SAAgB,iBAAiB;CAC/B,OAAO,oBAAC,iBAAD;EAAiB,eAAc;EAAO,aAAa,MAAM,UAAU,CAAC,CAAC;CAAO,CAAA;AACrF;;AAGA,SAAgB,eAAe;CAC7B,MAAM,SAAS,UAAU;CACzB,MAAM,SAAS,UAAU,QAAQ,MAAM,UAAU,CAAC,CAAC,IAAI;CACvD,MAAM,EAAE,MAAM,WAAW,iBAAiB,QAAQ,OAAO,QAAQ,QAAQ,SAAS,CAAC,CAAC,aAAa,YAAY,CAAC;CAE9G,IAAI,QAAQ,OAAO,QAAQ,OAAO,WAAW,MAAM,OAAO;CAC1D,OACE,oBAAC,mBAAD;EACE,MAAM,OAAO,OAAO;EACpB,QAAQ,oBAAoB,QAAQ,MAAM;EAC1C,aAAY;EACZ,OAAM;CACP,CAAA;AAEL;;AAGA,SAAgB,mBAAmB;CACjC,OAAO,oBAAC,YAAD,EAAY,QAAQ,UAAU,QAAQ,MAAM,UAAU,CAAC,CAAC,IAAI,EAAI,CAAA;AACzE"}
|
package/dist/pages/users.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as PageHeader, n as ClosedDoor, rt as Users, u as useCoffre } from "../chunks/page-DvsgZ2Hd.js";
|
|
2
|
-
import {
|
|
3
|
-
import { t as useShell } from "../chunks/use-shell-
|
|
4
|
-
import { t as DirectoryTable } from "../chunks/directory-
|
|
5
|
-
import { n as RemovedList } from "../chunks/offboarding-
|
|
2
|
+
import { g as queries } from "../chunks/queries-DE5nK2y4.js";
|
|
3
|
+
import { t as useShell } from "../chunks/use-shell-BO4ZTr1y.js";
|
|
4
|
+
import { t as DirectoryTable } from "../chunks/directory-DSVt5Tya.js";
|
|
5
|
+
import { n as RemovedList } from "../chunks/offboarding-DVBSiJRZ.js";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
|
8
8
|
//#region src/pages/users.tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffre/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "coffre's pages, for a deployment's own TanStack Start app: its router, and a Vite plugin for its build.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@tanstack/router-core": "1.171.15",
|
|
45
45
|
"lucide-react": "1.47.0",
|
|
46
46
|
"sonner": "2.0.7",
|
|
47
|
-
"@coffre/client": "0.
|
|
48
|
-
"@coffre/core": "0.
|
|
47
|
+
"@coffre/client": "0.5.1",
|
|
48
|
+
"@coffre/core": "0.5.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@tanstack/react-query": "5.103.1",
|
|
@@ -9,6 +9,7 @@ import type { UiCapabilities } from '../lib/capabilities';
|
|
|
9
9
|
type AdministrationItemsProps = {
|
|
10
10
|
capabilities: UiCapabilities;
|
|
11
11
|
users: ReactNode;
|
|
12
|
+
services: ReactNode;
|
|
12
13
|
audit: ReactNode;
|
|
13
14
|
};
|
|
14
15
|
|
|
@@ -16,27 +17,30 @@ type AdministrationItemsProps = {
|
|
|
16
17
|
export function AdministrationItems({
|
|
17
18
|
capabilities,
|
|
18
19
|
users,
|
|
20
|
+
services,
|
|
19
21
|
audit,
|
|
20
22
|
}: AdministrationItemsProps): ReactElement {
|
|
21
23
|
return createElement(
|
|
22
24
|
Fragment,
|
|
23
25
|
null,
|
|
24
|
-
...administrationEntries(capabilities, { users: [users], audit: [audit] }),
|
|
26
|
+
...administrationEntries(capabilities, { users: [users], services: [services], audit: [audit] }),
|
|
25
27
|
);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
/** The same rule, for destinations kept as data (the command palette's). */
|
|
29
31
|
export function administrationEntries<T>(
|
|
30
32
|
capabilities: UiCapabilities,
|
|
31
|
-
{ users, audit }: { users: T[]; audit: T[] },
|
|
33
|
+
{ users, services, audit }: { users: T[]; services: T[]; audit: T[] },
|
|
32
34
|
): T[] {
|
|
33
35
|
return [
|
|
34
36
|
...(capabilities.canManageGrants ? users : []),
|
|
37
|
+
// Service accounts, to whoever sets one up too: they see those they manage.
|
|
38
|
+
...(capabilities.canManageGrants || capabilities.setsUpServices ? services : []),
|
|
35
39
|
...(capabilities.canReadAudit ? audit : []),
|
|
36
40
|
];
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
/** Project creation exists before a grantable resource, so it
|
|
43
|
+
/** Project creation exists before a grantable resource, so it follows the instance role and its scope (`makesProjects`). */
|
|
40
44
|
export function RootAdminOnly({
|
|
41
45
|
capabilities,
|
|
42
46
|
children,
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { Fragment, useState } from 'react';
|
|
2
2
|
import { useQuery } from '@tanstack/react-query';
|
|
3
3
|
import { Menu } from '@base-ui/react/menu';
|
|
4
|
-
import {
|
|
4
|
+
import { EVERYWHERE, INSTANCE_ROLES, scopeInWords, unscoped } from '@coffre/core/access';
|
|
5
|
+
import { changeRole, directoryList, invite, removeMember, type InviteVars, type RoleVars } from '../lib/changes';
|
|
5
6
|
import { memberRef, useCoffre } from '../lib/coffre';
|
|
6
|
-
import {
|
|
7
|
+
import { scopeComplete } from '../lib/validation';
|
|
8
|
+
import { queries, waysFor } from '../lib/queries';
|
|
7
9
|
import { useShell } from '../lib/use-shell';
|
|
8
10
|
import { useChange, useChangeStatus } from '../lib/use-change';
|
|
9
11
|
import type { DirectoryPrincipal } from '../shared/models';
|
|
10
12
|
import { RowFailure, RowPending, rowClass } from './row-state';
|
|
11
13
|
import { ConfirmDialog, EmptyState, MenuPopup, Modal, Spinner, Timestamp, Toggletip } from './ui';
|
|
12
14
|
import { PrincipalLink } from './principal';
|
|
15
|
+
import { RoleField } from './role-field';
|
|
13
16
|
import { Clock, Folder, GitHub, Key, Link, Lock, MoreHorizontal, Pencil, Plus, ShieldCheck, User, X } from './icons';
|
|
14
17
|
|
|
15
18
|
/**
|
|
@@ -28,9 +31,15 @@ export const memberOf = (principal: Pick<DirectoryPrincipal, 'principalType' | '
|
|
|
28
31
|
|
|
29
32
|
export const ROLE_LABEL: Record<DirectoryPrincipal['instanceRole'], string> = {
|
|
30
33
|
'root-admin': 'Root admin',
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
...Object.fromEntries(Object.entries(INSTANCE_ROLES).map(([role, { name }]) => [role, name])),
|
|
35
|
+
} as Record<DirectoryPrincipal['instanceRole'], string>;
|
|
36
|
+
|
|
37
|
+
/** A new person's role: a Member, everywhere. */
|
|
38
|
+
const MEMBER: RoleVars = { role: 'member', scope: EVERYWHERE };
|
|
39
|
+
|
|
40
|
+
/** The role a principal holds, as the role field edits it. */
|
|
41
|
+
const roleOf = (principal: DirectoryPrincipal): RoleVars =>
|
|
42
|
+
principal.instanceRole === 'root-admin' ? MEMBER : { role: principal.instanceRole, scope: principal.scope ?? EVERYWHERE };
|
|
34
43
|
|
|
35
44
|
/** What each kind of principal is called in the interface. */
|
|
36
45
|
export const KIND: Record<PrincipalType, string> = {
|
|
@@ -50,6 +59,7 @@ export function DirectoryTable({
|
|
|
50
59
|
}) {
|
|
51
60
|
const users = principalType === 'user';
|
|
52
61
|
const columns = users ? 4 : 6;
|
|
62
|
+
const { capabilities } = useShell();
|
|
53
63
|
const { status, failedAdds, dismiss } = useChangeStatus(directoryList.queryKey);
|
|
54
64
|
const refused = failedAdds<InviteVars>(principals.map(memberOf)).filter(
|
|
55
65
|
({ vars }) => vars.principalType === principalType,
|
|
@@ -171,9 +181,11 @@ export function DirectoryTable({
|
|
|
171
181
|
</div>
|
|
172
182
|
)}
|
|
173
183
|
</section>
|
|
174
|
-
|
|
175
|
-
<
|
|
176
|
-
|
|
184
|
+
{(capabilities.runsInstance || (!users && capabilities.setsUpServices)) && (
|
|
185
|
+
<div className="table-actions">
|
|
186
|
+
<AddPrincipal principalType={principalType} />
|
|
187
|
+
</div>
|
|
188
|
+
)}
|
|
177
189
|
</>
|
|
178
190
|
);
|
|
179
191
|
}
|
|
@@ -193,13 +205,13 @@ const PLATFORM: Record<string, string> = {
|
|
|
193
205
|
*/
|
|
194
206
|
function ServiceCells({ principal }: { principal: DirectoryPrincipal }) {
|
|
195
207
|
const client = useCoffre();
|
|
196
|
-
const
|
|
208
|
+
const shell = useShell();
|
|
197
209
|
const member = memberOf(principal);
|
|
198
|
-
// As `loadServiceDirectory` read them, so these come from its cache.
|
|
199
|
-
const
|
|
210
|
+
// As `loadServiceDirectory` read them, so these come from its cache; an account just added is yours.
|
|
211
|
+
const ways = waysFor(shell, principal.managed !== false);
|
|
200
212
|
// Not suspended: an account added here is shown at once, its facts when they come.
|
|
201
|
-
const { data: bindings } = useQuery(queries.bindings(client, member,
|
|
202
|
-
const { data: credentials } = useQuery(queries.credentials(client, member,
|
|
213
|
+
const { data: bindings } = useQuery(queries.bindings(client, member, ways.workloads));
|
|
214
|
+
const { data: credentials } = useQuery(queries.credentials(client, member, ways.tokens));
|
|
203
215
|
|
|
204
216
|
const platforms = new Map<string, number>();
|
|
205
217
|
const bindingList = bindings?.ok === true ? bindings.bindings : [];
|
|
@@ -305,15 +317,21 @@ export function InstanceRole({ principal }: { principal: DirectoryPrincipal }) {
|
|
|
305
317
|
);
|
|
306
318
|
}
|
|
307
319
|
return (
|
|
308
|
-
|
|
309
|
-
{
|
|
310
|
-
|
|
320
|
+
<>
|
|
321
|
+
<span className={`tag${principal.instanceRole === 'member' ? '' : ' tag-violet'}`}>
|
|
322
|
+
{ROLE_LABEL[principal.instanceRole]}
|
|
323
|
+
</span>
|
|
324
|
+
{principal.instanceRole !== 'member' && principal.scope !== null && !unscoped(principal.scope) && (
|
|
325
|
+
<span className="role-scope">{scopeInWords(principal.scope)}</span>
|
|
326
|
+
)}
|
|
327
|
+
</>
|
|
311
328
|
);
|
|
312
329
|
}
|
|
313
330
|
|
|
314
331
|
/**
|
|
315
|
-
* Change role and Remove, behind one menu
|
|
316
|
-
*
|
|
332
|
+
* Change role and Remove, behind one menu, for those who run the instance;
|
|
333
|
+
* Remove, for a service account you manage. Root admins get none: the
|
|
334
|
+
* deployment's configuration owns them. Nobody changes their own role.
|
|
317
335
|
*/
|
|
318
336
|
export function PrincipalActions({
|
|
319
337
|
principal,
|
|
@@ -325,17 +343,18 @@ export function PrincipalActions({
|
|
|
325
343
|
}) {
|
|
326
344
|
const [editing, setEditing] = useState(false);
|
|
327
345
|
const [confirming, setConfirming] = useState(false);
|
|
328
|
-
const [
|
|
329
|
-
|
|
330
|
-
);
|
|
346
|
+
const [role, setRole] = useState<RoleVars>(roleOf(principal));
|
|
347
|
+
const { capabilities, principal: me } = useShell();
|
|
331
348
|
const coffre = useCoffre();
|
|
332
|
-
const
|
|
349
|
+
const saveRole = useChange(changeRole(coffre));
|
|
333
350
|
const remove = useChange(removeMember(coffre));
|
|
334
351
|
const { status } = useChangeStatus(directoryList.queryKey);
|
|
335
352
|
const pending = status(memberOf(principal)).state === 'pending';
|
|
336
353
|
const kind = KIND[principal.principalType];
|
|
337
354
|
|
|
338
|
-
|
|
355
|
+
const self = me?.type === principal.principalType && me.id === principal.principalId;
|
|
356
|
+
const yours = principal.principalType === 'service' && principal.managed === true;
|
|
357
|
+
if (principal.isRootAdmin || !(capabilities.runsInstance || yours)) return null;
|
|
339
358
|
|
|
340
359
|
return (
|
|
341
360
|
<>
|
|
@@ -348,12 +367,12 @@ export function PrincipalActions({
|
|
|
348
367
|
{pending ? <Spinner size={13} /> : <MoreHorizontal size={16} />}
|
|
349
368
|
</Menu.Trigger>
|
|
350
369
|
<MenuPopup align="end">
|
|
351
|
-
{principal.principalType === 'user' && (
|
|
370
|
+
{principal.principalType === 'user' && !self && capabilities.runsInstance && (
|
|
352
371
|
<>
|
|
353
372
|
<Menu.Item
|
|
354
373
|
className="menu-item"
|
|
355
374
|
onClick={() => {
|
|
356
|
-
|
|
375
|
+
setRole(roleOf(principal));
|
|
357
376
|
setEditing(true);
|
|
358
377
|
}}
|
|
359
378
|
>
|
|
@@ -388,16 +407,16 @@ export function PrincipalActions({
|
|
|
388
407
|
onSubmit={(event) => {
|
|
389
408
|
event.preventDefault();
|
|
390
409
|
// Shown in the list at once; the row says if the server refuses.
|
|
391
|
-
|
|
410
|
+
saveRole({ principalId: principal.principalId, ...role });
|
|
392
411
|
setEditing(false);
|
|
393
412
|
}}
|
|
394
413
|
>
|
|
395
|
-
<RoleField value={
|
|
414
|
+
<RoleField value={role} onChange={setRole} />
|
|
396
415
|
<div className="dialog-actions">
|
|
397
416
|
<button className="btn" type="button" onClick={() => setEditing(false)}>
|
|
398
417
|
Cancel
|
|
399
418
|
</button>
|
|
400
|
-
<button className="btn btn-primary" type="submit">
|
|
419
|
+
<button className="btn btn-primary" type="submit" disabled={!scopeComplete(role)}>
|
|
401
420
|
Save
|
|
402
421
|
</button>
|
|
403
422
|
</div>
|
|
@@ -432,7 +451,7 @@ function RemovalPreview({ principal, open }: { principal: DirectoryPrincipal; op
|
|
|
432
451
|
const { capabilities, features } = useShell();
|
|
433
452
|
const person = principal.principalType === 'user';
|
|
434
453
|
const { data, isPending } = useQuery({
|
|
435
|
-
...queries.report(useCoffre(), memberOf(principal), capabilities.
|
|
454
|
+
...queries.report(useCoffre(), memberOf(principal), capabilities.runsInstance),
|
|
436
455
|
enabled: open,
|
|
437
456
|
});
|
|
438
457
|
const report = data?.ok === true ? data.report : null;
|
|
@@ -476,14 +495,14 @@ function RemovalPreview({ principal, open }: { principal: DirectoryPrincipal; op
|
|
|
476
495
|
export function AddPrincipal({ principalType }: { principalType: PrincipalType }) {
|
|
477
496
|
const [open, setOpen] = useState(false);
|
|
478
497
|
const [principalId, setPrincipalId] = useState('');
|
|
479
|
-
const [
|
|
498
|
+
const [role, setRole] = useState<RoleVars>(MEMBER);
|
|
480
499
|
const add = useChange(invite(useCoffre()));
|
|
481
500
|
const kind = KIND[principalType];
|
|
482
501
|
|
|
483
502
|
function close() {
|
|
484
503
|
setOpen(false);
|
|
485
504
|
setPrincipalId('');
|
|
486
|
-
|
|
505
|
+
setRole(MEMBER);
|
|
487
506
|
}
|
|
488
507
|
|
|
489
508
|
return (
|
|
@@ -497,14 +516,18 @@ export function AddPrincipal({ principalType }: { principalType: PrincipalType }
|
|
|
497
516
|
open={open}
|
|
498
517
|
onOpenChange={(next) => (next ? setOpen(true) : close())}
|
|
499
518
|
title={`Add a ${kind}`}
|
|
500
|
-
description={
|
|
519
|
+
description={
|
|
520
|
+
principalType === 'user'
|
|
521
|
+
? 'Their instance role reaches every project in its scope. Grant more afterwards, from their page or a project\'s.'
|
|
522
|
+
: 'This gives the service account no project access. Grant it afterwards, from its page or a project\'s.'
|
|
523
|
+
}
|
|
501
524
|
>
|
|
502
525
|
<form
|
|
503
526
|
className="form"
|
|
504
527
|
onSubmit={(event) => {
|
|
505
528
|
event.preventDefault();
|
|
506
529
|
// Shown in the list at once; the list says if the server refuses.
|
|
507
|
-
add({ principalType, principalId: principalId.trim(),
|
|
530
|
+
add({ principalType, principalId: principalId.trim(), ...role });
|
|
508
531
|
close();
|
|
509
532
|
}}
|
|
510
533
|
>
|
|
@@ -525,15 +548,13 @@ export function AddPrincipal({ principalType }: { principalType: PrincipalType }
|
|
|
525
548
|
/>
|
|
526
549
|
</label>
|
|
527
550
|
|
|
528
|
-
{principalType === 'user' &&
|
|
529
|
-
<RoleField value={instanceRole} onChange={setInstanceRole} />
|
|
530
|
-
)}
|
|
551
|
+
{principalType === 'user' && <RoleField value={role} onChange={setRole} />}
|
|
531
552
|
|
|
532
553
|
<div className="dialog-actions">
|
|
533
554
|
<button className="btn" type="button" onClick={close}>
|
|
534
555
|
Cancel
|
|
535
556
|
</button>
|
|
536
|
-
<button className="btn btn-primary" type="submit" disabled={principalId.trim() === ''}>
|
|
557
|
+
<button className="btn btn-primary" type="submit" disabled={principalId.trim() === '' || !scopeComplete(role)}>
|
|
537
558
|
Add {kind}
|
|
538
559
|
</button>
|
|
539
560
|
</div>
|
|
@@ -542,29 +563,3 @@ export function AddPrincipal({ principalType }: { principalType: PrincipalType }
|
|
|
542
563
|
</>
|
|
543
564
|
);
|
|
544
565
|
}
|
|
545
|
-
|
|
546
|
-
function RoleField({
|
|
547
|
-
value,
|
|
548
|
-
onChange,
|
|
549
|
-
}: {
|
|
550
|
-
value: 'user' | 'owner';
|
|
551
|
-
onChange: (value: 'user' | 'owner') => void;
|
|
552
|
-
}) {
|
|
553
|
-
return (
|
|
554
|
-
<label className="field">
|
|
555
|
-
<span className="label">Instance role</span>
|
|
556
|
-
<select
|
|
557
|
-
className="select"
|
|
558
|
-
value={value}
|
|
559
|
-
onChange={(event) => onChange(event.target.value as 'user' | 'owner')}
|
|
560
|
-
>
|
|
561
|
-
<option value="user">Member</option>
|
|
562
|
-
<option value="owner">Owner</option>
|
|
563
|
-
</select>
|
|
564
|
-
<span className="hint">
|
|
565
|
-
Owners manage users and service accounts, can create projects, and read the whole audit log.
|
|
566
|
-
Neither role reads a secret without a project grant.
|
|
567
|
-
</span>
|
|
568
|
-
</label>
|
|
569
|
-
);
|
|
570
|
-
}
|
|
@@ -3,7 +3,6 @@ import { grantId, revokeGrant, type GrantVars } from '../lib/changes';
|
|
|
3
3
|
import type { FailedAdd } from '../lib/optimistic';
|
|
4
4
|
import { useCoffre } from '../lib/coffre';
|
|
5
5
|
import { projectAccessLabel } from '../lib/project-access';
|
|
6
|
-
import { everyProjectPlace } from './every-project';
|
|
7
6
|
import { keys } from '../lib/queries';
|
|
8
7
|
import { useChange, useChangeStatus } from '../lib/use-change';
|
|
9
8
|
import type { GrantRow } from '../shared/models';
|
|
@@ -65,9 +64,9 @@ export function GrantRowView({
|
|
|
65
64
|
const revoke = useChange(revokeGrant(useCoffre(), project));
|
|
66
65
|
const { status, dismiss } = useChangeStatus(keys.grants(project));
|
|
67
66
|
const state = status(grantId(grant));
|
|
68
|
-
//
|
|
69
|
-
const
|
|
70
|
-
const label =
|
|
67
|
+
// Someone's instance role reaching the project is shown here, and changed on their page in Users.
|
|
68
|
+
const byRole = grant.scope === 'instance-role';
|
|
69
|
+
const label = byRole ? grant.roleName : projectAccessLabel(grant);
|
|
71
70
|
const expired = grant.expiresAt !== null && new Date(grant.expiresAt).getTime() < Date.now();
|
|
72
71
|
|
|
73
72
|
return (
|
|
@@ -79,6 +78,11 @@ export function GrantRowView({
|
|
|
79
78
|
</td>
|
|
80
79
|
<td className="col-access" data-label="Permissions">
|
|
81
80
|
<span className={`tag${grant.role === 'owner' ? ' tag-violet' : ''}`}>{label}</span>
|
|
81
|
+
{byRole && (
|
|
82
|
+
<span className="role-scope" title="Their instance role reaches this project. Change it on their page in Users.">
|
|
83
|
+
instance role
|
|
84
|
+
</span>
|
|
85
|
+
)}
|
|
82
86
|
</td>
|
|
83
87
|
<td
|
|
84
88
|
className={`col-expires cell-mono cell-muted${grant.expiresAt === null ? ' is-never' : ''}`}
|
|
@@ -102,11 +106,7 @@ export function GrantRowView({
|
|
|
102
106
|
<td className="col-actions">
|
|
103
107
|
{state.state === 'pending' ? (
|
|
104
108
|
<RowPending status={state} />
|
|
105
|
-
) :
|
|
106
|
-
<span className="cell-muted every-project-note" title="Owners change grants on every project with coffre grant '*' and coffre revoke '*'">
|
|
107
|
-
every project
|
|
108
|
-
</span>
|
|
109
|
-
) : (
|
|
109
|
+
) : byRole ? null : (
|
|
110
110
|
<ConfirmButton
|
|
111
111
|
trigger={<button className="act act-danger">Revoke</button>}
|
|
112
112
|
title={
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Link } from '@tanstack/react-router';
|
|
2
|
+
import { credentialScopeInWords } from '@coffre/core/access';
|
|
2
3
|
import type { PrincipalReport, RemovedPrincipal } from '../shared/models';
|
|
3
4
|
import { Card } from './page';
|
|
4
5
|
import { EmptyState, Notice, Timestamp } from './ui';
|
|
@@ -239,7 +240,8 @@ function IssuedTokens({ report }: { report: PrincipalReport }) {
|
|
|
239
240
|
service:{serviceName(token.service)}
|
|
240
241
|
</Link>
|
|
241
242
|
<small>
|
|
242
|
-
{token.label ?? 'No label'} · <span className="mono">{token.hint}</span>
|
|
243
|
+
{token.label ?? 'No label'} · <span className="mono">{token.hint}</span> · reaches{' '}
|
|
244
|
+
{token.scope === null ? 'all its account holds' : credentialScopeInWords(token.scope)}
|
|
243
245
|
</small>
|
|
244
246
|
</span>
|
|
245
247
|
</td>
|