@coffre/ui 0.6.1 → 0.7.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-CUUMshIp.js → audit-sentence-C1_gRxWW.js} +91 -26
- package/dist/chunks/audit-sentence-C1_gRxWW.js.map +1 -0
- package/dist/chunks/{connected-apps-DTpatjge.js → connected-apps-Bn5rEoV2.js} +4 -4
- package/dist/chunks/{connected-apps-DTpatjge.js.map → connected-apps-Bn5rEoV2.js.map} +1 -1
- package/dist/chunks/{delete-place-SOOYVt6A.js → delete-place-CQCDHkne.js} +4 -4
- package/dist/chunks/{delete-place-SOOYVt6A.js.map → delete-place-CQCDHkne.js.map} +1 -1
- package/dist/chunks/{directory-DrtdKny2.js → directory-BQNOdze_.js} +22 -19
- package/dist/chunks/directory-BQNOdze_.js.map +1 -0
- package/dist/chunks/{folders-hR2Lnk0k.js → folders-Dw240WMJ.js} +2 -2
- package/dist/chunks/{folders-hR2Lnk0k.js.map → folders-Dw240WMJ.js.map} +1 -1
- package/dist/chunks/{grants-DDBui9YD.js → grants-CJIBrkod.js} +5 -5
- package/dist/chunks/{grants-DDBui9YD.js.map → grants-CJIBrkod.js.map} +1 -1
- package/dist/chunks/multi-combobox-CsIXihuc.js +99 -0
- package/dist/chunks/multi-combobox-CsIXihuc.js.map +1 -0
- package/dist/chunks/{offboarding-C7ECW5o0.js → offboarding-CrgwaetA.js} +4 -4
- package/dist/chunks/offboarding-CrgwaetA.js.map +1 -0
- package/dist/chunks/personal-tokens-B8rkT-DI.js +138 -0
- package/dist/chunks/personal-tokens-B8rkT-DI.js.map +1 -0
- package/dist/chunks/{principal-page-CB6dAABC.js → principal-page-DDmmV1KQ.js} +37 -27
- package/dist/chunks/principal-page-DDmmV1KQ.js.map +1 -0
- package/dist/chunks/{project-page-BHNUvr2L.js → project-page-BI--vjt3.js} +2 -2
- package/dist/chunks/{project-page-BHNUvr2L.js.map → project-page-BI--vjt3.js.map} +1 -1
- package/dist/chunks/{queries-DgQo3mC-.js → queries-epz4MIuW.js} +103 -18
- package/dist/chunks/queries-epz4MIuW.js.map +1 -0
- package/dist/chunks/{references-BQc35Q9g.js → references-DImfw0cz.js} +4 -4
- package/dist/chunks/{references-BQc35Q9g.js.map → references-DImfw0cz.js.map} +1 -1
- package/dist/chunks/{role-field-BfWRCqzl.js → role-field-C1KhNaIR.js} +2 -2
- package/dist/chunks/{role-field-BfWRCqzl.js.map → role-field-C1KhNaIR.js.map} +1 -1
- package/dist/chunks/{row-state-Zf3kZVhd.js → row-state-BsIHspy4.js} +2 -2
- package/dist/chunks/{row-state-Zf3kZVhd.js.map → row-state-BsIHspy4.js.map} +1 -1
- package/dist/chunks/{theme-B6-V9JvY.js → theme-3b4DnCow.js} +2 -2
- package/dist/chunks/{theme-B6-V9JvY.js.map → theme-3b4DnCow.js.map} +1 -1
- package/dist/chunks/{ui-Br-dNUTc.js → ui-2kwXXfrX.js} +95 -22
- package/dist/chunks/ui-2kwXXfrX.js.map +1 -0
- package/dist/chunks/{use-action-DthL5hL8.js → use-action-BB-RcHo1.js} +2 -2
- package/dist/chunks/{use-action-DthL5hL8.js.map → use-action-BB-RcHo1.js.map} +1 -1
- package/dist/chunks/{use-change-By4cG8bT.js → use-change-CQyDpCqw.js} +323 -31
- package/dist/chunks/use-change-CQyDpCqw.js.map +1 -0
- package/dist/chunks/{use-shell-D6kjSPls.js → use-shell-C_NmvCt_.js} +2 -2
- package/dist/chunks/{use-shell-D6kjSPls.js.map → use-shell-C_NmvCt_.js.map} +1 -1
- package/dist/index.d.ts +46 -164
- package/dist/index.js +143 -129
- package/dist/index.js.map +1 -1
- package/dist/pages/account.d.ts +1 -1
- package/dist/pages/account.js +29 -12
- package/dist/pages/account.js.map +1 -1
- package/dist/pages/approval.js +1 -1
- package/dist/pages/audit.js +96 -90
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +1 -1
- package/dist/pages/environment.js +949 -412
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +2 -2
- package/dist/pages/oauth-authorize.js +1 -1
- package/dist/pages/project-access.js +9 -9
- package/dist/pages/project-access.js.map +1 -1
- package/dist/pages/project-environments.js +112 -64
- package/dist/pages/project-environments.js.map +1 -1
- package/dist/pages/project-settings.d.ts +1 -1
- package/dist/pages/project-settings.js +54 -75
- package/dist/pages/project-settings.js.map +1 -1
- package/dist/pages/project.js +3 -7
- package/dist/pages/project.js.map +1 -1
- package/dist/pages/projects.js +50 -77
- package/dist/pages/projects.js.map +1 -1
- package/dist/pages/service-account.js +284 -160
- package/dist/pages/service-account.js.map +1 -1
- package/dist/pages/service-accounts.js +4 -4
- package/dist/pages/settings.js +5 -5
- package/dist/pages/unregistered.js +1 -1
- package/dist/pages/user.js +5 -5
- package/dist/pages/users.js +4 -4
- package/package.json +3 -3
- package/src/components/actions-log.tsx +3 -2
- package/src/components/command-palette.tsx +4 -5
- package/src/components/directory.tsx +7 -14
- package/src/components/generate-value.tsx +15 -7
- package/src/components/missing.tsx +63 -67
- package/src/components/offboarding.tsx +1 -1
- package/src/components/personal-tokens.tsx +131 -0
- package/src/components/principal-page.tsx +30 -17
- package/src/components/regenerate.tsx +72 -0
- package/src/components/service-tokens.tsx +5 -14
- package/src/components/shell.tsx +79 -75
- package/src/components/trusted-workloads.tsx +179 -19
- package/src/components/ui.tsx +35 -25
- package/src/lib/audit-sentences.ts +100 -12
- package/src/lib/bindings.ts +41 -3
- package/src/lib/changes.ts +215 -29
- package/src/lib/clipboard.ts +40 -0
- package/src/lib/copy-attempts.ts +103 -0
- package/src/lib/dismissal.ts +24 -0
- package/src/lib/generate.ts +3 -146
- package/src/lib/optimistic.ts +3 -1
- package/src/lib/queries.ts +121 -17
- package/src/lib/recipes.ts +63 -0
- package/src/lib/reveal.ts +7 -1
- package/src/lib/row-reads.ts +64 -0
- package/src/lib/secret-edit-batch.ts +64 -5
- package/src/options.ts +43 -51
- package/src/pages/account.tsx +27 -5
- package/src/pages/audit.tsx +38 -31
- package/src/pages/environment.tsx +655 -121
- package/src/pages/project-access.tsx +1 -1
- package/src/pages/project-environments.tsx +92 -45
- package/src/pages/project-settings.tsx +9 -20
- package/src/pages/project.tsx +1 -5
- package/src/pages/projects.tsx +13 -28
- package/src/parity.ts +20 -4
- package/src/styles/globals.css +143 -131
- package/dist/chunks/audit-sentence-CUUMshIp.js.map +0 -1
- package/dist/chunks/directory-DrtdKny2.js.map +0 -1
- package/dist/chunks/offboarding-C7ECW5o0.js.map +0 -1
- package/dist/chunks/principal-page-CB6dAABC.js.map +0 -1
- package/dist/chunks/project-environments-lEzFHUt4.js +0 -11
- package/dist/chunks/project-environments-lEzFHUt4.js.map +0 -1
- package/dist/chunks/queries-DgQo3mC-.js.map +0 -1
- package/dist/chunks/ui-Br-dNUTc.js.map +0 -1
- package/dist/chunks/use-change-By4cG8bT.js.map +0 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { SecretKey } from '@coffre/client';
|
|
2
|
+
import { describeRecipe, parseRecipe, recipeProblem, type Generation } from '@coffre/core/recipe';
|
|
3
|
+
|
|
4
|
+
import { Generate } from './icons';
|
|
5
|
+
import { ConfirmDialog, Tip } from './ui';
|
|
6
|
+
|
|
7
|
+
/** What a generated key's recipe makes, in words; null for one this page does not know. */
|
|
8
|
+
export function recipeInWords(generated: Generation): string | null {
|
|
9
|
+
return recipeProblem(generated.recipe) === null ? describeRecipe(parseRecipe(generated.recipe)) : null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Beside a key whose value was generated: how, on hover or focus. */
|
|
13
|
+
export function RecipeMark({ generated }: { generated: Generation }) {
|
|
14
|
+
const label = `Generated: ${recipeInWords(generated) ?? generated.recipe}`;
|
|
15
|
+
return (
|
|
16
|
+
<Tip label={label}>
|
|
17
|
+
<span className="recipe-mark" tabIndex={0} role="img" aria-label={label}>
|
|
18
|
+
<Generate size={12} />
|
|
19
|
+
</span>
|
|
20
|
+
</Tip>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Asks before regenerating a key by its recipe (`regenerateSecret`, which
|
|
26
|
+
* the row runs on confirm): a new value made in this browser, written as
|
|
27
|
+
* its next version, and never shown. A key pair's either half makes the
|
|
28
|
+
* pair again, both keys in one write, in the environment the page is on.
|
|
29
|
+
*/
|
|
30
|
+
export function RegenerateSecret({
|
|
31
|
+
open,
|
|
32
|
+
onOpenChange,
|
|
33
|
+
place,
|
|
34
|
+
entry,
|
|
35
|
+
generated,
|
|
36
|
+
onConfirm,
|
|
37
|
+
}: {
|
|
38
|
+
open: boolean;
|
|
39
|
+
onOpenChange: (open: boolean) => void;
|
|
40
|
+
/** `project/environment`, where it is written. */
|
|
41
|
+
place: string;
|
|
42
|
+
entry: SecretKey;
|
|
43
|
+
generated: Generation;
|
|
44
|
+
onConfirm: () => void;
|
|
45
|
+
}) {
|
|
46
|
+
const made = recipeInWords(generated);
|
|
47
|
+
const body =
|
|
48
|
+
generated.pair === undefined
|
|
49
|
+
? `A new value, ${made ?? generated.recipe}, is made in this browser and saved as v${(entry.version ?? 0) + 1}. Nobody sees it; whatever reads ${place} gets it from now on.`
|
|
50
|
+
: `A new key pair is made in this browser and saved as ${generated.pair.private} and ${generated.pair.public}, together. Nobody sees it; whatever reads ${place} gets both from now on.`;
|
|
51
|
+
return (
|
|
52
|
+
<ConfirmDialog
|
|
53
|
+
open={open}
|
|
54
|
+
onOpenChange={onOpenChange}
|
|
55
|
+
title={
|
|
56
|
+
<>
|
|
57
|
+
Regenerate <span className="mono">{entry.key}</span>
|
|
58
|
+
{generated.pair !== undefined && ' and its pair'}?
|
|
59
|
+
</>
|
|
60
|
+
}
|
|
61
|
+
body={body}
|
|
62
|
+
detail={
|
|
63
|
+
<p className="hint">
|
|
64
|
+
Recipe <span className="mono">{generated.recipe}</span>
|
|
65
|
+
{generated.pair !== undefined && made !== null && <>: {made}</>}
|
|
66
|
+
</p>
|
|
67
|
+
}
|
|
68
|
+
confirmLabel="Regenerate"
|
|
69
|
+
onConfirm={onConfirm}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TokenRow } from '@coffre/client';
|
|
2
2
|
import { credentialScopeInWords } from '@coffre/core/access';
|
|
3
3
|
import { Fragment, useState } from 'react';
|
|
4
4
|
import { revokeCredential } from '../lib/changes';
|
|
@@ -19,25 +19,16 @@ const LIFETIMES = [30, 90, 180, 365] as const;
|
|
|
19
19
|
* OIDC. A value exists in exactly
|
|
20
20
|
* one place, this dialog, for as long as it stays open: coffre keeps a hash.
|
|
21
21
|
*/
|
|
22
|
-
export function ServiceTokens({ serviceId, tokens, grants }: { serviceId: string; tokens:
|
|
23
|
-
const change = revokeCredential(useCoffre(), serviceId);
|
|
22
|
+
export function ServiceTokens({ serviceId, tokens, grants }: { serviceId: string; tokens: TokenRow[]; grants: HeldGrant[] }) {
|
|
23
|
+
const change = revokeCredential(useCoffre(), memberRef('service', serviceId));
|
|
24
24
|
const revoke = useChange(change);
|
|
25
25
|
const { status, dismiss } = useChangeStatus(change.list.queryKey);
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
28
|
<>
|
|
29
|
-
<Card
|
|
30
|
-
labelledBy="service-tokens"
|
|
31
|
-
title="Bearer tokens"
|
|
32
|
-
description={
|
|
33
|
-
<>
|
|
34
|
-
A long-lived secret, for CI that can't use OIDC. For example, a cron job on your own server runs{' '}
|
|
35
|
-
<span className="mono nowrap">coffre login <url> --token</span> with one. coffre shows it once.
|
|
36
|
-
</>
|
|
37
|
-
}
|
|
38
|
-
>
|
|
29
|
+
<Card labelledBy="service-tokens" title="Bearer tokens">
|
|
39
30
|
{tokens.length === 0 ? (
|
|
40
|
-
<EmptyState title="No bearer tokens"
|
|
31
|
+
<EmptyState title="No bearer tokens" />
|
|
41
32
|
) : (
|
|
42
33
|
<div className="dt-wrap">
|
|
43
34
|
<table className="dt">
|
package/src/components/shell.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
type ReactElement,
|
|
6
6
|
type ReactNode,
|
|
7
7
|
} from 'react';
|
|
8
|
-
import { Link,
|
|
8
|
+
import { Link, useRouterState } from '@tanstack/react-router';
|
|
9
9
|
import { Dialog } from '@base-ui/react/dialog';
|
|
10
10
|
import { Menu } from '@base-ui/react/menu';
|
|
11
11
|
import { INSTANCE_ROLES } from '@coffre/core/access';
|
|
@@ -410,7 +410,7 @@ function Breadcrumbs({
|
|
|
410
410
|
</span>
|
|
411
411
|
<span className="crumb">
|
|
412
412
|
<span className="crumb-link" aria-current="page">
|
|
413
|
-
<span>{projectSlug}</span>
|
|
413
|
+
<span className="crumb-name">{projectSlug}</span>
|
|
414
414
|
</span>
|
|
415
415
|
</span>
|
|
416
416
|
</nav>
|
|
@@ -419,7 +419,8 @@ function Breadcrumbs({
|
|
|
419
419
|
|
|
420
420
|
if (section !== 'projects' || projectSlug === undefined) return null;
|
|
421
421
|
|
|
422
|
-
|
|
422
|
+
// The active projects, and this one even archived: its page is its entry in the list.
|
|
423
|
+
const listed = projects.filter((project) => project.archivedAt === null || project.slug === projectSlug);
|
|
423
424
|
const project = projects.find((entry) => entry.slug === projectSlug);
|
|
424
425
|
|
|
425
426
|
return (
|
|
@@ -431,7 +432,7 @@ function Breadcrumbs({
|
|
|
431
432
|
<span className="crumb-sep" aria-hidden>
|
|
432
433
|
/
|
|
433
434
|
</span>
|
|
434
|
-
<ProjectCrumb slug={projectSlug} current={environmentSlug === undefined} projects={
|
|
435
|
+
<ProjectCrumb slug={projectSlug} current={environmentSlug === undefined} projects={listed} />
|
|
435
436
|
|
|
436
437
|
{environmentSlug !== undefined && (
|
|
437
438
|
<>
|
|
@@ -449,6 +450,11 @@ function Breadcrumbs({
|
|
|
449
450
|
);
|
|
450
451
|
}
|
|
451
452
|
|
|
453
|
+
/**
|
|
454
|
+
* The project you are in, one button that lists every project. Its own
|
|
455
|
+
* page, all its environments, is the current one in that list. Each entry
|
|
456
|
+
* is a link, so the router fetches its page as it is pointed at or focused.
|
|
457
|
+
*/
|
|
452
458
|
function ProjectCrumb({
|
|
453
459
|
slug,
|
|
454
460
|
current,
|
|
@@ -458,46 +464,39 @@ function ProjectCrumb({
|
|
|
458
464
|
current: boolean;
|
|
459
465
|
projects: ProjectSummary[];
|
|
460
466
|
}) {
|
|
461
|
-
const navigate = useNavigate();
|
|
462
467
|
return (
|
|
463
|
-
<
|
|
464
|
-
<
|
|
465
|
-
className="crumb-link"
|
|
466
|
-
|
|
467
|
-
params={{ project: slug }}
|
|
468
|
+
<Menu.Root>
|
|
469
|
+
<Menu.Trigger
|
|
470
|
+
className="crumb-link crumb-switch crumb-project"
|
|
471
|
+
aria-label={`${slug}, switch project`}
|
|
468
472
|
aria-current={current ? 'page' : undefined}
|
|
469
473
|
>
|
|
470
474
|
<Tile name={slug} />
|
|
471
|
-
<span className="crumb-project-name">{slug}</span>
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
</Menu.Item>
|
|
493
|
-
))}
|
|
494
|
-
</Menu.Group>
|
|
495
|
-
</MenuPopup>
|
|
496
|
-
</Menu.Root>
|
|
497
|
-
</span>
|
|
475
|
+
<span className="crumb-name crumb-project-name">{slug}</span>
|
|
476
|
+
<ChevronsUpDown size={14} className="crumb-chevron" />
|
|
477
|
+
</Menu.Trigger>
|
|
478
|
+
<MenuPopup align="start">
|
|
479
|
+
<Menu.Group>
|
|
480
|
+
<Menu.GroupLabel className="menu-label">Projects</Menu.GroupLabel>
|
|
481
|
+
{projects.map((project) => (
|
|
482
|
+
<Menu.LinkItem
|
|
483
|
+
key={project.slug}
|
|
484
|
+
className="menu-item"
|
|
485
|
+
closeOnClick
|
|
486
|
+
render={<Link to="/projects/$project" params={{ project: project.slug }} />}
|
|
487
|
+
>
|
|
488
|
+
<Tile name={project.slug} />
|
|
489
|
+
{project.slug}
|
|
490
|
+
{project.slug === slug && <Check size={14} className="menu-check" />}
|
|
491
|
+
</Menu.LinkItem>
|
|
492
|
+
))}
|
|
493
|
+
</Menu.Group>
|
|
494
|
+
</MenuPopup>
|
|
495
|
+
</Menu.Root>
|
|
498
496
|
);
|
|
499
497
|
}
|
|
500
498
|
|
|
499
|
+
/** The environment you are in, one button that lists its siblings you can open, as links like the project's. */
|
|
501
500
|
function EnvironmentCrumb({
|
|
502
501
|
projectSlug,
|
|
503
502
|
slug,
|
|
@@ -507,45 +506,50 @@ function EnvironmentCrumb({
|
|
|
507
506
|
slug: string;
|
|
508
507
|
environments: ProjectSummary['environments'];
|
|
509
508
|
}) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
<span className="crumb">
|
|
509
|
+
if (environments.length === 0) {
|
|
510
|
+
return (
|
|
513
511
|
<span className="crumb-link" aria-current="page">
|
|
514
|
-
<span>{slug}</span>
|
|
512
|
+
<span className="crumb-name">{slug}</span>
|
|
515
513
|
</span>
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
return (
|
|
517
|
+
<Menu.Root>
|
|
518
|
+
<Menu.Trigger
|
|
519
|
+
className="crumb-link crumb-switch"
|
|
520
|
+
aria-label={`${slug}, switch environment`}
|
|
521
|
+
aria-current="page"
|
|
522
|
+
>
|
|
523
|
+
<span className="crumb-name">{slug}</span>
|
|
524
|
+
<ChevronsUpDown size={14} className="crumb-chevron" />
|
|
525
|
+
</Menu.Trigger>
|
|
526
|
+
<MenuPopup align="start">
|
|
527
|
+
<Menu.Group>
|
|
528
|
+
<Menu.GroupLabel className="menu-label">
|
|
529
|
+
Environments in {projectSlug}
|
|
530
|
+
</Menu.GroupLabel>
|
|
531
|
+
{environments.map((environment) => (
|
|
532
|
+
<Menu.LinkItem
|
|
533
|
+
key={environment.slug}
|
|
534
|
+
className="menu-item"
|
|
535
|
+
closeOnClick
|
|
536
|
+
render={
|
|
537
|
+
<Link
|
|
538
|
+
to="/projects/$project/$environment"
|
|
539
|
+
params={{ project: projectSlug, environment: environment.slug }}
|
|
540
|
+
/>
|
|
541
|
+
}
|
|
542
|
+
>
|
|
543
|
+
<span className="mono">{environment.slug}</span>
|
|
544
|
+
<span className="menu-hint">
|
|
545
|
+
{environment.details?.secretCount ?? 0} secret
|
|
546
|
+
{environment.details?.secretCount === 1 ? '' : 's'}
|
|
547
|
+
</span>
|
|
548
|
+
{environment.slug === slug && <Check size={14} className="menu-check" />}
|
|
549
|
+
</Menu.LinkItem>
|
|
550
|
+
))}
|
|
551
|
+
</Menu.Group>
|
|
552
|
+
</MenuPopup>
|
|
553
|
+
</Menu.Root>
|
|
550
554
|
);
|
|
551
555
|
}
|
|
@@ -1,9 +1,25 @@
|
|
|
1
|
-
import type { BindingPlan, BindingView, CoffreClient } from '@coffre/client';
|
|
1
|
+
import type { BindingPlan, BindingView, CoffreClient, KeysPlan } from '@coffre/client';
|
|
2
2
|
import { credentialScopeInWords } from '@coffre/core/access';
|
|
3
3
|
import { claimValues, EVENT_EXPOSURE, githubEventsAt, GITLAB_PIPELINE_SOURCES } from '@coffre/core/workloads';
|
|
4
4
|
import { useQuery } from '@tanstack/react-query';
|
|
5
5
|
import { Fragment, useEffect, useState } from 'react';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
askedScope,
|
|
8
|
+
bindingOf,
|
|
9
|
+
EMPTY_FORM,
|
|
10
|
+
githubTarget,
|
|
11
|
+
keySetOf,
|
|
12
|
+
keysOf,
|
|
13
|
+
listedIds,
|
|
14
|
+
listingGap,
|
|
15
|
+
planned,
|
|
16
|
+
summary,
|
|
17
|
+
type Form,
|
|
18
|
+
type GitHubLookup,
|
|
19
|
+
type KeySet,
|
|
20
|
+
type RefKind,
|
|
21
|
+
type ScopeChoice,
|
|
22
|
+
} from '../lib/bindings';
|
|
7
23
|
import { removeBinding } from '../lib/changes';
|
|
8
24
|
import { memberRef, statusOf, useCoffre } from '../lib/coffre';
|
|
9
25
|
import { affects, queries } from '../lib/queries';
|
|
@@ -16,7 +32,7 @@ import { RowFailure, RowPending, rowClass } from './row-state';
|
|
|
16
32
|
import { Card } from './page';
|
|
17
33
|
import { ScopePicker, wholeScope, type HeldGrant } from './scope-picker';
|
|
18
34
|
import { ConfirmButton, EmptyState, ErrorLine, Modal, Notice, Spinner, Timestamp } from './ui';
|
|
19
|
-
import { CheckCircle, GitHub, Link, Plus, X } from './icons';
|
|
35
|
+
import { CheckCircle, GitHub, Key, Link, Plus, X } from './icons';
|
|
20
36
|
|
|
21
37
|
/**
|
|
22
38
|
* The CI runs that may sign in as a service, by the ID token their platform
|
|
@@ -31,18 +47,9 @@ export function TrustedWorkloads({ serviceId, bindings, grants }: { serviceId: s
|
|
|
31
47
|
|
|
32
48
|
return (
|
|
33
49
|
<>
|
|
34
|
-
<Card
|
|
35
|
-
labelledBy="trusted-workloads"
|
|
36
|
-
title="Sign in with OIDC"
|
|
37
|
-
description={
|
|
38
|
-
<>
|
|
39
|
-
A CI run signs in with the ID token GitHub Actions or GitLab gives it, so there is no secret to store. For example,{' '}
|
|
40
|
-
<span className="mono">deploy.yml</span> in <span className="mono">acme/api</span>, on pushes to <span className="mono">main</span>.
|
|
41
|
-
</>
|
|
42
|
-
}
|
|
43
|
-
>
|
|
50
|
+
<Card labelledBy="trusted-workloads" title="Sign in with OIDC">
|
|
44
51
|
{bindings.length === 0 ? (
|
|
45
|
-
<EmptyState title="No trust bindings"
|
|
52
|
+
<EmptyState title="No trust bindings" />
|
|
46
53
|
) : (
|
|
47
54
|
<div className="dt-wrap">
|
|
48
55
|
<table className="dt">
|
|
@@ -73,6 +80,7 @@ export function TrustedWorkloads({ serviceId, bindings, grants }: { serviceId: s
|
|
|
73
80
|
<details className="claims">
|
|
74
81
|
<summary>Claims</summary>
|
|
75
82
|
<Claims binding={binding} />
|
|
83
|
+
{binding.keys !== null && <ReplaceKeys serviceId={serviceId} issuer={binding.issuer} bindings={bindings} />}
|
|
76
84
|
</details>
|
|
77
85
|
</span>
|
|
78
86
|
</span>
|
|
@@ -136,7 +144,7 @@ export function TrustedWorkloads({ serviceId, bindings, grants }: { serviceId: s
|
|
|
136
144
|
);
|
|
137
145
|
}
|
|
138
146
|
|
|
139
|
-
function Claims({ binding }: { binding: Pick<BindingPlan, 'issuer' | 'jwksUri' | 'claims'> }) {
|
|
147
|
+
function Claims({ binding }: { binding: Pick<BindingPlan, 'issuer' | 'jwksUri' | 'keys' | 'claims'> }) {
|
|
140
148
|
return (
|
|
141
149
|
<table className="claims-table">
|
|
142
150
|
<tbody>
|
|
@@ -152,13 +160,136 @@ function Claims({ binding }: { binding: Pick<BindingPlan, 'issuer' | 'jwksUri' |
|
|
|
152
160
|
))}
|
|
153
161
|
<tr>
|
|
154
162
|
<th>keys</th>
|
|
155
|
-
<td className="mono">{binding
|
|
163
|
+
<td className="mono">{keysOf(binding)}</td>
|
|
156
164
|
</tr>
|
|
157
165
|
</tbody>
|
|
158
166
|
</table>
|
|
159
167
|
);
|
|
160
168
|
}
|
|
161
169
|
|
|
170
|
+
/**
|
|
171
|
+
* New keys, pasted, for the service's bindings on an issuer whose keys they
|
|
172
|
+
* carry: when the issuer rotates its keys. Each binding is replaced by one
|
|
173
|
+
* the same but for them, as the review says before anything is saved.
|
|
174
|
+
*/
|
|
175
|
+
function ReplaceKeys({ serviceId, issuer, bindings }: { serviceId: string; issuer: string; bindings: BindingView[] }) {
|
|
176
|
+
const [open, setOpen] = useState(false);
|
|
177
|
+
const [text, setText] = useState('');
|
|
178
|
+
// The plan, with the keys it was made for: Save sends those, whatever the field says by then.
|
|
179
|
+
const [preview, setPreview] = useState<{ plan: KeysPlan; jwks: KeySet } | null>(null);
|
|
180
|
+
const plan = preview?.plan ?? null;
|
|
181
|
+
const coffre = useCoffre();
|
|
182
|
+
const member = memberRef('service', serviceId);
|
|
183
|
+
const { pending, error, setError, run } = useAction();
|
|
184
|
+
const on = bindings.filter((binding) => binding.issuer === issuer).length;
|
|
185
|
+
|
|
186
|
+
function close() {
|
|
187
|
+
setOpen(false);
|
|
188
|
+
setText('');
|
|
189
|
+
setPreview(null);
|
|
190
|
+
setError(null);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function review() {
|
|
194
|
+
let jwks: KeySet;
|
|
195
|
+
try {
|
|
196
|
+
const pasted = keySetOf(text);
|
|
197
|
+
if (pasted === undefined) throw new Error("Paste the issuer's key set");
|
|
198
|
+
jwks = pasted;
|
|
199
|
+
} catch (problem) {
|
|
200
|
+
setError((problem as Error).message);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
void run(() => coffre.bindings.previewKeys(member, { issuer, jwks }), { affects: [], onSuccess: (next) => setPreview({ plan: next, jwks }) });
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<>
|
|
208
|
+
<button className="act" type="button" onClick={() => setOpen(true)}>
|
|
209
|
+
<Key size={13} />
|
|
210
|
+
Replace keys
|
|
211
|
+
</button>
|
|
212
|
+
<Modal open={open} onOpenChange={(next) => (next ? setOpen(true) : close())} title={preview === null ? 'Replace keys' : 'Review the keys'}>
|
|
213
|
+
{preview === null || plan === null ? (
|
|
214
|
+
<form
|
|
215
|
+
className="form"
|
|
216
|
+
onSubmit={(event) => {
|
|
217
|
+
event.preventDefault();
|
|
218
|
+
review();
|
|
219
|
+
}}
|
|
220
|
+
>
|
|
221
|
+
<p>
|
|
222
|
+
The {on === 1 ? 'binding' : `${on} bindings`} of <span className="mono">service:{serviceId}</span> on{' '}
|
|
223
|
+
<span className="mono">{issuer}</span> will verify tokens with these keys alone. While the issuer rotates, paste a set that
|
|
224
|
+
holds the old key and the new, and tokens signed with either sign in.
|
|
225
|
+
</p>
|
|
226
|
+
<label className="field">
|
|
227
|
+
<span className="label">Keys</span>
|
|
228
|
+
<textarea
|
|
229
|
+
className="input mono"
|
|
230
|
+
rows={6}
|
|
231
|
+
value={text}
|
|
232
|
+
spellCheck={false}
|
|
233
|
+
placeholder='{ "keys": [ … ] }'
|
|
234
|
+
onChange={(event) => {
|
|
235
|
+
setText(event.target.value);
|
|
236
|
+
setError(null);
|
|
237
|
+
}}
|
|
238
|
+
/>
|
|
239
|
+
<span className="hint">
|
|
240
|
+
From a Kubernetes cluster: <span className="mono">kubectl get --raw /openid/v1/jwks</span>
|
|
241
|
+
</span>
|
|
242
|
+
</label>
|
|
243
|
+
<ErrorLine error={error} />
|
|
244
|
+
<div className="dialog-actions">
|
|
245
|
+
<button className="btn" type="button" onClick={close}>
|
|
246
|
+
Cancel
|
|
247
|
+
</button>
|
|
248
|
+
<button className="btn btn-primary" type="submit" disabled={pending}>
|
|
249
|
+
{pending && <Spinner />}
|
|
250
|
+
Review
|
|
251
|
+
</button>
|
|
252
|
+
</div>
|
|
253
|
+
</form>
|
|
254
|
+
) : (
|
|
255
|
+
<div className="form">
|
|
256
|
+
<p>
|
|
257
|
+
{plan.replaces.length === 1 ? 'Its binding' : `Its ${plan.replaces.length} bindings`} on <span className="mono">{issuer}</span>{' '}
|
|
258
|
+
{plan.replaces.length === 1 ? 'is' : 'are'} replaced by {plan.replaces.length === 1 ? 'one' : 'ones'} the same but for these keys.
|
|
259
|
+
Credentials {plan.replaces.length === 1 ? 'it' : 'they'} issued, five minutes each at most, end at once.
|
|
260
|
+
</p>
|
|
261
|
+
<table className="claims-table">
|
|
262
|
+
<tbody>
|
|
263
|
+
{plan.keys.map((key) => (
|
|
264
|
+
<tr key={key.thumbprint}>
|
|
265
|
+
<th className="mono">{key.alg}</th>
|
|
266
|
+
<td className="mono">{key.kid ?? key.thumbprint}</td>
|
|
267
|
+
</tr>
|
|
268
|
+
))}
|
|
269
|
+
</tbody>
|
|
270
|
+
</table>
|
|
271
|
+
<ErrorLine error={error} />
|
|
272
|
+
<div className="dialog-actions">
|
|
273
|
+
<button className="btn" type="button" onClick={() => setPreview(null)}>
|
|
274
|
+
Back
|
|
275
|
+
</button>
|
|
276
|
+
<button
|
|
277
|
+
className="btn btn-primary"
|
|
278
|
+
type="button"
|
|
279
|
+
disabled={pending}
|
|
280
|
+
onClick={() => void run(() => coffre.bindings.replaceKeys(member, { issuer, jwks: preview.jwks }), { affects: affects.bindings(member), onSuccess: close })}
|
|
281
|
+
>
|
|
282
|
+
{pending && <Spinner />}
|
|
283
|
+
Save keys
|
|
284
|
+
</button>
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
)}
|
|
288
|
+
</Modal>
|
|
289
|
+
</>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
162
293
|
/** Beside `pull_request` and `workflow_run` in the events' list: they run code nobody reviewed, said in full once chosen. */
|
|
163
294
|
function exposureNote(event: string) {
|
|
164
295
|
return EVENT_EXPOSURE[event] === undefined ? null : <span className="tag tag-amber">unreviewed code</span>;
|
|
@@ -259,6 +390,8 @@ function TrustWorkload({ serviceId, grants, bindings }: { serviceId: string; gra
|
|
|
259
390
|
const whole = (): ScopeChoice => ({ scope: wholeScope(grants), chosen: false });
|
|
260
391
|
const [choice, setChoice] = useState(whole);
|
|
261
392
|
const [plan, setPlan] = useState<BindingPlan | null>(null);
|
|
393
|
+
// What the plan was made from: Save sends it, whatever the form says by then.
|
|
394
|
+
const [reviewed, setReviewed] = useState<ReturnType<typeof input> | null>(null);
|
|
262
395
|
const coffre = useCoffre();
|
|
263
396
|
const member = memberRef('service', serviceId);
|
|
264
397
|
const { pending, error, setError, run } = useAction();
|
|
@@ -302,6 +435,7 @@ function TrustWorkload({ serviceId, grants, bindings }: { serviceId: string; gra
|
|
|
302
435
|
// One that replaces bindings reaches what they did unless told: the picker says so, should the person go back.
|
|
303
436
|
onSuccess: (next) => {
|
|
304
437
|
setPlan(next);
|
|
438
|
+
setReviewed(request);
|
|
305
439
|
setChoice((current) => planned(current, next));
|
|
306
440
|
},
|
|
307
441
|
});
|
|
@@ -503,11 +637,37 @@ function TrustWorkload({ serviceId, grants, bindings }: { serviceId: string; gra
|
|
|
503
637
|
|
|
504
638
|
{form.platform === 'other' && (
|
|
505
639
|
<>
|
|
506
|
-
{field('Issuer', 'issuer', {
|
|
640
|
+
{field('Issuer', 'issuer', {
|
|
641
|
+
placeholder: 'https://accounts.google.com',
|
|
642
|
+
hint: form.jwks.trim() === '' ? undefined : 'Exactly as its tokens name it in iss: with its keys pasted below, coffre asks it nothing.',
|
|
643
|
+
})}
|
|
507
644
|
{field('Subject (sub)', 'sub', { mono: true, hint: "You vouch for what this issuer's subject means: a Google service account's unique ID, say." })}
|
|
508
645
|
<label className="field">
|
|
509
646
|
<span className="label">Other claims, one <span className="mono">name=value</span> a line</span>
|
|
510
|
-
<textarea
|
|
647
|
+
<textarea
|
|
648
|
+
className="input mono"
|
|
649
|
+
rows={3}
|
|
650
|
+
value={form.extra}
|
|
651
|
+
spellCheck={false}
|
|
652
|
+
placeholder="kubernetes.io.serviceaccount.uid=…"
|
|
653
|
+
onChange={(event) => set({ extra: event.target.value })}
|
|
654
|
+
/>
|
|
655
|
+
<span className="hint">A nested claim goes by its path, its names joined by dots.</span>
|
|
656
|
+
</label>
|
|
657
|
+
<label className="field">
|
|
658
|
+
<span className="label">Keys (optional)</span>
|
|
659
|
+
<textarea
|
|
660
|
+
className="input mono"
|
|
661
|
+
rows={3}
|
|
662
|
+
value={form.jwks}
|
|
663
|
+
spellCheck={false}
|
|
664
|
+
placeholder='{ "keys": [ … ] }'
|
|
665
|
+
onChange={(event) => set({ jwks: event.target.value })}
|
|
666
|
+
/>
|
|
667
|
+
<span className="hint">
|
|
668
|
+
Left empty, coffre fetches the issuer's keys. Paste them for one it cannot reach, such as a private Kubernetes cluster:{' '}
|
|
669
|
+
<span className="mono">kubectl get --raw /openid/v1/jwks</span>
|
|
670
|
+
</span>
|
|
511
671
|
</label>
|
|
512
672
|
</>
|
|
513
673
|
)}
|
|
@@ -557,7 +717,7 @@ function TrustWorkload({ serviceId, grants, bindings }: { serviceId: string; gra
|
|
|
557
717
|
type="button"
|
|
558
718
|
disabled={pending}
|
|
559
719
|
// What the review said it reaches, whatever the account holds by now.
|
|
560
|
-
onClick={() => void run(() => coffre.bindings.create(member, { ...
|
|
720
|
+
onClick={() => void run(() => coffre.bindings.create(member, { ...reviewed!, scope: plan.scope }), { affects: affects.bindings(member), onSuccess: close })}
|
|
561
721
|
>
|
|
562
722
|
{pending && <Spinner />}
|
|
563
723
|
Save binding
|