@contember/create 2.2.0-alpha.1 → 2.2.0-alpha.11
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/CLAUDE.md +22 -0
- package/dist/development/run.cjs +7 -7
- package/dist/development/run.cjs.map +1 -1
- package/dist/development/run.js +8 -8
- package/dist/development/run.js.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs +27 -13
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.js +28 -14
- package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.cjs +72 -60
- package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.js +72 -60
- package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/production/run.cjs +7 -7
- package/dist/production/run.cjs.map +1 -1
- package/dist/production/run.js +8 -8
- package/dist/production/run.js.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs +27 -13
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.js +28 -14
- package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.cjs +72 -60
- package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.js +72 -60
- package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/types/commands/WorkspaceCreateCommand.d.ts +15 -3
- package/dist/types/commands/WorkspaceCreateCommand.d.ts.map +1 -1
- package/dist/types/lib/FileSystem.d.ts.map +1 -1
- package/dist/types/lib/TemplateInstaller.d.ts +9 -1
- package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/resources/templates/default/README.md +3 -1
- package/resources/templates/default/admin/app/components/navigation.tsx +95 -8
- package/resources/templates/default/admin/app/pages/tenant.tsx +328 -77
- package/resources/templates/default/admin/entrypoint/components/login.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/magicLink.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/magicLinkSent.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/passwordReset.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/resetRequest.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/resetRequestSuccess.tsx +1 -1
- package/resources/templates/default/admin/lib/tenant/config/auth-policy-list.tsx +86 -0
- package/resources/templates/default/admin/lib/tenant/config/common.tsx +71 -0
- package/resources/templates/default/admin/lib/tenant/config/identity-provider-list.tsx +113 -0
- package/resources/templates/default/admin/lib/tenant/config/index.ts +5 -0
- package/resources/templates/default/admin/lib/tenant/config/mail-template-list.tsx +108 -0
- package/resources/templates/default/admin/lib/tenant/config/tenant-config-view.tsx +182 -0
- package/resources/templates/default/admin/lib/tenant/dict.ts +450 -4
- package/resources/templates/default/admin/lib/tenant/errors.ts +10 -0
- package/resources/templates/default/admin/lib/tenant/forms/add-project-member.tsx +57 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-my-profile.tsx +40 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-profile.tsx +55 -0
- package/resources/templates/default/admin/lib/tenant/forms/common.tsx +9 -2
- package/resources/templates/default/admin/lib/tenant/forms/create-global-api-key.tsx +69 -0
- package/resources/templates/default/admin/lib/tenant/forms/global-roles-control.tsx +113 -0
- package/resources/templates/default/admin/lib/tenant/forms/index.ts +11 -0
- package/resources/templates/default/admin/lib/tenant/forms/invite.tsx +42 -4
- package/resources/templates/default/admin/lib/tenant/forms/login.tsx +4 -10
- package/resources/templates/default/admin/lib/tenant/forms/memberships-control.tsx +3 -1
- package/resources/templates/default/admin/lib/tenant/forms/mfa-code-fields.tsx +81 -0
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin.tsx +4 -10
- package/resources/templates/default/admin/lib/tenant/forms/set-person-password.tsx +58 -0
- package/resources/templates/default/admin/lib/tenant/forms/set-project-secret.tsx +59 -0
- package/resources/templates/default/admin/lib/tenant/forms/sign-up.tsx +73 -0
- package/resources/templates/default/admin/lib/tenant/hooks/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/idp/identity-provider-connections.tsx +124 -0
- package/resources/templates/default/admin/lib/tenant/idp/index.ts +1 -0
- package/resources/templates/default/admin/lib/tenant/index.ts +7 -0
- package/resources/templates/default/admin/lib/tenant/listing/api-key-list.tsx +160 -22
- package/resources/templates/default/admin/lib/tenant/listing/auth-log-list.tsx +179 -0
- package/resources/templates/default/admin/lib/tenant/listing/global-api-key-list.tsx +149 -0
- package/resources/templates/default/admin/lib/tenant/listing/index.ts +7 -0
- package/resources/templates/default/admin/lib/tenant/listing/member-delete-dialog.tsx +1 -1
- package/resources/templates/default/admin/lib/tenant/listing/member-list.tsx +20 -11
- package/resources/templates/default/admin/lib/tenant/listing/mfa.tsx +29 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-actions.tsx +179 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-detail.tsx +141 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-list.tsx +13 -2
- package/resources/templates/default/admin/lib/tenant/listing/persons-list.tsx +128 -0
- package/resources/templates/default/admin/lib/tenant/listing/project-secret-list.tsx +82 -0
- package/resources/templates/default/admin/lib/tenant/otp/backup-codes.tsx +81 -0
- package/resources/templates/default/admin/lib/tenant/otp/email-otp-setup.tsx +133 -0
- package/resources/templates/default/admin/lib/tenant/otp/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/security/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/security/passwordless-toggle.tsx +63 -0
- package/resources/templates/default/admin/lib/tenant/security/session-list.tsx +143 -0
- package/resources/templates/default/admin/package.json +1 -0
- package/resources/templates/default/docker/object-storage/README.md +13 -0
- package/resources/templates/default/docker/object-storage/identities.json +13 -0
- package/resources/templates/default/docker-compose.yaml +29 -7
- package/src/commands/WorkspaceCreateCommand.ts +42 -14
- package/src/lib/TemplateInstaller.ts +87 -69
- package/src/run.ts +8 -7
- package/tests/cases/unit/create-process.test.ts +66 -0
- package/tests/cases/unit/template-installer-cleanup.test.ts +150 -0
- package/tests/cases/unit/workspace-create.test.ts +81 -0
|
@@ -1,19 +1,51 @@
|
|
|
1
1
|
import { useProjectSlug } from '@contember/react-client'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
AddProjectMemberForm,
|
|
4
|
+
ChangeMyPasswordForm,
|
|
5
|
+
ChangeMyProfileForm,
|
|
6
|
+
CreateApiKeyForm,
|
|
7
|
+
CreateGlobalApiKeyForm,
|
|
8
|
+
InviteForm,
|
|
9
|
+
SetProjectSecretForm,
|
|
10
|
+
useIdentity,
|
|
11
|
+
} from '@contember/react-identity'
|
|
12
|
+
import { KeyRoundIcon, LockKeyholeIcon, ScrollTextIcon, SettingsIcon, UserRoundIcon, UsersIcon } from 'lucide-react'
|
|
13
|
+
import { ReactNode, useRef, useState } from 'react'
|
|
5
14
|
import { Slots } from '~/lib/layout'
|
|
6
15
|
import {
|
|
16
|
+
AddProjectMemberFormFields,
|
|
7
17
|
ApiKeyList,
|
|
18
|
+
ApiKeyListController,
|
|
19
|
+
AuthLogList,
|
|
20
|
+
AuthPolicyList,
|
|
21
|
+
BackupCodes,
|
|
8
22
|
ChangeMyPasswordFormFields,
|
|
23
|
+
ChangeMyProfileFormFields,
|
|
9
24
|
CreateApiKeyFormFields,
|
|
25
|
+
CreateGlobalApiKeyFormFields,
|
|
26
|
+
EmailOtpSetup,
|
|
27
|
+
GlobalApiKeyList,
|
|
28
|
+
GlobalApiKeyListController,
|
|
29
|
+
IdentityProviderConnections,
|
|
30
|
+
IdentityProviderList,
|
|
10
31
|
InviteFormFields,
|
|
32
|
+
MailTemplateList,
|
|
11
33
|
MemberListController,
|
|
12
34
|
OtpSetup,
|
|
35
|
+
PasswordlessToggle,
|
|
36
|
+
PersonDetail,
|
|
13
37
|
PersonList,
|
|
38
|
+
PersonsList,
|
|
39
|
+
PersonsListController,
|
|
40
|
+
ProjectSecretList,
|
|
41
|
+
ProjectSecretListController,
|
|
42
|
+
SessionList,
|
|
43
|
+
SetProjectSecretFormFields,
|
|
44
|
+
TenantConfigView,
|
|
14
45
|
} from '~/lib/tenant'
|
|
15
46
|
import { ToastContent, useShowToast } from '~/lib/toast'
|
|
16
47
|
import { Card, CardContent, CardHeader, CardTitle } from '~/lib/ui/card'
|
|
48
|
+
import { Dialog, DialogContent } from '~/lib/ui/dialog'
|
|
17
49
|
import { Input } from '~/lib/ui/input'
|
|
18
50
|
|
|
19
51
|
const Title = ({ icon, children }: { icon?: ReactNode; children: ReactNode }) => {
|
|
@@ -25,8 +57,19 @@ const Title = ({ icon, children }: { icon?: ReactNode; children: ReactNode }) =>
|
|
|
25
57
|
)
|
|
26
58
|
}
|
|
27
59
|
|
|
60
|
+
const Panel = ({ title, children }: { title: string; children: ReactNode }) => (
|
|
61
|
+
<Card className="w-[40rem] max-w-full">
|
|
62
|
+
<CardHeader>
|
|
63
|
+
<CardTitle className="text-2xl">{title}</CardTitle>
|
|
64
|
+
</CardHeader>
|
|
65
|
+
<CardContent>{children}</CardContent>
|
|
66
|
+
</Card>
|
|
67
|
+
)
|
|
68
|
+
|
|
28
69
|
export const Security = () => {
|
|
29
70
|
const showToast = useShowToast()
|
|
71
|
+
const identity = useIdentity()
|
|
72
|
+
const person = identity?.person
|
|
30
73
|
|
|
31
74
|
return (
|
|
32
75
|
<>
|
|
@@ -35,25 +78,53 @@ export const Security = () => {
|
|
|
35
78
|
</Slots.Title>
|
|
36
79
|
|
|
37
80
|
<div className="flex flex-col gap-4">
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
<
|
|
81
|
+
<Panel title="Profile">
|
|
82
|
+
{/* keyed on the identity values: the form snapshots initialValues on mount */}
|
|
83
|
+
<ChangeMyProfileForm
|
|
84
|
+
key={`${person?.email ?? ''} ${person?.name ?? ''}`}
|
|
85
|
+
initialValues={{ email: person?.email ?? '', name: person?.name ?? '' }}
|
|
86
|
+
onSuccess={() => showToast(<ToastContent>Profile updated</ToastContent>, { type: 'success' })}
|
|
87
|
+
>
|
|
88
|
+
<form className="grid gap-4">
|
|
89
|
+
<ChangeMyProfileFormFields />
|
|
90
|
+
</form>
|
|
91
|
+
</ChangeMyProfileForm>
|
|
92
|
+
</Panel>
|
|
93
|
+
|
|
94
|
+
<Panel title="Change password">
|
|
95
|
+
<ChangeMyPasswordForm onSuccess={() => showToast(<ToastContent>Password changed</ToastContent>, { type: 'success' })}>
|
|
96
|
+
<form className="grid gap-4">
|
|
97
|
+
<ChangeMyPasswordFormFields />
|
|
98
|
+
</form>
|
|
99
|
+
</ChangeMyPasswordForm>
|
|
100
|
+
</Panel>
|
|
101
|
+
|
|
102
|
+
<Panel title="Two-factor — authenticator app">
|
|
103
|
+
<OtpSetup />
|
|
104
|
+
</Panel>
|
|
105
|
+
|
|
106
|
+
<Panel title="Two-factor — e-mail code">
|
|
107
|
+
<EmailOtpSetup />
|
|
108
|
+
</Panel>
|
|
109
|
+
|
|
110
|
+
<Panel title="Backup codes">
|
|
111
|
+
<BackupCodes />
|
|
112
|
+
</Panel>
|
|
113
|
+
|
|
114
|
+
<Panel title="Passwordless sign-in">
|
|
115
|
+
<PasswordlessToggle />
|
|
116
|
+
</Panel>
|
|
117
|
+
|
|
118
|
+
<Panel title="Connected identity providers">
|
|
119
|
+
<IdentityProviderConnections />
|
|
120
|
+
</Panel>
|
|
121
|
+
|
|
122
|
+
<Card className="w-[60rem] max-w-full">
|
|
52
123
|
<CardHeader>
|
|
53
|
-
<CardTitle className="text-2xl">
|
|
124
|
+
<CardTitle className="text-2xl">Active sessions</CardTitle>
|
|
54
125
|
</CardHeader>
|
|
55
126
|
<CardContent>
|
|
56
|
-
<
|
|
127
|
+
<SessionList />
|
|
57
128
|
</CardContent>
|
|
58
129
|
</Card>
|
|
59
130
|
</div>
|
|
@@ -65,6 +136,8 @@ export const Members = () => {
|
|
|
65
136
|
const projectSlug = useProjectSlug()!
|
|
66
137
|
const showToast = useShowToast()
|
|
67
138
|
const memberListController = useRef<MemberListController>(undefined)
|
|
139
|
+
const identity = useIdentity()
|
|
140
|
+
const permissions = identity?.projects.find(project => project.slug === projectSlug)?.permissions
|
|
68
141
|
|
|
69
142
|
return (
|
|
70
143
|
<>
|
|
@@ -73,87 +146,265 @@ export const Members = () => {
|
|
|
73
146
|
</Slots.Title>
|
|
74
147
|
|
|
75
148
|
<div className="flex flex-col gap-4">
|
|
76
|
-
<
|
|
149
|
+
{permissions?.canAddMember !== false && <Panel title="Invite">
|
|
150
|
+
<InviteForm
|
|
151
|
+
projectSlug={projectSlug}
|
|
152
|
+
initialMemberships={[{ role: 'admin', variables: [] }]}
|
|
153
|
+
allowUnmanaged
|
|
154
|
+
onSuccess={args => {
|
|
155
|
+
showToast(<ToastContent>Member created: {args.result.person?.email}</ToastContent>, { type: 'success' })
|
|
156
|
+
memberListController.current?.refresh()
|
|
157
|
+
}}
|
|
158
|
+
>
|
|
159
|
+
<form>
|
|
160
|
+
{/* allowUnmanaged offers the "no invitation e-mail" path, for seeding and air-gapped setups */}
|
|
161
|
+
<InviteFormFields projectSlug={projectSlug} allowUnmanaged />
|
|
162
|
+
</form>
|
|
163
|
+
</InviteForm>
|
|
164
|
+
</Panel>}
|
|
165
|
+
|
|
166
|
+
{permissions?.canAddMember !== false && <Panel title="Add an existing identity">
|
|
167
|
+
<AddProjectMemberForm
|
|
168
|
+
projectSlug={projectSlug}
|
|
169
|
+
initialMemberships={[{ role: 'admin', variables: [] }]}
|
|
170
|
+
onSuccess={() => {
|
|
171
|
+
showToast(<ToastContent>Member added</ToastContent>, { type: 'success' })
|
|
172
|
+
memberListController.current?.refresh()
|
|
173
|
+
}}
|
|
174
|
+
>
|
|
175
|
+
<form>
|
|
176
|
+
<AddProjectMemberFormFields projectSlug={projectSlug} />
|
|
177
|
+
</form>
|
|
178
|
+
</AddProjectMemberForm>
|
|
179
|
+
</Panel>}
|
|
180
|
+
|
|
181
|
+
{permissions?.canViewMembers !== false && <Card className="w-[60rem] max-w-full">
|
|
77
182
|
<CardHeader>
|
|
78
|
-
<CardTitle className="text-2xl">
|
|
183
|
+
<CardTitle className="text-2xl">Members</CardTitle>
|
|
79
184
|
</CardHeader>
|
|
80
185
|
<CardContent>
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
<ToastContent>Invitation sent to {args.result.person?.email}</ToastContent>, { type: 'success' })
|
|
87
|
-
memberListController.current?.refresh()
|
|
88
|
-
}}
|
|
89
|
-
>
|
|
90
|
-
<form>
|
|
91
|
-
<InviteFormFields projectSlug={projectSlug} />
|
|
92
|
-
</form>
|
|
93
|
-
</InviteForm>
|
|
186
|
+
<PersonList
|
|
187
|
+
controller={memberListController}
|
|
188
|
+
canUpdateMember={permissions?.canUpdateMember}
|
|
189
|
+
canRemoveMember={permissions?.canRemoveMember}
|
|
190
|
+
/>
|
|
94
191
|
</CardContent>
|
|
95
|
-
</Card>
|
|
96
|
-
|
|
192
|
+
</Card>}
|
|
193
|
+
</div>
|
|
194
|
+
</>
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export const ApiKeys = () => {
|
|
199
|
+
const projectSlug = useProjectSlug()!
|
|
200
|
+
const showToast = useShowToast()
|
|
201
|
+
const identity = useIdentity()
|
|
202
|
+
const permissions = identity?.projects.find(project => project.slug === projectSlug)?.permissions
|
|
203
|
+
const globalPermissions = identity?.permissions
|
|
204
|
+
const apiKeyListController = useRef<ApiKeyListController>(undefined)
|
|
205
|
+
const globalApiKeyListController = useRef<GlobalApiKeyListController>(undefined)
|
|
206
|
+
|
|
207
|
+
const showToken = (token?: string) => {
|
|
208
|
+
showToast(
|
|
209
|
+
<ToastContent title="API key created">
|
|
210
|
+
<Input value={token ?? ''} type="text" />
|
|
211
|
+
</ToastContent>,
|
|
212
|
+
{ type: 'success' },
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<>
|
|
218
|
+
<Slots.Title>
|
|
219
|
+
<Title icon={<KeyRoundIcon />}>API keys</Title>
|
|
220
|
+
</Slots.Title>
|
|
221
|
+
|
|
222
|
+
<div className="flex flex-col gap-4">
|
|
223
|
+
{permissions?.canCreateApiKey !== false && <Panel title="Create API key">
|
|
224
|
+
<CreateApiKeyForm
|
|
225
|
+
projectSlug={projectSlug}
|
|
226
|
+
initialMemberships={[{ role: 'admin', variables: [] }]}
|
|
227
|
+
onSuccess={args => {
|
|
228
|
+
showToken(args.result.apiKey.token)
|
|
229
|
+
apiKeyListController.current?.refresh()
|
|
230
|
+
}}
|
|
231
|
+
>
|
|
232
|
+
<form className="grid gap-4">
|
|
233
|
+
<CreateApiKeyFormFields projectSlug={projectSlug} />
|
|
234
|
+
</form>
|
|
235
|
+
</CreateApiKeyForm>
|
|
236
|
+
</Panel>}
|
|
237
|
+
|
|
238
|
+
{permissions?.canViewMembers !== false && <Card className="w-[60rem] max-w-full">
|
|
97
239
|
<CardHeader>
|
|
98
|
-
<CardTitle className="text-2xl">
|
|
240
|
+
<CardTitle className="text-2xl">Project API keys</CardTitle>
|
|
99
241
|
</CardHeader>
|
|
100
242
|
<CardContent>
|
|
101
|
-
<
|
|
243
|
+
<ApiKeyList controller={apiKeyListController} />
|
|
102
244
|
</CardContent>
|
|
103
|
-
</Card>
|
|
245
|
+
</Card>}
|
|
104
246
|
|
|
247
|
+
{/* global keys carry tenant-wide roles instead of a project membership — SUPER_ADMIN only */}
|
|
248
|
+
{globalPermissions?.canCreateGlobalApiKey !== false && <Panel title="Create global API key">
|
|
249
|
+
<CreateGlobalApiKeyForm
|
|
250
|
+
onSuccess={args => {
|
|
251
|
+
showToken(args.result.apiKey.token)
|
|
252
|
+
globalApiKeyListController.current?.refresh()
|
|
253
|
+
}}
|
|
254
|
+
>
|
|
255
|
+
<form className="grid gap-4">
|
|
256
|
+
<CreateGlobalApiKeyFormFields />
|
|
257
|
+
</form>
|
|
258
|
+
</CreateGlobalApiKeyForm>
|
|
259
|
+
</Panel>}
|
|
260
|
+
|
|
261
|
+
{globalPermissions?.canListGlobalApiKeys !== false && <Card className="w-[60rem] max-w-full">
|
|
262
|
+
<CardHeader>
|
|
263
|
+
<CardTitle className="text-2xl">Global API keys</CardTitle>
|
|
264
|
+
</CardHeader>
|
|
265
|
+
<CardContent>
|
|
266
|
+
<GlobalApiKeyList controller={globalApiKeyListController} />
|
|
267
|
+
</CardContent>
|
|
268
|
+
</Card>}
|
|
105
269
|
</div>
|
|
106
270
|
</>
|
|
107
271
|
)
|
|
108
272
|
}
|
|
109
273
|
|
|
110
|
-
export const
|
|
274
|
+
export const Persons = () => {
|
|
275
|
+
const personsListController = useRef<PersonsListController>(undefined)
|
|
276
|
+
const [selectedPersonId, setSelectedPersonId] = useState<string>()
|
|
277
|
+
|
|
278
|
+
return (
|
|
279
|
+
<>
|
|
280
|
+
<Slots.Title>
|
|
281
|
+
<Title icon={<UserRoundIcon />}>Persons</Title>
|
|
282
|
+
</Slots.Title>
|
|
283
|
+
|
|
284
|
+
<Card className="w-[80rem] max-w-full">
|
|
285
|
+
<CardHeader>
|
|
286
|
+
<CardTitle className="text-2xl">Persons</CardTitle>
|
|
287
|
+
</CardHeader>
|
|
288
|
+
<CardContent>
|
|
289
|
+
<PersonsList controller={personsListController} onSelectPerson={setSelectedPersonId} />
|
|
290
|
+
</CardContent>
|
|
291
|
+
</Card>
|
|
292
|
+
|
|
293
|
+
<Dialog
|
|
294
|
+
open={selectedPersonId !== undefined}
|
|
295
|
+
onOpenChange={open => {
|
|
296
|
+
if (!open) {
|
|
297
|
+
setSelectedPersonId(undefined)
|
|
298
|
+
personsListController.current?.refresh()
|
|
299
|
+
}
|
|
300
|
+
}}
|
|
301
|
+
>
|
|
302
|
+
<DialogContent className="max-w-3xl max-h-[90vh] overflow-y-auto">
|
|
303
|
+
{selectedPersonId && <PersonDetail personId={selectedPersonId} />}
|
|
304
|
+
</DialogContent>
|
|
305
|
+
</Dialog>
|
|
306
|
+
</>
|
|
307
|
+
)
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export const AuditLog = () => (
|
|
311
|
+
<>
|
|
312
|
+
<Slots.Title>
|
|
313
|
+
<Title icon={<ScrollTextIcon />}>Audit log</Title>
|
|
314
|
+
</Slots.Title>
|
|
315
|
+
|
|
316
|
+
<Card className="w-[80rem] max-w-full">
|
|
317
|
+
<CardContent className="pt-6">
|
|
318
|
+
<AuthLogList />
|
|
319
|
+
</CardContent>
|
|
320
|
+
</Card>
|
|
321
|
+
</>
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
export const Configuration = () => (
|
|
325
|
+
<>
|
|
326
|
+
<Slots.Title>
|
|
327
|
+
<Title icon={<SettingsIcon />}>Configuration</Title>
|
|
328
|
+
</Slots.Title>
|
|
329
|
+
|
|
330
|
+
{/* Read-only throughout: all four areas are written with `contember tenant:apply`. */}
|
|
331
|
+
<div className="flex flex-col gap-4">
|
|
332
|
+
<Card className="w-[80rem] max-w-full">
|
|
333
|
+
<CardHeader>
|
|
334
|
+
<CardTitle className="text-2xl">Auth policies</CardTitle>
|
|
335
|
+
</CardHeader>
|
|
336
|
+
<CardContent>
|
|
337
|
+
<AuthPolicyList />
|
|
338
|
+
</CardContent>
|
|
339
|
+
</Card>
|
|
340
|
+
|
|
341
|
+
<Card className="w-[80rem] max-w-full">
|
|
342
|
+
<CardHeader>
|
|
343
|
+
<CardTitle className="text-2xl">Identity providers</CardTitle>
|
|
344
|
+
</CardHeader>
|
|
345
|
+
<CardContent>
|
|
346
|
+
<IdentityProviderList />
|
|
347
|
+
</CardContent>
|
|
348
|
+
</Card>
|
|
349
|
+
|
|
350
|
+
<Card className="w-[80rem] max-w-full">
|
|
351
|
+
<CardHeader>
|
|
352
|
+
<CardTitle className="text-2xl">Mail templates</CardTitle>
|
|
353
|
+
</CardHeader>
|
|
354
|
+
<CardContent>
|
|
355
|
+
<MailTemplateList />
|
|
356
|
+
</CardContent>
|
|
357
|
+
</Card>
|
|
358
|
+
|
|
359
|
+
<Card className="w-[80rem] max-w-full">
|
|
360
|
+
<CardHeader>
|
|
361
|
+
<CardTitle className="text-2xl">Tenant settings</CardTitle>
|
|
362
|
+
</CardHeader>
|
|
363
|
+
<CardContent>
|
|
364
|
+
<TenantConfigView />
|
|
365
|
+
</CardContent>
|
|
366
|
+
</Card>
|
|
367
|
+
</div>
|
|
368
|
+
</>
|
|
369
|
+
)
|
|
370
|
+
|
|
371
|
+
export const ProjectSecrets = () => {
|
|
111
372
|
const projectSlug = useProjectSlug()!
|
|
112
373
|
const showToast = useShowToast()
|
|
113
|
-
const
|
|
374
|
+
const secretListController = useRef<ProjectSecretListController>(undefined)
|
|
375
|
+
const identity = useIdentity()
|
|
376
|
+
const permissions = identity?.projects.find(project => project.slug === projectSlug)?.permissions
|
|
114
377
|
|
|
115
378
|
return (
|
|
116
379
|
<>
|
|
117
380
|
<Slots.Title>
|
|
118
|
-
<Title icon={<KeyRoundIcon />}>
|
|
381
|
+
<Title icon={<KeyRoundIcon />}>Project secrets</Title>
|
|
119
382
|
</Slots.Title>
|
|
120
383
|
|
|
121
384
|
<div className="flex flex-col gap-4">
|
|
122
|
-
<
|
|
123
|
-
<
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
</Card>
|
|
146
|
-
</div>
|
|
147
|
-
<div>
|
|
148
|
-
<Card className="w-[40rem] max-w-full">
|
|
149
|
-
<CardHeader>
|
|
150
|
-
<CardTitle className="text-2xl">API keys</CardTitle>
|
|
151
|
-
</CardHeader>
|
|
152
|
-
<CardContent>
|
|
153
|
-
<ApiKeyList controller={memberListController} />
|
|
154
|
-
</CardContent>
|
|
155
|
-
</Card>
|
|
156
|
-
</div>
|
|
385
|
+
{permissions?.canSetSecret !== false && <Panel title="Set a secret">
|
|
386
|
+
<SetProjectSecretForm
|
|
387
|
+
projectSlug={projectSlug}
|
|
388
|
+
onSuccess={() => {
|
|
389
|
+
showToast(<ToastContent>Secret saved</ToastContent>, { type: 'success' })
|
|
390
|
+
secretListController.current?.refresh()
|
|
391
|
+
}}
|
|
392
|
+
>
|
|
393
|
+
<form className="grid gap-4">
|
|
394
|
+
<SetProjectSecretFormFields />
|
|
395
|
+
</form>
|
|
396
|
+
</SetProjectSecretForm>
|
|
397
|
+
</Panel>}
|
|
398
|
+
|
|
399
|
+
{permissions?.canViewSecrets !== false && <Card className="w-[60rem] max-w-full">
|
|
400
|
+
<CardHeader>
|
|
401
|
+
<CardTitle className="text-2xl">Secrets</CardTitle>
|
|
402
|
+
</CardHeader>
|
|
403
|
+
<CardContent>
|
|
404
|
+
{/* values are never readable — the API returns keys and timestamps only */}
|
|
405
|
+
<ProjectSecretList controller={secretListController} />
|
|
406
|
+
</CardContent>
|
|
407
|
+
</Card>}
|
|
157
408
|
</div>
|
|
158
409
|
</>
|
|
159
410
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ToastContent, useShowToast } from '~/lib/toast'
|
|
2
|
-
import { dict } from '~/lib/dict'
|
|
2
|
+
import { dict } from '~/lib/tenant/dict'
|
|
3
3
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '~/lib/ui/card'
|
|
4
4
|
import { AnchorButton, Button } from '~/lib/ui/button'
|
|
5
5
|
import { LoginFormFields } from '~/lib/tenant'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '~/lib/ui/card'
|
|
2
|
-
import { dict } from '~/lib/dict'
|
|
2
|
+
import { dict } from '~/lib/tenant/dict'
|
|
3
3
|
import { Loader } from '~/lib/ui/loader'
|
|
4
4
|
import { PasswordlessSignInFormFields } from '~/lib/tenant/forms/passwordless-signin'
|
|
5
5
|
import { AnchorButton } from '~/lib/ui/button'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react'
|
|
2
2
|
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '~/lib/ui/card'
|
|
3
|
-
import { dict } from '~/lib/dict'
|
|
3
|
+
import { dict } from '~/lib/tenant/dict'
|
|
4
4
|
import { PasswordlessSignInFormFields } from '~/lib/tenant/forms/passwordless-signin'
|
|
5
5
|
import { MailIcon } from 'lucide-react'
|
|
6
6
|
import { AnchorButton } from '~/lib/ui/button'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ToastContent, useShowToast } from '~/lib/toast'
|
|
2
2
|
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '~/lib/ui/card'
|
|
3
|
-
import { dict } from '~/lib/dict'
|
|
3
|
+
import { dict } from '~/lib/tenant/dict'
|
|
4
4
|
import { PasswordResetFormFields } from '~/lib/tenant'
|
|
5
5
|
import { AnchorButton } from '~/lib/ui/button'
|
|
6
6
|
import { Link, useCurrentRequest, useRedirect } from '@contember/react-routing'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '~/lib/ui/card'
|
|
2
|
-
import { dict } from '~/lib/dict'
|
|
2
|
+
import { dict } from '~/lib/tenant/dict'
|
|
3
3
|
import { PasswordResetRequestFormFields } from '~/lib/tenant'
|
|
4
4
|
import { AnchorButton } from '~/lib/ui/button'
|
|
5
5
|
import { Link, useRedirect } from '@contember/react-routing'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '~/lib/ui/card'
|
|
2
|
-
import { dict } from '~/lib/dict'
|
|
2
|
+
import { dict } from '~/lib/tenant/dict'
|
|
3
3
|
import { MailIcon } from 'lucide-react'
|
|
4
4
|
import { AnchorButton } from '~/lib/ui/button'
|
|
5
5
|
import { Link } from '@contember/react-routing'
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { Loader, Table, TableCell, TableHead, TableHeader, TableRow } from '~/lib'
|
|
3
|
+
import { useAuthPoliciesQuery, useTenantQueryLoader } from '@contember/react-client-tenant'
|
|
4
|
+
import { dict } from '../dict.js'
|
|
5
|
+
import { formatConfigValue, ManagedByCliNote, renderConfigQueryState } from './common.js'
|
|
6
|
+
|
|
7
|
+
export interface AuthPolicyListController {
|
|
8
|
+
refresh: () => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AuthPolicyListProps {
|
|
12
|
+
controller?: { current?: AuthPolicyListController }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `AuthPolicyList` shows the configured per-role MFA / session policies read-only.
|
|
17
|
+
*
|
|
18
|
+
* Without this view an enforced MFA requirement is invisible to an administrator —
|
|
19
|
+
* they only meet it as a sign-in prompt. Policies are written with
|
|
20
|
+
* `contember tenant:apply`; requires `system:configure` to read.
|
|
21
|
+
*
|
|
22
|
+
* ## Example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <AuthPolicyList />
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export const AuthPolicyList = ({ controller }: AuthPolicyListProps) => {
|
|
28
|
+
const [query, { refresh }] = useTenantQueryLoader(useAuthPoliciesQuery(), {})
|
|
29
|
+
if (controller) {
|
|
30
|
+
controller.current = { refresh }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const nonData = renderConfigQueryState({
|
|
34
|
+
query,
|
|
35
|
+
forbiddenMessage: dict.tenant.authPolicyList.forbidden,
|
|
36
|
+
failedMessage: dict.tenant.authPolicyList.failedToLoadData,
|
|
37
|
+
})
|
|
38
|
+
if (nonData !== null) {
|
|
39
|
+
return nonData
|
|
40
|
+
}
|
|
41
|
+
if (!('data' in query)) {
|
|
42
|
+
return null
|
|
43
|
+
}
|
|
44
|
+
const policies = query.data
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div className="relative flex flex-col gap-3">
|
|
48
|
+
{query.state !== 'success' && <Loader position="absolute" />}
|
|
49
|
+
<ManagedByCliNote />
|
|
50
|
+
|
|
51
|
+
{policies.length === 0
|
|
52
|
+
? <div className="text-gray-500 italic">{dict.tenant.authPolicyList.noResults}</div>
|
|
53
|
+
: (
|
|
54
|
+
<>
|
|
55
|
+
<Table>
|
|
56
|
+
<TableHeader>
|
|
57
|
+
<TableRow>
|
|
58
|
+
<TableHead>{dict.tenant.authPolicyList.scope}</TableHead>
|
|
59
|
+
<TableHead>{dict.tenant.authPolicyList.project}</TableHead>
|
|
60
|
+
<TableHead>{dict.tenant.authPolicyList.roles}</TableHead>
|
|
61
|
+
<TableHead>{dict.tenant.authPolicyList.mfaRequired}</TableHead>
|
|
62
|
+
<TableHead>{dict.tenant.authPolicyList.tokenExpiration}</TableHead>
|
|
63
|
+
<TableHead>{dict.tenant.authPolicyList.idleTimeout}</TableHead>
|
|
64
|
+
<TableHead>{dict.tenant.authPolicyList.mfaGraceDuration}</TableHead>
|
|
65
|
+
<TableHead>{dict.tenant.authPolicyList.rememberMeAllowed}</TableHead>
|
|
66
|
+
</TableRow>
|
|
67
|
+
</TableHeader>
|
|
68
|
+
{policies.map(policy => (
|
|
69
|
+
<TableRow key={policy.id}>
|
|
70
|
+
<TableCell className="font-medium">{policy.scope}</TableCell>
|
|
71
|
+
<TableCell>{policy.project ?? '—'}</TableCell>
|
|
72
|
+
<TableCell className="font-mono text-xs">{policy.roles.join(', ')}</TableCell>
|
|
73
|
+
<TableCell>{formatConfigValue(policy.mfaRequired)}</TableCell>
|
|
74
|
+
<TableCell className="whitespace-nowrap">{formatConfigValue(policy.tokenExpiration)}</TableCell>
|
|
75
|
+
<TableCell className="whitespace-nowrap">{formatConfigValue(policy.idleTimeout)}</TableCell>
|
|
76
|
+
<TableCell className="whitespace-nowrap">{formatConfigValue(policy.mfaGraceDuration)}</TableCell>
|
|
77
|
+
<TableCell>{formatConfigValue(policy.rememberMeAllowed)}</TableCell>
|
|
78
|
+
</TableRow>
|
|
79
|
+
))}
|
|
80
|
+
</Table>
|
|
81
|
+
<p className="text-sm text-gray-500">{dict.tenant.authPolicyList.aggregationNote}</p>
|
|
82
|
+
</>
|
|
83
|
+
)}
|
|
84
|
+
</div>
|
|
85
|
+
)
|
|
86
|
+
}
|