@coffre/ui 0.2.0 → 0.4.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-BhHmvQX_.js +660 -0
- package/dist/chunks/audit-sentence-BhHmvQX_.js.map +1 -0
- package/dist/chunks/delete-place-CRX7ntE8.js +206 -0
- package/dist/chunks/delete-place-CRX7ntE8.js.map +1 -0
- package/dist/chunks/{directory-CSjWWUQ1.js → directory-zr3ek7Mc.js} +175 -60
- package/dist/chunks/directory-zr3ek7Mc.js.map +1 -0
- package/dist/chunks/folders-DoBmCwOi.js +207 -0
- package/dist/chunks/folders-DoBmCwOi.js.map +1 -0
- package/dist/chunks/grants-Cw1FyGID.js +669 -0
- package/dist/chunks/grants-Cw1FyGID.js.map +1 -0
- package/dist/chunks/offboarding-CE6d7um1.js +305 -0
- package/dist/chunks/offboarding-CE6d7um1.js.map +1 -0
- package/dist/chunks/one-time-DXEl9hbg.js +35 -0
- package/dist/chunks/one-time-DXEl9hbg.js.map +1 -0
- package/dist/chunks/page-DvsgZ2Hd.js +391 -0
- package/dist/chunks/page-DvsgZ2Hd.js.map +1 -0
- package/dist/chunks/principal-BIN-xwZw.js +42 -0
- package/dist/chunks/principal-BIN-xwZw.js.map +1 -0
- package/dist/chunks/{principal-page-D_91OA0l.js → principal-page-DhjO76GH.js} +245 -251
- package/dist/chunks/principal-page-DhjO76GH.js.map +1 -0
- package/dist/chunks/project-page-SRCtRe2g.js +17 -0
- package/dist/chunks/project-page-SRCtRe2g.js.map +1 -0
- package/dist/chunks/{queries-CQ81o4so.js → queries-DVR_i3rA.js} +132 -30
- package/dist/chunks/queries-DVR_i3rA.js.map +1 -0
- package/dist/chunks/references-B6pLT1uQ.js +343 -0
- package/dist/chunks/references-B6pLT1uQ.js.map +1 -0
- package/dist/chunks/{row-state-0PsrEzOL.js → row-state-DOPUsjQK.js} +3 -3
- package/dist/chunks/{row-state-0PsrEzOL.js.map → row-state-DOPUsjQK.js.map} +1 -1
- package/dist/chunks/signin-errors--ykMFuqN.js +57 -0
- package/dist/chunks/signin-errors--ykMFuqN.js.map +1 -0
- package/dist/chunks/tabs-BmwKfUeK.js +22 -0
- package/dist/chunks/tabs-BmwKfUeK.js.map +1 -0
- package/dist/chunks/{theme-B2vQolVR.js → theme-DJuz-xLM.js} +3 -3
- package/dist/chunks/{theme-B2vQolVR.js.map → theme-DJuz-xLM.js.map} +1 -1
- package/dist/chunks/{ui-DixXLQvQ.js → ui-DJje3gST.js} +6 -3
- package/dist/chunks/ui-DJje3gST.js.map +1 -0
- package/dist/chunks/{use-change-c6CeLRin.js → use-change-DUiGO19U.js} +52 -21
- package/dist/chunks/use-change-DUiGO19U.js.map +1 -0
- package/dist/chunks/{use-shell-jxd7Tzd-.js → use-shell-rNKfGjdj.js} +3 -3
- package/dist/chunks/{use-shell-jxd7Tzd-.js.map → use-shell-rNKfGjdj.js.map} +1 -1
- package/dist/chunks/validation-D312_NLf.js +87 -0
- package/dist/chunks/validation-D312_NLf.js.map +1 -0
- package/dist/index.d.ts +361 -27
- package/dist/index.js +188 -98
- package/dist/index.js.map +1 -1
- package/dist/pages/account.d.ts +2 -2
- package/dist/pages/account.js +297 -135
- package/dist/pages/account.js.map +1 -1
- package/dist/pages/approval.d.ts +9 -0
- package/dist/pages/approval.js +207 -0
- package/dist/pages/approval.js.map +1 -0
- package/dist/pages/audit.js +17 -542
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +2 -3
- package/dist/pages/device-login.js.map +1 -1
- package/dist/pages/environment.js +647 -257
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +18 -7
- package/dist/pages/login.js.map +1 -1
- package/dist/pages/oauth-authorize.d.ts +10 -0
- package/dist/pages/oauth-authorize.js +249 -0
- package/dist/pages/oauth-authorize.js.map +1 -0
- package/dist/pages/project-access.d.ts +6 -0
- package/dist/pages/project-access.js +370 -0
- package/dist/pages/project-access.js.map +1 -0
- package/dist/pages/project-environments.d.ts +4 -0
- package/dist/pages/project-environments.js +593 -0
- package/dist/pages/project-environments.js.map +1 -0
- package/dist/pages/project-settings.d.ts +4 -0
- package/dist/pages/project-settings.js +242 -0
- package/dist/pages/project-settings.js.map +1 -0
- package/dist/pages/project.d.ts +10 -2
- package/dist/pages/project.js +57 -934
- package/dist/pages/project.js.map +1 -1
- package/dist/pages/projects.js +53 -21
- package/dist/pages/projects.js.map +1 -1
- package/dist/pages/service-account.d.ts +10 -0
- package/dist/pages/{token.js → service-account.js} +115 -56
- package/dist/pages/service-account.js.map +1 -0
- package/dist/pages/service-accounts.d.ts +3 -0
- package/dist/pages/service-accounts.js +38 -0
- package/dist/pages/service-accounts.js.map +1 -0
- package/dist/pages/settings.d.ts +1 -0
- package/dist/pages/settings.js +104 -42
- package/dist/pages/settings.js.map +1 -1
- package/dist/pages/unregistered.js +2 -3
- package/dist/pages/unregistered.js.map +1 -1
- package/dist/pages/user.d.ts +6 -1
- package/dist/pages/user.js +18 -6
- package/dist/pages/user.js.map +1 -1
- package/dist/pages/users.js +6 -10
- package/dist/pages/users.js.map +1 -1
- package/package.json +3 -3
- package/src/components/actions-log.tsx +117 -0
- package/src/components/audit-sentence.tsx +55 -0
- package/src/components/command-palette.tsx +4 -4
- package/src/components/delete-place.tsx +180 -0
- package/src/components/directory.tsx +259 -110
- package/src/components/every-project.tsx +287 -0
- package/src/components/expiry-field.tsx +42 -0
- package/src/components/folders.tsx +219 -0
- package/src/components/grants.tsx +11 -4
- package/src/components/icons.tsx +2 -0
- package/src/components/missing.tsx +110 -0
- package/src/components/offboarding.tsx +61 -33
- package/src/components/page.tsx +4 -1
- package/src/components/principal-page.tsx +136 -106
- package/src/components/principal-picker.tsx +5 -5
- package/src/components/principal.tsx +4 -4
- package/src/components/references.tsx +323 -0
- package/src/components/service-tokens.tsx +115 -95
- package/src/components/shell.tsx +11 -32
- package/src/components/tabs.tsx +18 -0
- package/src/components/trusted-workloads.tsx +97 -79
- package/src/components/ui.tsx +8 -1
- package/src/index.ts +13 -2
- package/src/layout.tsx +2 -2
- package/src/lib/access-plan.ts +2 -2
- package/src/lib/audit-sentences.ts +161 -77
- package/src/lib/changes.ts +56 -5
- package/src/lib/coffre.ts +3 -2
- package/src/lib/one-time.ts +32 -0
- package/src/lib/project-access.ts +11 -23
- package/src/lib/project-page.ts +14 -0
- package/src/lib/queries.ts +126 -32
- package/src/lib/search.ts +25 -0
- package/src/lib/signin-errors.ts +45 -1
- package/src/lib/validation.ts +14 -0
- package/src/options.ts +187 -35
- package/src/pages/account.tsx +274 -129
- package/src/pages/approval.tsx +197 -0
- package/src/pages/audit.tsx +9 -61
- package/src/pages/environment.tsx +585 -286
- package/src/pages/login.tsx +8 -2
- package/src/pages/oauth-authorize.tsx +233 -0
- package/src/pages/project-access.tsx +219 -0
- package/src/pages/project-environments.tsx +582 -0
- package/src/pages/project-settings.tsx +259 -0
- package/src/pages/project.tsx +52 -879
- package/src/pages/projects.tsx +55 -18
- package/src/pages/service-account.tsx +50 -0
- package/src/pages/{tokens.tsx → service-accounts.tsx} +9 -6
- package/src/pages/settings.tsx +62 -8
- package/src/pages/user.tsx +16 -4
- package/src/pages/users.tsx +2 -2
- package/src/parity.ts +160 -0
- package/src/register.ts +58 -9
- package/src/router.tsx +4 -0
- package/src/shared/models.ts +6 -2
- package/src/styles/globals.css +536 -31
- package/dist/chunks/directory-CSjWWUQ1.js.map +0 -1
- package/dist/chunks/grants-saMQagmG.js +0 -160
- package/dist/chunks/grants-saMQagmG.js.map +0 -1
- package/dist/chunks/icons-D-PfAfnH.js +0 -203
- package/dist/chunks/icons-D-PfAfnH.js.map +0 -1
- package/dist/chunks/offboarding-C6l30DZR.js +0 -263
- package/dist/chunks/offboarding-C6l30DZR.js.map +0 -1
- package/dist/chunks/page-C5HcNqf2.js +0 -190
- package/dist/chunks/page-C5HcNqf2.js.map +0 -1
- package/dist/chunks/principal-page-D_91OA0l.js.map +0 -1
- package/dist/chunks/queries-CQ81o4so.js.map +0 -1
- package/dist/chunks/signin-errors-BEFlVDbQ.js +0 -30
- package/dist/chunks/signin-errors-BEFlVDbQ.js.map +0 -1
- package/dist/chunks/ui-DixXLQvQ.js.map +0 -1
- package/dist/chunks/use-action-CWsg_YWU.js +0 -49
- package/dist/chunks/use-action-CWsg_YWU.js.map +0 -1
- package/dist/chunks/use-change-c6CeLRin.js.map +0 -1
- package/dist/chunks/validation-BQtqPe2V.js +0 -29
- package/dist/chunks/validation-BQtqPe2V.js.map +0 -1
- package/dist/pages/token.d.ts +0 -3
- package/dist/pages/token.js.map +0 -1
- package/dist/pages/tokens.d.ts +0 -3
- package/dist/pages/tokens.js +0 -39
- package/dist/pages/tokens.js.map +0 -1
- package/dist/project-BqIy8gYR.d.ts +0 -5
- package/src/lib/instance.ts +0 -13
- package/src/pages/token.tsx +0 -34
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { Fragment, useState } from 'react';
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
3
|
import { Menu } from '@base-ui/react/menu';
|
|
3
4
|
import { changeRole, directoryList, invite, removeMember, type InviteVars } from '../lib/changes';
|
|
4
5
|
import { memberRef, useCoffre } from '../lib/coffre';
|
|
6
|
+
import { queries } from '../lib/queries';
|
|
7
|
+
import { useShell } from '../lib/use-shell';
|
|
5
8
|
import { useChange, useChangeStatus } from '../lib/use-change';
|
|
6
9
|
import type { DirectoryPrincipal } from '../shared/models';
|
|
7
10
|
import { RowFailure, RowPending, rowClass } from './row-state';
|
|
8
|
-
import { ConfirmDialog, EmptyState, MenuPopup, Modal, Spinner, Toggletip } from './ui';
|
|
11
|
+
import { ConfirmDialog, EmptyState, MenuPopup, Modal, Spinner, Timestamp, Toggletip } from './ui';
|
|
9
12
|
import { PrincipalLink } from './principal';
|
|
10
|
-
import { Key, Lock, MoreHorizontal, Pencil, Plus, ShieldCheck, User, X } from './icons';
|
|
13
|
+
import { Clock, Folder, GitHub, Key, Link, Lock, MoreHorizontal, Pencil, Plus, ShieldCheck, User, X } from './icons';
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
|
-
* The instance directory, shared by the Users and
|
|
16
|
+
* The instance directory, shared by the Users and Service accounts pages.
|
|
14
17
|
*
|
|
15
18
|
* Both are rows in the same table on the server (principals, typed user or
|
|
16
19
|
* service); the pages split them because people and machines are looked after
|
|
@@ -19,7 +22,7 @@ import { Key, Lock, MoreHorizontal, Pencil, Plus, ShieldCheck, User, X } from '.
|
|
|
19
22
|
|
|
20
23
|
type PrincipalType = DirectoryPrincipal['principalType'];
|
|
21
24
|
|
|
22
|
-
/** How the directory, and its changes, name someone: `user:…`, `token
|
|
25
|
+
/** How the directory, and its changes, name someone to the API: `user:…`, `token:…` (shown `service:…`). */
|
|
23
26
|
export const memberOf = (principal: Pick<DirectoryPrincipal, 'principalType' | 'principalId'>) =>
|
|
24
27
|
memberRef(principal.principalType, principal.principalId);
|
|
25
28
|
|
|
@@ -32,7 +35,7 @@ export const ROLE_LABEL: Record<DirectoryPrincipal['instanceRole'], string> = {
|
|
|
32
35
|
/** What each kind of principal is called in the interface. */
|
|
33
36
|
export const KIND: Record<PrincipalType, string> = {
|
|
34
37
|
user: 'user',
|
|
35
|
-
service: '
|
|
38
|
+
service: 'service account',
|
|
36
39
|
};
|
|
37
40
|
|
|
38
41
|
export function DirectoryTable({
|
|
@@ -46,109 +49,224 @@ export function DirectoryTable({
|
|
|
46
49
|
hasRemoved?: boolean;
|
|
47
50
|
}) {
|
|
48
51
|
const users = principalType === 'user';
|
|
49
|
-
const columns = users ? 4 :
|
|
52
|
+
const columns = users ? 4 : 6;
|
|
50
53
|
const { status, failedAdds, dismiss } = useChangeStatus(directoryList.queryKey);
|
|
51
54
|
const refused = failedAdds<InviteVars>(principals.map(memberOf)).filter(
|
|
52
55
|
({ vars }) => vars.principalType === principalType,
|
|
53
56
|
);
|
|
54
57
|
return (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<
|
|
72
|
-
<
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
<
|
|
77
|
-
{users ? <User size={14} /> : <Key size={14} />}
|
|
78
|
-
{users ? 'Email' : 'Name'}
|
|
79
|
-
</span>
|
|
80
|
-
</th>
|
|
81
|
-
{users && (
|
|
82
|
-
<th className="col-role">
|
|
58
|
+
<>
|
|
59
|
+
<section className="card" aria-label={users ? 'Users' : 'Service accounts'}>
|
|
60
|
+
{principals.length === 0 && refused.length === 0 ? (
|
|
61
|
+
<EmptyState
|
|
62
|
+
title={
|
|
63
|
+
hasRemoved
|
|
64
|
+
? `No active ${KIND[principalType]}s`
|
|
65
|
+
: users
|
|
66
|
+
? 'Nobody is registered'
|
|
67
|
+
: 'No service accounts yet'
|
|
68
|
+
}
|
|
69
|
+
>
|
|
70
|
+
{hasRemoved ? `Add a ${KIND[principalType]}` : `Add the first ${KIND[principalType]}`} to let
|
|
71
|
+
it through the door. Project access is a separate step, granted from each project's page.
|
|
72
|
+
</EmptyState>
|
|
73
|
+
) : (
|
|
74
|
+
<div className="dt-wrap">
|
|
75
|
+
<table className={`dt directory directory-${principalType} stacks${users ? '' : ' stacks-inline'}`}>
|
|
76
|
+
<thead>
|
|
77
|
+
<tr>
|
|
78
|
+
<th className="n">#</th>
|
|
79
|
+
<th className="col-principal">
|
|
83
80
|
<span className="th">
|
|
84
|
-
<
|
|
85
|
-
|
|
81
|
+
{users ? <User size={14} /> : <Key size={14} />}
|
|
82
|
+
{users ? 'Email' : 'Name'}
|
|
86
83
|
</span>
|
|
87
84
|
</th>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
85
|
+
{users ? (
|
|
86
|
+
<th className="col-role">
|
|
87
|
+
<span className="th">
|
|
88
|
+
<ShieldCheck size={14} />
|
|
89
|
+
Instance role
|
|
90
|
+
</span>
|
|
91
|
+
</th>
|
|
92
|
+
) : (
|
|
93
|
+
<>
|
|
94
|
+
<th className="col-signin">
|
|
95
|
+
<span className="th">
|
|
96
|
+
<Link size={14} />
|
|
97
|
+
Signs in with
|
|
98
|
+
</span>
|
|
99
|
+
</th>
|
|
100
|
+
<th className="col-access">
|
|
101
|
+
<span className="th">
|
|
102
|
+
<Folder size={14} />
|
|
103
|
+
Access
|
|
104
|
+
</span>
|
|
105
|
+
</th>
|
|
106
|
+
<th className="col-used">
|
|
107
|
+
<span className="th">
|
|
108
|
+
<Clock size={14} />
|
|
109
|
+
Last used
|
|
110
|
+
</span>
|
|
111
|
+
</th>
|
|
112
|
+
</>
|
|
113
|
+
)}
|
|
114
|
+
<th className="col-actions">
|
|
115
|
+
<span className="visually-hidden">Actions</span>
|
|
116
|
+
</th>
|
|
117
|
+
</tr>
|
|
118
|
+
</thead>
|
|
119
|
+
<tbody>
|
|
120
|
+
{principals.map((principal, index) => {
|
|
121
|
+
const state = status(memberOf(principal));
|
|
122
|
+
return (
|
|
123
|
+
<Fragment key={principal.principalId}>
|
|
124
|
+
<tr className={`row-link ${rowClass(state)}`}>
|
|
125
|
+
<td className="n">{index + 1}</td>
|
|
126
|
+
<td
|
|
127
|
+
className="col-lead"
|
|
128
|
+
data-label={principal.principalType === 'user' ? 'Email' : 'Name'}
|
|
129
|
+
>
|
|
130
|
+
<PrincipalLink
|
|
131
|
+
type={principal.principalType}
|
|
132
|
+
id={principal.principalId}
|
|
133
|
+
stretch
|
|
134
|
+
/>
|
|
114
135
|
</td>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
136
|
+
{users ? (
|
|
137
|
+
<td className="col-role" data-label="Instance role">
|
|
138
|
+
<InstanceRole principal={principal} />
|
|
139
|
+
</td>
|
|
119
140
|
) : (
|
|
120
|
-
<
|
|
141
|
+
<ServiceCells principal={principal} />
|
|
121
142
|
)}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
<td className="col-actions">
|
|
144
|
+
{state.state === 'pending' ? (
|
|
145
|
+
<RowPending status={state} />
|
|
146
|
+
) : (
|
|
147
|
+
<PrincipalActions principal={principal} />
|
|
148
|
+
)}
|
|
149
|
+
</td>
|
|
150
|
+
</tr>
|
|
151
|
+
<RowFailure
|
|
152
|
+
status={state}
|
|
153
|
+
columns={columns}
|
|
154
|
+
onDismiss={() => state.state === 'failed' && dismiss(state.mutationId)}
|
|
155
|
+
/>
|
|
156
|
+
</Fragment>
|
|
157
|
+
);
|
|
158
|
+
})}
|
|
159
|
+
{refused.map(({ mutationId, vars, status: failed }) => (
|
|
160
|
+
<RowFailure
|
|
161
|
+
key={mutationId}
|
|
162
|
+
status={failed}
|
|
163
|
+
columns={columns}
|
|
164
|
+
onDismiss={() => dismiss(mutationId)}
|
|
165
|
+
>
|
|
166
|
+
{vars.principalId} was not added.
|
|
167
|
+
</RowFailure>
|
|
168
|
+
))}
|
|
169
|
+
</tbody>
|
|
170
|
+
</table>
|
|
171
|
+
</div>
|
|
172
|
+
)}
|
|
173
|
+
</section>
|
|
174
|
+
<div className="table-actions">
|
|
175
|
+
<AddPrincipal principalType={principalType} />
|
|
176
|
+
</div>
|
|
177
|
+
</>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const PLATFORM: Record<string, string> = {
|
|
182
|
+
github: 'GitHub',
|
|
183
|
+
'github-reusable': 'GitHub',
|
|
184
|
+
'github-reusable-organization': 'GitHub',
|
|
185
|
+
gitlab: 'GitLab',
|
|
186
|
+
custom: 'OIDC',
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* What someone scanning service accounts wants of each: how it signs in, where
|
|
191
|
+
* it reaches, and whether it is still in use. Access comes with the list; the
|
|
192
|
+
* bindings and tokens are read per row, as its own page reads them.
|
|
193
|
+
*/
|
|
194
|
+
function ServiceCells({ principal }: { principal: DirectoryPrincipal }) {
|
|
195
|
+
const client = useCoffre();
|
|
196
|
+
const { auth, capabilities, features } = useShell();
|
|
197
|
+
const member = memberOf(principal);
|
|
198
|
+
// As `loadServiceDirectory` read them, so these come from its cache.
|
|
199
|
+
const allowed = capabilities.canManageGrants && auth.signin !== null;
|
|
200
|
+
// Not suspended: an account added here is shown at once, its facts when they come.
|
|
201
|
+
const { data: bindings } = useQuery(queries.bindings(client, member, capabilities.canManageGrants && features.workloads));
|
|
202
|
+
const { data: credentials } = useQuery(queries.credentials(client, member, allowed));
|
|
203
|
+
|
|
204
|
+
const platforms = new Map<string, number>();
|
|
205
|
+
const bindingList = bindings?.ok === true ? bindings.bindings : [];
|
|
206
|
+
for (const binding of bindingList) {
|
|
207
|
+
const platform = PLATFORM[binding.profile] ?? 'OIDC';
|
|
208
|
+
platforms.set(platform, (platforms.get(platform) ?? 0) + 1);
|
|
209
|
+
}
|
|
210
|
+
const now = Date.now();
|
|
211
|
+
const tokenList = credentials?.ok === true ? credentials.tokens : [];
|
|
212
|
+
const activeTokens = tokenList.filter((token) => new Date(token.expiresAt).getTime() > now).length;
|
|
213
|
+
const lastUsed = [...bindingList, ...tokenList]
|
|
214
|
+
.map((credential) => credential.lastUsedAt)
|
|
215
|
+
.filter((at): at is string => at !== null)
|
|
216
|
+
.sort()
|
|
217
|
+
.at(-1);
|
|
218
|
+
|
|
219
|
+
const places = [
|
|
220
|
+
...new Set(
|
|
221
|
+
(principal.grants ?? []).map(({ project, environment }) =>
|
|
222
|
+
environment === null ? project : `${project}/${environment}`,
|
|
223
|
+
),
|
|
224
|
+
),
|
|
225
|
+
];
|
|
226
|
+
const projects = new Set((principal.grants ?? []).map((grant) => grant.project));
|
|
227
|
+
const loaded = bindings !== undefined && credentials !== undefined;
|
|
228
|
+
|
|
229
|
+
return (
|
|
230
|
+
<>
|
|
231
|
+
<td className="col-signin" data-label="Signs in with">
|
|
232
|
+
{!loaded ? null : platforms.size === 0 && activeTokens === 0 ? (
|
|
233
|
+
<span className="cell-muted">Nothing yet</span>
|
|
234
|
+
) : (
|
|
235
|
+
<span className="signin-list">
|
|
236
|
+
{[...platforms].map(([platform, count]) => (
|
|
237
|
+
<span key={platform} className="signin-item">
|
|
238
|
+
{platform === 'GitHub' && <GitHub size={12} />}
|
|
239
|
+
{platform}
|
|
240
|
+
{count > 1 && ` ×${count}`}
|
|
241
|
+
</span>
|
|
242
|
+
))}
|
|
243
|
+
{activeTokens > 0 && (
|
|
244
|
+
<span className="signin-item">
|
|
245
|
+
<Key size={12} />
|
|
246
|
+
{activeTokens} token{activeTokens === 1 ? '' : 's'}
|
|
247
|
+
</span>
|
|
248
|
+
)}
|
|
249
|
+
</span>
|
|
250
|
+
)}
|
|
251
|
+
</td>
|
|
252
|
+
<td className="col-access" data-label="Access" title={places.join(', ')}>
|
|
253
|
+
{places.length === 0 ? (
|
|
254
|
+
<span className="cell-muted">None</span>
|
|
255
|
+
) : places.length <= 2 ? (
|
|
256
|
+
<span className="mono">{places.join(', ')}</span>
|
|
257
|
+
) : (
|
|
258
|
+
`${projects.size} project${projects.size === 1 ? '' : 's'}`
|
|
259
|
+
)}
|
|
260
|
+
</td>
|
|
261
|
+
<td className="col-used cell-muted" data-label="Last used">
|
|
262
|
+
{!loaded ? null : lastUsed === undefined ? 'Never' : <Timestamp iso={lastUsed} display="relative" />}
|
|
263
|
+
</td>
|
|
264
|
+
</>
|
|
147
265
|
);
|
|
148
266
|
}
|
|
149
267
|
|
|
150
268
|
/**
|
|
151
|
-
* A user's instance role.
|
|
269
|
+
* A user's instance role. Service accounts have none worth showing: every one is a
|
|
152
270
|
* plain member. A root admin's role comes from the deployment, so its tag says
|
|
153
271
|
* so on hover or tap instead of offering a menu that could not work.
|
|
154
272
|
*/
|
|
@@ -296,21 +414,7 @@ export function PrincipalActions({
|
|
|
296
414
|
Remove <span className="mono">{principal.principalId}</span>?
|
|
297
415
|
</>
|
|
298
416
|
}
|
|
299
|
-
body={
|
|
300
|
-
principal.principalType === 'user' ? (
|
|
301
|
-
<>
|
|
302
|
-
They are signed out everywhere, and their CLI logins, linked sign-in accounts and
|
|
303
|
-
project permissions are revoked at once. Their past actions stay in the audit log,
|
|
304
|
-
and their page then lists the values they saw, to rotate.
|
|
305
|
-
</>
|
|
306
|
-
) : (
|
|
307
|
-
<>
|
|
308
|
-
Every token issued to it stops working and its project permissions are revoked at
|
|
309
|
-
once, including for anything running with it right now. Its past actions stay in
|
|
310
|
-
the audit log, and its page then lists the values it read, to rotate.
|
|
311
|
-
</>
|
|
312
|
-
)
|
|
313
|
-
}
|
|
417
|
+
body={<RemovalPreview principal={principal} open={confirming} />}
|
|
314
418
|
confirmLabel={`Remove ${kind}`}
|
|
315
419
|
onConfirm={() => remove(principal)}
|
|
316
420
|
/>
|
|
@@ -318,6 +422,51 @@ export function PrincipalActions({
|
|
|
318
422
|
);
|
|
319
423
|
}
|
|
320
424
|
|
|
425
|
+
const plural = (count: number, one: string) => `${count} ${one}${count === 1 ? '' : 's'}`;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* What removing someone would do, read when its dialog opens, as `coffre
|
|
429
|
+
* offboard` previews it before `--apply`: every way in it revokes, and what
|
|
430
|
+
* they leave behind to rotate.
|
|
431
|
+
*/
|
|
432
|
+
function RemovalPreview({ principal, open }: { principal: DirectoryPrincipal; open: boolean }) {
|
|
433
|
+
const { capabilities } = useShell();
|
|
434
|
+
const person = principal.principalType === 'user';
|
|
435
|
+
const { data, isPending } = useQuery({
|
|
436
|
+
...queries.report(useCoffre(), memberOf(principal), capabilities.canManageGrants),
|
|
437
|
+
enabled: open,
|
|
438
|
+
});
|
|
439
|
+
const report = data?.ok === true ? data.report : null;
|
|
440
|
+
if (isPending) {
|
|
441
|
+
return (
|
|
442
|
+
<>
|
|
443
|
+
<Spinner size={13} /> Reading what {person ? 'they hold' : 'it holds'}…
|
|
444
|
+
</>
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
if (report === null) {
|
|
448
|
+
return person
|
|
449
|
+
? 'They are signed out everywhere, and their sign-in accounts and project access are revoked at once.'
|
|
450
|
+
: 'Its bearer tokens and trust bindings stop working, and its project access is revoked at once.';
|
|
451
|
+
}
|
|
452
|
+
const { live } = report;
|
|
453
|
+
const revokes = person
|
|
454
|
+
? [plural(live.grants, 'grant'), plural(live.sessions, 'session'), plural(live.identities, 'linked sign-in account')]
|
|
455
|
+
: [plural(live.grants, 'grant'), plural(live.tokens, 'bearer token')];
|
|
456
|
+
return (
|
|
457
|
+
<>
|
|
458
|
+
Removing revokes {revokes.join(', ')} at once
|
|
459
|
+
{person ? '' : ', and its trust bindings, including for anything running as it now'}.{' '}
|
|
460
|
+
{report.exposed.length === 0
|
|
461
|
+
? `No value ${person ? 'they' : 'it'} saw is still current.`
|
|
462
|
+
: `${plural(report.exposed.length, 'value')} ${person ? 'they' : 'it'} saw ${report.exposed.length === 1 ? 'is' : 'are'} still current: ${person ? 'their' : 'its'} page lists them, to rotate.`}
|
|
463
|
+
{report.issuedTokens.length > 0 &&
|
|
464
|
+
` ${plural(report.issuedTokens.length, 'bearer token')} ${person ? 'they' : 'it'} issued still ${report.issuedTokens.length === 1 ? 'works' : 'work'}.`}{' '}
|
|
465
|
+
{person ? 'Their' : 'Its'} past actions stay in the audit log.
|
|
466
|
+
</>
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
|
|
321
470
|
export function AddPrincipal({ principalType }: { principalType: PrincipalType }) {
|
|
322
471
|
const [open, setOpen] = useState(false);
|
|
323
472
|
const [principalId, setPrincipalId] = useState('');
|
|
@@ -355,7 +504,7 @@ export function AddPrincipal({ principalType }: { principalType: PrincipalType }
|
|
|
355
504
|
>
|
|
356
505
|
<label className="field">
|
|
357
506
|
<span className="label">
|
|
358
|
-
{principalType === 'user' ? 'Cloudflare Access email' : 'Service
|
|
507
|
+
{principalType === 'user' ? 'Cloudflare Access email' : 'Service account name'}
|
|
359
508
|
</span>
|
|
360
509
|
<input
|
|
361
510
|
className="input input-mono"
|
|
@@ -407,7 +556,7 @@ function RoleField({
|
|
|
407
556
|
<option value="owner">Owner</option>
|
|
408
557
|
</select>
|
|
409
558
|
<span className="hint">
|
|
410
|
-
Owners manage users and
|
|
559
|
+
Owners manage users and service accounts, can create projects, and read the whole audit log.
|
|
411
560
|
Neither role reads a secret without a project grant.
|
|
412
561
|
</span>
|
|
413
562
|
</label>
|