@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
package/src/lib/validation.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* bundle does not carry zod, and `test/validation.test.ts` holds the two in
|
|
8
8
|
* agreement.
|
|
9
9
|
*/
|
|
10
|
+
import type { Filter, InstanceRole, Scope } from '@coffre/core/access';
|
|
10
11
|
import { PROJECT_PAGES } from '@coffre/core/pages';
|
|
11
12
|
|
|
12
13
|
const SLUG = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
@@ -39,3 +40,9 @@ export function folderProblem(value: string): string | null {
|
|
|
39
40
|
if (/[/\p{Cc}]/u.test(value)) return 'No slash.';
|
|
40
41
|
return null;
|
|
41
42
|
}
|
|
43
|
+
|
|
44
|
+
/** Whether a role's scope can be saved: each Only or All except names something. A Member's has nothing to fill. */
|
|
45
|
+
export function scopeComplete({ role, scope }: { role: InstanceRole; scope: Scope }): boolean {
|
|
46
|
+
const named = (filter: Filter) => filter === 'all' || ('only' in filter ? filter.only : filter.except).length > 0;
|
|
47
|
+
return role === 'member' || (named(scope.projects) && named(scope.environments));
|
|
48
|
+
}
|
package/src/options.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { ShellLayout, SoloLayout } from './layout';
|
|
|
23
23
|
import { memberRef, uiResult } from './lib/coffre';
|
|
24
24
|
import { stringsOf } from './lib/search';
|
|
25
25
|
import {
|
|
26
|
+
hasAppsTab,
|
|
26
27
|
loadAccess,
|
|
27
28
|
loadDirectory,
|
|
28
29
|
loadMember,
|
|
@@ -204,9 +205,9 @@ export const user = {
|
|
|
204
205
|
|
|
205
206
|
/** `/users/$user/`, their access on every project where you manage it. */
|
|
206
207
|
export const userAccess = {
|
|
207
|
-
loader: ({ context }: Loader) => {
|
|
208
|
+
loader: ({ context, params }: Loader<{ user: string }>) => {
|
|
208
209
|
const { coffre, queryClient } = coffreOf(context);
|
|
209
|
-
return loadAccess(queryClient, coffre);
|
|
210
|
+
return loadAccess(queryClient, coffre, memberRef('user', params.user));
|
|
210
211
|
},
|
|
211
212
|
};
|
|
212
213
|
|
|
@@ -219,6 +220,21 @@ export const userActivity = {
|
|
|
219
220
|
},
|
|
220
221
|
};
|
|
221
222
|
|
|
223
|
+
/**
|
|
224
|
+
* `/users/$user/apps`, the MCP clients they connected, for an owner where the
|
|
225
|
+
* deployment serves MCP, and while they are not removed (removal disconnects
|
|
226
|
+
* every one); the others are sent to the first tab, which for someone removed
|
|
227
|
+
* is their offboarding.
|
|
228
|
+
*/
|
|
229
|
+
export const userApps = {
|
|
230
|
+
loader: async ({ context, params }: Loader<{ user: string }>) => {
|
|
231
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
232
|
+
const shell = await loadShell(queryClient, coffre);
|
|
233
|
+
const report = await loadMember(queryClient, coffre, memberRef('user', params.user));
|
|
234
|
+
if (!hasAppsTab(shell, report)) throw redirect({ to: '/users/$user', params });
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
|
|
222
238
|
/** `/service-accounts`. */
|
|
223
239
|
export const serviceAccounts = {
|
|
224
240
|
loader: ({ context }: Loader) => {
|
|
@@ -227,25 +243,29 @@ export const serviceAccounts = {
|
|
|
227
243
|
},
|
|
228
244
|
};
|
|
229
245
|
|
|
230
|
-
/**
|
|
246
|
+
/**
|
|
247
|
+
* `/service-accounts/$account`, the layout of a service account's tabs: who
|
|
248
|
+
* it is to the instance, for owners, and what it holds, for whoever manages it.
|
|
249
|
+
*/
|
|
231
250
|
export const serviceAccount = {
|
|
232
|
-
loader: ({ context, params }: Loader<{ account: string }>) => {
|
|
251
|
+
loader: async ({ context, params }: Loader<{ account: string }>) => {
|
|
233
252
|
const { coffre, queryClient } = coffreOf(context);
|
|
234
|
-
|
|
253
|
+
const member = memberRef('service', params.account);
|
|
254
|
+
await Promise.all([loadMember(queryClient, coffre, member), loadAccess(queryClient, coffre, member)]);
|
|
235
255
|
},
|
|
236
256
|
};
|
|
237
257
|
|
|
238
258
|
/**
|
|
239
259
|
* `/service-accounts/$account/`, how it signs in: its trusted workloads and
|
|
240
|
-
* bearer tokens. Only
|
|
241
|
-
* anyone else is sent to its access.
|
|
260
|
+
* bearer tokens. Only whoever manages it sees them, and only while it is
|
|
261
|
+
* active; anyone else is sent to its access.
|
|
242
262
|
*/
|
|
243
263
|
export const serviceAccountSignIn = {
|
|
244
264
|
loader: async ({ context, params }: Loader<{ account: string }>) => {
|
|
245
265
|
const { coffre, queryClient } = coffreOf(context);
|
|
246
266
|
const member = memberRef('service', params.account);
|
|
247
|
-
const [shell,
|
|
248
|
-
const ways = signInWays(shell,
|
|
267
|
+
const [shell, access] = await Promise.all([loadShell(queryClient, coffre), loadAccess(queryClient, coffre, member)]);
|
|
268
|
+
const ways = signInWays(shell, access);
|
|
249
269
|
if (ways === null) throw redirect({ to: '/service-accounts/$account/access', params });
|
|
250
270
|
await Promise.all([
|
|
251
271
|
queryClient.fetchQuery(queries.credentials(coffre, member, ways.tokens)),
|
|
@@ -256,9 +276,9 @@ export const serviceAccountSignIn = {
|
|
|
256
276
|
|
|
257
277
|
/** `/service-accounts/$account/access`. */
|
|
258
278
|
export const serviceAccountAccess = {
|
|
259
|
-
loader: ({ context }: Loader) => {
|
|
279
|
+
loader: ({ context, params }: Loader<{ account: string }>) => {
|
|
260
280
|
const { coffre, queryClient } = coffreOf(context);
|
|
261
|
-
return loadAccess(queryClient, coffre);
|
|
281
|
+
return loadAccess(queryClient, coffre, memberRef('service', params.account));
|
|
262
282
|
},
|
|
263
283
|
};
|
|
264
284
|
|
package/src/pages/account.tsx
CHANGED
|
@@ -75,7 +75,7 @@ export function AccountPage() {
|
|
|
75
75
|
|
|
76
76
|
/** Its first tab: who you are to coffre, and the accounts you sign in with. */
|
|
77
77
|
export function AccountProfilePage() {
|
|
78
|
-
const { principal, instanceRole, auth } = useShell();
|
|
78
|
+
const { principal, instanceRole, scope, auth } = useShell();
|
|
79
79
|
if (principal === null) return null;
|
|
80
80
|
return (
|
|
81
81
|
<>
|
|
@@ -91,7 +91,8 @@ export function AccountProfilePage() {
|
|
|
91
91
|
principal={{
|
|
92
92
|
principalType: 'user',
|
|
93
93
|
principalId: principal.id,
|
|
94
|
-
instanceRole: instanceRole ?? '
|
|
94
|
+
instanceRole: instanceRole ?? 'member',
|
|
95
|
+
scope,
|
|
95
96
|
isRootAdmin: instanceRole === 'root-admin',
|
|
96
97
|
}}
|
|
97
98
|
/>
|
package/src/pages/login.tsx
CHANGED
|
@@ -80,7 +80,7 @@ function ProviderLoginPage({
|
|
|
80
80
|
{title}
|
|
81
81
|
</h1>
|
|
82
82
|
<p className="signin-lede">
|
|
83
|
-
{note ?? 'Sign in with your organization’s account. Only people an
|
|
83
|
+
{note ?? 'Sign in with your organization’s account. Only people an admin has invited can get in.'}
|
|
84
84
|
</p>
|
|
85
85
|
</div>
|
|
86
86
|
|
|
@@ -13,10 +13,9 @@ import type { GrantRow, ProjectSummary } from '../shared/models';
|
|
|
13
13
|
import { ArchiveBlocked, archiveBlockers } from '../components/references';
|
|
14
14
|
import { hasEnvironmentDetails, isActiveAccessibleEnvironment, type ProjectEnvironment } from '../lib/project-environments';
|
|
15
15
|
import { environmentSlugProblem } from '../lib/validation';
|
|
16
|
-
import { ConfirmDialog, EmptyState, MenuPopup, Modal, Timestamp } from '../components/ui';
|
|
16
|
+
import { ConfirmDialog, EmptyState, MenuPopup, Modal, Notice, Timestamp } from '../components/ui';
|
|
17
17
|
import { DeletePlaceDialog } from '../components/delete-place';
|
|
18
18
|
import { PrincipalAvatar } from '../components/principal';
|
|
19
|
-
import { ReachedBy, reaching, useEveryProject } from '../components/every-project';
|
|
20
19
|
import { Archive, ChevronRight, MoreHorizontal, Pencil, Plus, RotateBack, Trash } from '../components/icons';
|
|
21
20
|
import { pageRoute } from '../lib/page-route';
|
|
22
21
|
import { useProject } from '../lib/project-page';
|
|
@@ -181,7 +180,7 @@ function EnvironmentCard({
|
|
|
181
180
|
const [renaming, setRenaming] = useState(false);
|
|
182
181
|
const [confirming, setConfirming] = useState(false);
|
|
183
182
|
const [deleting, setDeleting] = useState(false);
|
|
184
|
-
const {
|
|
183
|
+
const { capabilities } = useShell();
|
|
185
184
|
const [slug, setSlug] = useState(environment.slug);
|
|
186
185
|
const [name, setName] = useState(environment.name);
|
|
187
186
|
const coffre = useCoffre();
|
|
@@ -193,7 +192,6 @@ function EnvironmentCard({
|
|
|
193
192
|
const { data: lent } = useQuery({ ...queries.references(coffre, place), enabled: archiving });
|
|
194
193
|
const blockers = archiving && lent?.ok === true ? archiveBlockers(place, lent.references) : [];
|
|
195
194
|
const asking = archiving && lent === undefined;
|
|
196
|
-
const everyProject = useEveryProject();
|
|
197
195
|
const { status, dismiss } = useChangeStatus(keys.projects);
|
|
198
196
|
const state = status(environmentId(project, environment.slug));
|
|
199
197
|
const pending = state.state === 'pending';
|
|
@@ -202,16 +200,13 @@ function EnvironmentCard({
|
|
|
202
200
|
const secretCount = details?.secretCount ?? null;
|
|
203
201
|
const opens = details !== null && !isArchived && environment.accessible && !pending;
|
|
204
202
|
const manageable = isAdmin && details !== null;
|
|
205
|
-
// Deleting is for instance
|
|
206
|
-
const deletable = manageable && isArchived &&
|
|
203
|
+
// Deleting is for those who run the instance, and only once the environment is archived.
|
|
204
|
+
const deletable = manageable && isArchived && capabilities.runsInstance;
|
|
207
205
|
const slugError = slug === '' ? null : environmentSlugProblem(slug);
|
|
208
206
|
const lastChange = useLastChange(project, environment.slug, opens);
|
|
209
207
|
const holders = holdersOf(grants, environment.slug);
|
|
210
|
-
//
|
|
211
|
-
const
|
|
212
|
-
slug === environment.slug || slugError !== null
|
|
213
|
-
? []
|
|
214
|
-
: reaching(everyProject, slug).filter((grant) => grant.place !== '*');
|
|
208
|
+
// Scopes match environments by slug: a new one is said to move them before the rename is saved.
|
|
209
|
+
const reslugged = slug !== environment.slug && slug !== '' && slugError === null;
|
|
215
210
|
|
|
216
211
|
return (
|
|
217
212
|
<div
|
|
@@ -365,7 +360,12 @@ function EnvironmentCard({
|
|
|
365
360
|
/>
|
|
366
361
|
</label>
|
|
367
362
|
|
|
368
|
-
|
|
363
|
+
{reslugged && (
|
|
364
|
+
<Notice tone="info">
|
|
365
|
+
Instance roles scoped to <span className="mono">{environment.slug}</span> stop reaching it; those scoped
|
|
366
|
+
to <span className="mono">{slug}</span> start.
|
|
367
|
+
</Notice>
|
|
368
|
+
)}
|
|
369
369
|
|
|
370
370
|
<div className="dialog-actions">
|
|
371
371
|
<button className="btn" type="button" onClick={() => setRenaming(false)}>
|
|
@@ -463,7 +463,6 @@ function NewEnvironment({ project, sources }: { project: string; sources: string
|
|
|
463
463
|
: [];
|
|
464
464
|
const create = useChange(createEnvironment(coffre, project));
|
|
465
465
|
const slugError = slug === '' ? null : environmentSlugProblem(slug);
|
|
466
|
-
const reachedBy = reaching(useEveryProject(), slugError === null && slug !== '' ? slug : null);
|
|
467
466
|
|
|
468
467
|
function close() {
|
|
469
468
|
setOpen(false);
|
|
@@ -561,8 +560,6 @@ function NewEnvironment({ project, sources }: { project: string; sources: string
|
|
|
561
560
|
</label>
|
|
562
561
|
)}
|
|
563
562
|
|
|
564
|
-
<ReachedBy grants={reachedBy} lead="As soon as it exists, it is reached by" />
|
|
565
|
-
|
|
566
563
|
<div className="dialog-actions">
|
|
567
564
|
<button className="btn" type="button" onClick={close}>
|
|
568
565
|
Cancel
|
|
@@ -145,7 +145,7 @@ function DangerZone({ project }: { project: ProjectSummary }) {
|
|
|
145
145
|
const [deleting, setDeleting] = useState(false);
|
|
146
146
|
const coffre = useCoffre();
|
|
147
147
|
const router = useRouter();
|
|
148
|
-
const {
|
|
148
|
+
const { capabilities } = useShell();
|
|
149
149
|
const { pending, error, run } = useAction();
|
|
150
150
|
const isArchived = project.archivedAt !== null;
|
|
151
151
|
// What archiving it would stop, asked once the dialog opens (D41); Archive waits for the answer.
|
|
@@ -153,8 +153,8 @@ function DangerZone({ project }: { project: ProjectSummary }) {
|
|
|
153
153
|
const { data: lent } = useQuery({ ...queries.references(coffre, project.slug), enabled: archiving });
|
|
154
154
|
const blockers = archiving && lent?.ok === true ? archiveBlockers(project.slug, lent.references) : [];
|
|
155
155
|
const asking = archiving && lent === undefined;
|
|
156
|
-
// Deleting is for instance
|
|
157
|
-
const canDelete = isArchived &&
|
|
156
|
+
// Deleting is for those who run the instance, and only once the project is archived.
|
|
157
|
+
const canDelete = isArchived && capabilities.runsInstance;
|
|
158
158
|
|
|
159
159
|
return (
|
|
160
160
|
<Card labelledBy="danger-zone" title="Danger zone" tone="danger">
|
package/src/pages/projects.tsx
CHANGED
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
ProjectEmptyStateCopy,
|
|
25
25
|
RootAdminOnly,
|
|
26
26
|
} from '../components/affordances';
|
|
27
|
-
import { ReachedBy, reaching, useEveryProject } from '../components/every-project';
|
|
28
27
|
|
|
29
28
|
export function ProjectsPage() {
|
|
30
29
|
const { data: result, refetch } = useSuspenseQuery(queries.projects(useCoffre()));
|
|
@@ -286,7 +285,6 @@ function NewProject() {
|
|
|
286
285
|
const [open, setOpen] = useState(false);
|
|
287
286
|
const create = useChange(createProject(useCoffre()));
|
|
288
287
|
const slugError = slug === '' ? null : slugProblem(slug);
|
|
289
|
-
const reachedBy = reaching(useEveryProject(), null);
|
|
290
288
|
|
|
291
289
|
function close() {
|
|
292
290
|
setOpen(false);
|
|
@@ -303,7 +301,7 @@ function NewProject() {
|
|
|
303
301
|
open={open}
|
|
304
302
|
onOpenChange={(next) => (next ? setOpen(true) : close())}
|
|
305
303
|
title="New project"
|
|
306
|
-
description="A project holds environments.
|
|
304
|
+
description="A project holds environments."
|
|
307
305
|
>
|
|
308
306
|
<form
|
|
309
307
|
className="form"
|
|
@@ -344,8 +342,6 @@ function NewProject() {
|
|
|
344
342
|
/>
|
|
345
343
|
</label>
|
|
346
344
|
|
|
347
|
-
<ReachedBy grants={reachedBy} lead="As soon as it exists, it is reached by" />
|
|
348
|
-
|
|
349
345
|
<div className="dialog-actions">
|
|
350
346
|
<button className="btn" type="button" onClick={close}>
|
|
351
347
|
Cancel
|
|
@@ -6,7 +6,7 @@ import { ServiceTokens } from '../components/service-tokens';
|
|
|
6
6
|
import { TrustedWorkloads } from '../components/trusted-workloads';
|
|
7
7
|
import { Notice } from '../components/ui';
|
|
8
8
|
import { memberRef, useCoffre } from '../lib/coffre';
|
|
9
|
-
import { queries, signInWays } from '../lib/queries';
|
|
9
|
+
import { listsAccess, queries, signInWays } from '../lib/queries';
|
|
10
10
|
import { useShell } from '../lib/use-shell';
|
|
11
11
|
import { pageRoute } from '../lib/page-route';
|
|
12
12
|
import type { serviceAccount } from '../options';
|
|
@@ -24,17 +24,19 @@ export function ServiceAccountSignInPage() {
|
|
|
24
24
|
const client = useCoffre();
|
|
25
25
|
const shell = useShell();
|
|
26
26
|
const member = memberRef('service', account);
|
|
27
|
-
const { data:
|
|
27
|
+
const { data: access } = useSuspenseQuery(queries.memberAccess(client, member, listsAccess(shell)));
|
|
28
28
|
// Nothing to issue once it is removed, which its loader sent elsewhere; its layout then shows no such tab.
|
|
29
|
-
const ways = signInWays(shell,
|
|
29
|
+
const ways = signInWays(shell, access) ?? { tokens: false, workloads: false };
|
|
30
30
|
const { data: credentials } = useSuspenseQuery(queries.credentials(client, member, ways.tokens));
|
|
31
31
|
const { data: bindings } = useSuspenseQuery(queries.bindings(client, member, ways.workloads));
|
|
32
|
+
// What a new token or binding reaches, unless narrowed: everything the account holds, which its manager reaches.
|
|
33
|
+
const grants = access?.ok === true ? access.grants : [];
|
|
32
34
|
return (
|
|
33
35
|
<>
|
|
34
36
|
{bindings !== null &&
|
|
35
|
-
(bindings.ok ? <TrustedWorkloads serviceId={account} bindings={bindings.bindings} /> : <Notice tone="bad">{bindings.error}</Notice>)}
|
|
37
|
+
(bindings.ok ? <TrustedWorkloads serviceId={account} bindings={bindings.bindings} grants={grants} /> : <Notice tone="bad">{bindings.error}</Notice>)}
|
|
36
38
|
{credentials !== null &&
|
|
37
|
-
(credentials.ok ? <ServiceTokens serviceId={account} tokens={credentials.tokens} /> : <Notice tone="bad">{credentials.error}</Notice>)}
|
|
39
|
+
(credentials.ok ? <ServiceTokens serviceId={account} tokens={credentials.tokens} grants={grants} /> : <Notice tone="bad">{credentials.error}</Notice>)}
|
|
38
40
|
</>
|
|
39
41
|
);
|
|
40
42
|
}
|
|
@@ -2,15 +2,15 @@ import { useSuspenseQuery } from '@tanstack/react-query';
|
|
|
2
2
|
|
|
3
3
|
import { DirectoryTable } from '../components/directory';
|
|
4
4
|
import { useCoffre } from '../lib/coffre';
|
|
5
|
-
import { queries } from '../lib/queries';
|
|
5
|
+
import { listsServices, queries } from '../lib/queries';
|
|
6
6
|
import { useShell } from '../lib/use-shell';
|
|
7
7
|
import { ClosedDoor, PageHeader } from '../components/page';
|
|
8
8
|
import { RemovedList } from '../components/offboarding';
|
|
9
9
|
import { Key } from '../components/icons';
|
|
10
10
|
|
|
11
11
|
export function ServiceAccountsPage() {
|
|
12
|
-
const
|
|
13
|
-
const { data: result } = useSuspenseQuery(queries.directory(useCoffre(),
|
|
12
|
+
const shell = useShell();
|
|
13
|
+
const { data: result } = useSuspenseQuery(queries.directory(useCoffre(), listsServices(shell)));
|
|
14
14
|
|
|
15
15
|
if (!result.ok) {
|
|
16
16
|
return (
|
|
@@ -26,7 +26,11 @@ export function ServiceAccountsPage() {
|
|
|
26
26
|
<>
|
|
27
27
|
<PageHeader
|
|
28
28
|
title="Service accounts"
|
|
29
|
-
description=
|
|
29
|
+
description={
|
|
30
|
+
shell.capabilities.canManageGrants
|
|
31
|
+
? 'Identities for CI and other automation.'
|
|
32
|
+
: 'Identities for CI and other automation: those you manage, which hold nothing you do not.'
|
|
33
|
+
}
|
|
30
34
|
/>
|
|
31
35
|
<DirectoryTable
|
|
32
36
|
principalType="service"
|
package/src/pages/settings.tsx
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
1
2
|
import type { RouteOutput } from '@coffre/client';
|
|
3
|
+
import { scopeInWords, unscoped, type Scope } from '@coffre/core/access';
|
|
2
4
|
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
3
5
|
import { Link } from '@tanstack/react-router';
|
|
6
|
+
import { toast } from 'sonner';
|
|
4
7
|
import { useCoffre } from '../lib/coffre';
|
|
5
|
-
import { queries } from '../lib/queries';
|
|
8
|
+
import { affects, queries } from '../lib/queries';
|
|
9
|
+
import { useAction } from '../lib/use-action';
|
|
6
10
|
import { useShell } from '../lib/use-shell';
|
|
7
11
|
import { Card, Fact, PageHeader } from '../components/page';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
12
|
+
import { ScopeField } from '../components/role-field';
|
|
13
|
+
import { ErrorLine, Modal, Spinner, Toggletip } from '../components/ui';
|
|
14
|
+
import { Info, Pencil } from '../components/icons';
|
|
10
15
|
|
|
11
16
|
/** The instance's settings. Your own are under Account, at the sidebar's foot. */
|
|
12
17
|
|
|
@@ -14,7 +19,8 @@ export function SettingsPage() {
|
|
|
14
19
|
const { auth, capabilities } = useShell();
|
|
15
20
|
const client = useCoffre();
|
|
16
21
|
const { data: directory } = useSuspenseQuery(queries.directory(client, capabilities.canManageGrants));
|
|
17
|
-
const { data: keys } = useSuspenseQuery(queries.auditKeys(client, capabilities.
|
|
22
|
+
const { data: keys } = useSuspenseQuery(queries.auditKeys(client, capabilities.runsInstance));
|
|
23
|
+
const { data: settings } = useSuspenseQuery(queries.settings(client, capabilities.runsInstance));
|
|
18
24
|
const providers = auth?.signin?.providers.map((provider) => provider.label) ?? [];
|
|
19
25
|
|
|
20
26
|
const principals = directory?.ok === true ? directory.principals : null;
|
|
@@ -75,11 +81,81 @@ export function SettingsPage() {
|
|
|
75
81
|
</dl>
|
|
76
82
|
</Card>
|
|
77
83
|
|
|
84
|
+
{settings?.ok === true && <ServiceSetup scope={settings.serviceAccounts} />}
|
|
78
85
|
{keys?.ok === true && <Keys keys={keys} />}
|
|
79
86
|
</>
|
|
80
87
|
);
|
|
81
88
|
}
|
|
82
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Who sets up service accounts without running the instance: anyone who
|
|
92
|
+
* holds access, inside this scope, giving one at most what they hold there.
|
|
93
|
+
* Narrowed, the rest takes an Admin whose own scope reaches it.
|
|
94
|
+
*/
|
|
95
|
+
function ServiceSetup({ scope }: { scope: Scope }) {
|
|
96
|
+
const client = useCoffre();
|
|
97
|
+
const [open, setOpen] = useState(false);
|
|
98
|
+
const [draft, setDraft] = useState(scope);
|
|
99
|
+
const { pending, error, setError, run } = useAction();
|
|
100
|
+
const close = () => {
|
|
101
|
+
setOpen(false);
|
|
102
|
+
setDraft(scope);
|
|
103
|
+
setError(null);
|
|
104
|
+
};
|
|
105
|
+
return (
|
|
106
|
+
<Card
|
|
107
|
+
labelledBy="service-setup"
|
|
108
|
+
title="Service accounts"
|
|
109
|
+
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."
|
|
110
|
+
actions={
|
|
111
|
+
<button className="btn" type="button" onClick={() => setOpen(true)}>
|
|
112
|
+
<Pencil size={14} />
|
|
113
|
+
Edit
|
|
114
|
+
</button>
|
|
115
|
+
}
|
|
116
|
+
>
|
|
117
|
+
<dl className="facts">
|
|
118
|
+
<Fact label="Set up by people in">
|
|
119
|
+
<span>{unscoped(scope) ? 'Every project and environment' : scopeInWords(scope)}</span>
|
|
120
|
+
</Fact>
|
|
121
|
+
</dl>
|
|
122
|
+
<Modal
|
|
123
|
+
open={open}
|
|
124
|
+
onOpenChange={(next) => (next ? setOpen(true) : close())}
|
|
125
|
+
title="Who sets up service accounts"
|
|
126
|
+
description="People set up service accounts, and give them what they hold, in these projects and environments. All except prod keeps prod's to Admins."
|
|
127
|
+
>
|
|
128
|
+
<form
|
|
129
|
+
className="form"
|
|
130
|
+
onSubmit={(event) => {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
run(() => client.settings.set({ serviceAccounts: draft }), {
|
|
133
|
+
affects: affects.settings(),
|
|
134
|
+
onSuccess: () => {
|
|
135
|
+
toast.success('Saved where people set up service accounts');
|
|
136
|
+
setOpen(false);
|
|
137
|
+
setError(null);
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<ScopeField legend="Where" scope={draft} onChange={setDraft} />
|
|
143
|
+
<ErrorLine error={error} />
|
|
144
|
+
<div className="dialog-actions">
|
|
145
|
+
<button className="btn" type="button" onClick={close}>
|
|
146
|
+
Cancel
|
|
147
|
+
</button>
|
|
148
|
+
<button className="btn btn-primary" type="submit" disabled={pending}>
|
|
149
|
+
{pending && <Spinner />}
|
|
150
|
+
Save
|
|
151
|
+
</button>
|
|
152
|
+
</div>
|
|
153
|
+
</form>
|
|
154
|
+
</Modal>
|
|
155
|
+
</Card>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
83
159
|
/**
|
|
84
160
|
* What the keys you keep are checked against: no secret, so shown. The keys
|
|
85
161
|
* themselves are checked by `coffre verify keys`, on your machine: a vault
|
|
@@ -6,7 +6,7 @@ import { User } from '../components/icons';
|
|
|
6
6
|
/**
|
|
7
7
|
* Cloudflare Access has authenticated this person, but Coffre has not
|
|
8
8
|
* registered them as a member. Keep this deliberately actionless: registration is
|
|
9
|
-
* an
|
|
9
|
+
* an admin's decision, not a self-service privilege escalation path.
|
|
10
10
|
*/
|
|
11
11
|
export function UnregisteredPage() {
|
|
12
12
|
const { principal, accessTampered } = useShell();
|
|
@@ -24,7 +24,7 @@ export function UnregisteredPage() {
|
|
|
24
24
|
)}{' '}
|
|
25
25
|
was changed outside coffre, so the vault refuses it and you have no access.
|
|
26
26
|
</p>
|
|
27
|
-
<p>To start over, ask a coffre
|
|
27
|
+
<p>To start over, ask a coffre admin to remove you under Users and add you again.</p>
|
|
28
28
|
</ClosedDoor>
|
|
29
29
|
);
|
|
30
30
|
}
|
|
@@ -46,7 +46,7 @@ export function UnregisteredPage() {
|
|
|
46
46
|
, but coffre has not added you.
|
|
47
47
|
</p>
|
|
48
48
|
<p>
|
|
49
|
-
Ask a coffre
|
|
49
|
+
Ask a coffre admin or root admin to add your Access email under Users.
|
|
50
50
|
</p>
|
|
51
51
|
</ClosedDoor>
|
|
52
52
|
);
|
package/src/pages/user.tsx
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
2
|
+
|
|
1
3
|
import { ActionsLog } from '../components/actions-log';
|
|
4
|
+
import { ConnectedAppsCard } from '../components/connected-apps';
|
|
2
5
|
import { PrincipalAccess, PrincipalLayout } from '../components/principal-page';
|
|
3
|
-
import {
|
|
6
|
+
import { disconnectMemberApp } from '../lib/changes';
|
|
7
|
+
import { memberRef, useCoffre } from '../lib/coffre';
|
|
4
8
|
import { pageRoute } from '../lib/page-route';
|
|
9
|
+
import { queries } from '../lib/queries';
|
|
10
|
+
import { useShell } from '../lib/use-shell';
|
|
5
11
|
import type { user } from '../options';
|
|
6
12
|
|
|
7
13
|
const Route = pageRoute<typeof user>();
|
|
@@ -16,6 +22,23 @@ export function UserAccessPage() {
|
|
|
16
22
|
return <PrincipalAccess principalType="user" principalId={Route.useParams().user} />;
|
|
17
23
|
}
|
|
18
24
|
|
|
25
|
+
/** The MCP clients they connected, for an owner, who may disconnect any of them. */
|
|
26
|
+
export function UserAppsPage() {
|
|
27
|
+
const client = useCoffre();
|
|
28
|
+
const member = memberRef('user', Route.useParams().user);
|
|
29
|
+
const { data: report } = useSuspenseQuery(queries.report(client, member, useShell().capabilities.runsInstance));
|
|
30
|
+
// Their layout says why there is no report.
|
|
31
|
+
if (report?.ok !== true || report.report === null) return null;
|
|
32
|
+
return (
|
|
33
|
+
<ConnectedAppsCard
|
|
34
|
+
apps={report.report.apps}
|
|
35
|
+
change={disconnectMemberApp(client, member)}
|
|
36
|
+
description="AI assistants and other MCP clients they connected. Removing them from coffre disconnects every one."
|
|
37
|
+
empty="They have connected none."
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
19
42
|
/** Everything they did, from the audit log. */
|
|
20
43
|
export function UserActivityPage() {
|
|
21
44
|
return <ActionsLog member={memberRef('user', Route.useParams().user)} />;
|
package/src/parity.ts
CHANGED
|
@@ -110,6 +110,9 @@ export const UI_PARITY: { [K in RouteKey]: Reach } = {
|
|
|
110
110
|
{ does: '⋯ › Remove…: what removing would revoke, before it does', in: 'components/directory.tsx', call: 'members.get' },
|
|
111
111
|
],
|
|
112
112
|
},
|
|
113
|
+
'GET /members/:member/access': {
|
|
114
|
+
ui: [{ does: "a user's or service account's page › Access: their role and the grants you manage, in one read", in: 'components/principal-page.tsx', call: 'members.access' }],
|
|
115
|
+
},
|
|
113
116
|
'PUT /members/:member': {
|
|
114
117
|
ui: [
|
|
115
118
|
{ does: 'Users › Add user; Service accounts › Add service account', in: 'components/directory.tsx', call: 'members.add' },
|
|
@@ -134,7 +137,6 @@ export const UI_PARITY: { [K in RouteKey]: Reach } = {
|
|
|
134
137
|
{ does: 'a project › Users, Service accounts › Add user, Add service account', in: 'pages/project-access.tsx', call: 'access.set' },
|
|
135
138
|
{ does: 'a grant › Revoke', in: 'components/grants.tsx', call: 'access.set' },
|
|
136
139
|
{ does: "a user's or service account's page › Edit access", in: 'components/principal-page.tsx', call: 'access.set' },
|
|
137
|
-
{ does: "an owner, on a user's or service account's Access tab › Grant on every project, and its Revoke", in: 'components/every-project.tsx', call: 'access.set' },
|
|
138
140
|
],
|
|
139
141
|
},
|
|
140
142
|
'GET /sessions': { ui: [{ does: 'Account › Sessions', in: 'pages/account.tsx', call: 'sessions.list' }] },
|
|
@@ -156,5 +158,7 @@ export const UI_PARITY: { [K in RouteKey]: Reach } = {
|
|
|
156
158
|
],
|
|
157
159
|
},
|
|
158
160
|
'GET /audit/verification': { ui: [{ does: "Audit: the log's seal, verified on every visit", in: 'pages/audit.tsx', call: 'audit.verify' }] },
|
|
161
|
+
'GET /settings': { ui: [{ does: 'Settings › Service accounts: where people set them up', in: 'pages/settings.tsx', call: 'settings.get' }] },
|
|
162
|
+
'PUT /settings': { ui: [{ does: 'Settings › Service accounts › Edit', in: 'pages/settings.tsx', call: 'settings.set' }] },
|
|
159
163
|
'GET /audit/keys': { ui: [{ does: 'Settings › Keys: what the keys you keep are checked against', in: 'pages/settings.tsx', call: 'audit.keys' }] },
|
|
160
164
|
};
|
package/src/register.ts
CHANGED
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
user,
|
|
36
36
|
userAccess,
|
|
37
37
|
userActivity,
|
|
38
|
+
userApps,
|
|
38
39
|
users,
|
|
39
40
|
type CoffreContext,
|
|
40
41
|
} from './options';
|
|
@@ -52,7 +53,7 @@ import { ServiceAccountAccessPage, ServiceAccountActivityPage, ServiceAccountLay
|
|
|
52
53
|
import { ServiceAccountsPage } from './pages/service-accounts';
|
|
53
54
|
import { SettingsPage } from './pages/settings';
|
|
54
55
|
import { UnregisteredPage } from './pages/unregistered';
|
|
55
|
-
import { UserAccessPage, UserActivityPage, UserLayout } from './pages/user';
|
|
56
|
+
import { UserAccessPage, UserActivityPage, UserAppsPage, UserLayout } from './pages/user';
|
|
56
57
|
import { UsersPage } from './pages/users';
|
|
57
58
|
|
|
58
59
|
const root = createRootRouteWithContext<CoffreContext>()({});
|
|
@@ -88,6 +89,7 @@ const routeTree = root.addChildren([
|
|
|
88
89
|
userPage.addChildren([
|
|
89
90
|
createRoute({ ...tab(userPage, '/'), ...userAccess, component: UserAccessPage }),
|
|
90
91
|
createRoute({ ...tab(userPage, '/activity'), ...userActivity, component: UserActivityPage }),
|
|
92
|
+
createRoute({ ...tab(userPage, '/apps'), ...userApps, component: UserAppsPage }),
|
|
91
93
|
]),
|
|
92
94
|
createRoute({ ...under('/service-accounts'), ...serviceAccounts, component: ServiceAccountsPage }),
|
|
93
95
|
serviceAccountPage.addChildren([
|
package/src/shared/models.ts
CHANGED
|
@@ -25,8 +25,12 @@ export type GrantRow = {
|
|
|
25
25
|
role: string;
|
|
26
26
|
roleName: string;
|
|
27
27
|
permissions: Permission[];
|
|
28
|
-
/**
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* `instance-role`: no grant, but their instance role reaching the
|
|
30
|
+
* project, which `role` and `roleName` name; it is changed on their page
|
|
31
|
+
* in Users, not here.
|
|
32
|
+
*/
|
|
33
|
+
scope: 'project' | 'environment' | 'instance-role';
|
|
30
34
|
environmentSlug: string | null;
|
|
31
35
|
expiresAt: string | null;
|
|
32
36
|
};
|
|
@@ -40,8 +44,8 @@ export type RoleRow = {
|
|
|
40
44
|
assignableToEnvironment: boolean;
|
|
41
45
|
};
|
|
42
46
|
|
|
43
|
-
export type DirectoryPrincipal = Pick<Member, 'principalType' | 'principalId' | 'instanceRole' | 'isRootAdmin'> &
|
|
44
|
-
Partial<Pick<Member, 'tampered'>> & {
|
|
47
|
+
export type DirectoryPrincipal = Pick<Member, 'principalType' | 'principalId' | 'instanceRole' | 'scope' | 'isRootAdmin'> &
|
|
48
|
+
Partial<Pick<Member, 'tampered' | 'managed'>> & {
|
|
45
49
|
/** Where it has access, when the list said; a member just added has none yet. */
|
|
46
50
|
grants?: { project: string; environment: string | null }[];
|
|
47
51
|
};
|