strapi-plugin-oidc 1.0.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.
@@ -0,0 +1,491 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const reactRouterDom = require("react-router-dom");
5
+ const admin = require("@strapi/strapi/admin");
6
+ const react = require("react");
7
+ const designSystem = require("@strapi/design-system");
8
+ const icons = require("@strapi/icons");
9
+ const reactIntl = require("react-intl");
10
+ const index = require("./index-C0GkDnGG.js");
11
+ const en = require("./en-jFPbEFeK.js");
12
+ const styled = require("styled-components");
13
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
14
+ const styled__default = /* @__PURE__ */ _interopDefault(styled);
15
+ function getTrad(id) {
16
+ const pluginIdWithId = `${index.pluginId}.${id}`;
17
+ return {
18
+ id: pluginIdWithId,
19
+ defaultMessage: en.default[id] || pluginIdWithId
20
+ };
21
+ }
22
+ function Role({ oidcRoles, roles, onChangeRole }) {
23
+ const { formatMessage } = reactIntl.useIntl();
24
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
25
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textColor: "neutral600", marginBottom: 4, children: formatMessage(getTrad("roles.notes")) }),
26
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, marginBottom: 4, children: oidcRoles.map((oidcRole) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
27
+ designSystem.MultiSelect,
28
+ {
29
+ withTags: true,
30
+ placeholder: formatMessage(getTrad("roles.placeholder")),
31
+ value: oidcRole["role"] ? oidcRole["role"].map((r) => r.toString()) : [],
32
+ onChange: (value) => {
33
+ if (value && value.length > 0) {
34
+ onChangeRole(value, oidcRole["oauth_type"]);
35
+ }
36
+ },
37
+ children: roles.map((role) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MultiSelectOption, { value: role.id.toString(), children: role.name }, role.id))
38
+ }
39
+ ) }, oidcRole["oauth_type"])) })
40
+ ] });
41
+ }
42
+ const CustomTable = styled__default.default(designSystem.Table)`
43
+ th, td, th span, td span {
44
+ font-size: 1.3rem !important;
45
+ }
46
+ `;
47
+ const LocalizedDate = ({ date }) => {
48
+ const userLocale = navigator.language || "en-US";
49
+ return new Intl.DateTimeFormat(userLocale, {
50
+ year: "numeric",
51
+ month: "long",
52
+ day: "numeric",
53
+ hour: "2-digit",
54
+ minute: "2-digit"
55
+ }).format(new Date(date));
56
+ };
57
+ function Whitelist({ users, roles, oidcRoles = [], useWhitelist, loading, onSave, onDelete }) {
58
+ const [email, setEmail] = react.useState("");
59
+ const [selectedRoles, setSelectedRoles] = react.useState([]);
60
+ const [page, setPage] = react.useState(1);
61
+ const { formatMessage } = reactIntl.useIntl();
62
+ const PAGE_SIZE = 10;
63
+ const pageCount = Math.ceil(users.length / PAGE_SIZE) || 1;
64
+ const paginatedUsers = users.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);
65
+ const onSaveEmail = react.useCallback(async () => {
66
+ const emailText = email.trim();
67
+ if (users.some((user) => user.email === emailText)) {
68
+ alert(
69
+ formatMessage(getTrad("whitelist.error.unique"))
70
+ );
71
+ } else {
72
+ await onSave(emailText, selectedRoles);
73
+ setEmail("");
74
+ setSelectedRoles([]);
75
+ }
76
+ }, [email, selectedRoles, users, onSave, formatMessage]);
77
+ const isValidEmail = react.useCallback(() => {
78
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
79
+ return emailRegex.test(email);
80
+ }, [email]);
81
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
82
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textColor: "neutral600", marginBottom: 4, children: formatMessage(getTrad("whitelist.description")) }),
83
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, marginTop: 5, marginBottom: 5, alignItems: "flex-start", children: [
84
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(
85
+ designSystem.Field.Input,
86
+ {
87
+ type: "text",
88
+ disabled: loading,
89
+ value: email,
90
+ hasError: Boolean(email && !isValidEmail()),
91
+ onChange: (e) => setEmail(e.currentTarget.value),
92
+ placeholder: formatMessage(getTrad("whitelist.email.placeholder"))
93
+ }
94
+ ) }) }),
95
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(
96
+ designSystem.MultiSelect,
97
+ {
98
+ withTags: true,
99
+ placeholder: formatMessage(getTrad("whitelist.roles.placeholder")),
100
+ value: selectedRoles,
101
+ onChange: (value) => {
102
+ setSelectedRoles(value || []);
103
+ },
104
+ children: roles.map((role) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MultiSelectOption, { value: role.id.toString(), children: role.name }, role.id))
105
+ }
106
+ ) }) }),
107
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
108
+ designSystem.Button,
109
+ {
110
+ size: "L",
111
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}),
112
+ disabled: loading || email.trim() === "" || !isValidEmail(),
113
+ loading,
114
+ onClick: onSaveEmail,
115
+ children: formatMessage(getTrad("page.add"))
116
+ }
117
+ ) })
118
+ ] }),
119
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {}),
120
+ /* @__PURE__ */ jsxRuntime.jsxs(CustomTable, { colCount: 5, rowCount: users.length, children: [
121
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
122
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: formatMessage(getTrad("whitelist.table.no")) }),
123
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: formatMessage(getTrad("whitelist.table.email")) }),
124
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: formatMessage(getTrad("whitelist.table.roles")) }),
125
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: formatMessage(getTrad("whitelist.table.created")) }),
126
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { style: { paddingRight: 0 }, children: " " })
127
+ ] }) }),
128
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: users.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage(getTrad("whitelist.table.empty")) }) }) }) }) : paginatedUsers.map((user, index2) => {
129
+ let userRolesNames = (user.roles || []).map((roleId) => {
130
+ const r = roles.find((ro) => ro.id.toString() === roleId.toString());
131
+ return r ? r.name : roleId;
132
+ }).join(", ");
133
+ if (!userRolesNames) {
134
+ const defaultRolesIds = oidcRoles.reduce((acc, oidc) => {
135
+ if (oidc.role) {
136
+ acc.push(...oidc.role);
137
+ }
138
+ return acc;
139
+ }, []);
140
+ userRolesNames = defaultRolesIds.map((roleId) => {
141
+ const r = roles.find((ro) => ro.id.toString() === roleId.toString());
142
+ return r ? r.name : roleId;
143
+ }).join(", ");
144
+ }
145
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
146
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: index2 + 1 + (page - 1) * PAGE_SIZE }),
147
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: user.email }),
148
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: userRolesNames || "-" }),
149
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(LocalizedDate, { date: user.createdAt }) }),
150
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: { paddingRight: 0 }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", onClick: (e) => e.stopPropagation(), style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Root, { children: [
151
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { label: formatMessage(getTrad("whitelist.delete.label")), withTooltip: false, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}) }) }),
152
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
153
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage(getTrad("whitelist.delete.title")) }),
154
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { icon: /* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { fill: "danger600" }), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "center", gap: 2, children: [
155
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", children: formatMessage(getTrad("whitelist.delete.description")) }) }),
156
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", children: user.email }) }),
157
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", marginTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: formatMessage(getTrad("whitelist.delete.note")) }) })
158
+ ] }) }),
159
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
160
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, variant: "tertiary", children: formatMessage(getTrad("page.cancel")) }) }),
161
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Action, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, variant: "danger-light", onClick: () => onDelete(user.email), children: formatMessage(getTrad("page.ok")) }) })
162
+ ] })
163
+ ] })
164
+ ] }) }) })
165
+ ] }, user.email);
166
+ }) })
167
+ ] }),
168
+ pageCount > 1 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Pagination, { activePage: page, pageCount, children: [
169
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.PreviousLink, { href: "#", onClick: (e) => {
170
+ e.preventDefault();
171
+ setPage((p) => Math.max(1, p - 1));
172
+ }, children: "Go to previous page" }),
173
+ Array.from({ length: pageCount }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.PageLink, { number: i + 1, href: "#", onClick: (e) => {
174
+ e.preventDefault();
175
+ setPage(i + 1);
176
+ }, children: [
177
+ "Go to page ",
178
+ i + 1
179
+ ] }, i + 1)),
180
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.NextLink, { href: "#", onClick: (e) => {
181
+ e.preventDefault();
182
+ setPage((p) => Math.min(pageCount, p + 1));
183
+ }, children: "Go to next page" })
184
+ ] }) }) })
185
+ ] }) });
186
+ }
187
+ const AlertMessage = styled__default.default.div`
188
+ position: fixed;
189
+ left: 50%;
190
+ transform: translateX(-50%);
191
+ top: 2.875rem;
192
+ z-index: 10;
193
+ width: 31.25rem;
194
+ `;
195
+ function SuccessAlertMessage({ onClose }) {
196
+ const { formatMessage } = reactIntl.useIntl();
197
+ return /* @__PURE__ */ jsxRuntime.jsx(AlertMessage, { children: /* @__PURE__ */ jsxRuntime.jsx(
198
+ designSystem.Alert,
199
+ {
200
+ title: "Success",
201
+ variant: "success",
202
+ closeLabel: "",
203
+ onClose,
204
+ children: formatMessage(getTrad("page.save.success"))
205
+ }
206
+ ) });
207
+ }
208
+ function ErrorAlertMessage({ onClose }) {
209
+ const { formatMessage } = reactIntl.useIntl();
210
+ return /* @__PURE__ */ jsxRuntime.jsx(AlertMessage, { children: /* @__PURE__ */ jsxRuntime.jsx(
211
+ designSystem.Alert,
212
+ {
213
+ title: "Error",
214
+ variant: "danger",
215
+ closeLabel: "",
216
+ onClose,
217
+ children: formatMessage(getTrad("page.save.error"))
218
+ }
219
+ ) });
220
+ }
221
+ function MatchedUserAlertMessage({ onClose, count }) {
222
+ const { formatMessage } = reactIntl.useIntl();
223
+ const id = count > 1 ? "tab.whitelist.users_exists" : "tab.whitelist.user_exists";
224
+ return /* @__PURE__ */ jsxRuntime.jsx(AlertMessage, { children: /* @__PURE__ */ jsxRuntime.jsx(
225
+ designSystem.Alert,
226
+ {
227
+ title: "Info",
228
+ variant: "default",
229
+ closeLabel: "",
230
+ onClose,
231
+ children: formatMessage(getTrad(id))
232
+ }
233
+ ) });
234
+ }
235
+ const SwitchContainer = styled__default.default.label`
236
+ position: relative;
237
+ display: inline-block;
238
+ width: 40px;
239
+ height: 24px;
240
+ cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "pointer"};
241
+ opacity: ${({ $disabled }) => $disabled ? 0.5 : 1};
242
+ `;
243
+ const SwitchInput = styled__default.default.input`
244
+ opacity: 0;
245
+ width: 0;
246
+ height: 0;
247
+
248
+ &:checked + span {
249
+ background-color: ${({ theme }) => theme.colors.primary600};
250
+ }
251
+
252
+ &:focus + span {
253
+ box-shadow: 0 0 1px ${({ theme }) => theme.colors.primary600};
254
+ }
255
+
256
+ &:checked + span:before {
257
+ transform: translateX(16px);
258
+ }
259
+
260
+ &:disabled + span {
261
+ pointer-events: none;
262
+ }
263
+ `;
264
+ const SwitchSlider = styled__default.default.span`
265
+ position: absolute;
266
+ cursor: inherit;
267
+ top: 0;
268
+ left: 0;
269
+ right: 0;
270
+ bottom: 0;
271
+ background-color: ${({ theme }) => theme.colors.neutral300};
272
+ transition: 0.4s;
273
+ border-radius: 24px;
274
+
275
+ &:before {
276
+ position: absolute;
277
+ content: "";
278
+ height: 18px;
279
+ width: 18px;
280
+ left: 3px;
281
+ bottom: 3px;
282
+ background-color: white;
283
+ transition: 0.4s;
284
+ border-radius: 50%;
285
+ }
286
+ `;
287
+ function CustomSwitch({ checked, onChange, label, disabled }) {
288
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, children: [
289
+ /* @__PURE__ */ jsxRuntime.jsxs(SwitchContainer, { $disabled: disabled, children: [
290
+ /* @__PURE__ */ jsxRuntime.jsx(
291
+ SwitchInput,
292
+ {
293
+ type: "checkbox",
294
+ checked,
295
+ onChange,
296
+ disabled
297
+ }
298
+ ),
299
+ /* @__PURE__ */ jsxRuntime.jsx(SwitchSlider, {})
300
+ ] }),
301
+ label && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: disabled ? "neutral500" : "neutral800", children: label })
302
+ ] });
303
+ }
304
+ function HomePage$1() {
305
+ const { formatMessage } = reactIntl.useIntl();
306
+ const [loading, setLoading] = react.useState(false);
307
+ const [initialOidcRoles, setInitialOIDCRoles] = react.useState([]);
308
+ const [oidcRoles, setOIDCRoles] = react.useState([]);
309
+ const [roles, setRoles] = react.useState([]);
310
+ const [initialUseWhitelist, setInitialUseWhitelist] = react.useState(false);
311
+ const [useWhitelist, setUseWhitelist] = react.useState(false);
312
+ const [initialEnforceOIDC, setInitialEnforceOIDC] = react.useState(false);
313
+ const [enforceOIDC, setEnforceOIDC] = react.useState(false);
314
+ const [initialUsers, setInitialUsers] = react.useState([]);
315
+ const [users, setUsers] = react.useState([]);
316
+ const [showSuccess, setSuccess] = react.useState(false);
317
+ const [showError, setError] = react.useState(false);
318
+ const [showMatched, setMatched] = react.useState(0);
319
+ const { get, put, post, del } = admin.useFetchClient();
320
+ react.useEffect(() => {
321
+ get(`/strapi-plugin-oidc/oidc-roles`).then((response) => {
322
+ setOIDCRoles(response.data);
323
+ setInitialOIDCRoles(JSON.parse(JSON.stringify(response.data)));
324
+ });
325
+ get(`/admin/roles`).then((response) => {
326
+ setRoles(response.data.data);
327
+ });
328
+ get("/strapi-plugin-oidc/whitelist").then((response) => {
329
+ setUsers(response.data.whitelistUsers);
330
+ setInitialUsers(JSON.parse(JSON.stringify(response.data.whitelistUsers)));
331
+ setUseWhitelist(response.data.useWhitelist);
332
+ setInitialUseWhitelist(response.data.useWhitelist);
333
+ setEnforceOIDC(response.data.enforceOIDC);
334
+ setInitialEnforceOIDC(response.data.enforceOIDC);
335
+ });
336
+ }, [setOIDCRoles, setRoles]);
337
+ const onChangeRole = (values, oidcId) => {
338
+ for (const oidcRole of oidcRoles) {
339
+ if (oidcRole["oauth_type"] === oidcId) {
340
+ oidcRole["role"] = values;
341
+ }
342
+ }
343
+ setOIDCRoles(oidcRoles.slice());
344
+ };
345
+ const onSaveAll = async () => {
346
+ setLoading(true);
347
+ try {
348
+ await put("/strapi-plugin-oidc/oidc-roles", {
349
+ roles: oidcRoles.map((role) => ({
350
+ "oauth_type": role["oauth_type"],
351
+ role: role["role"]
352
+ }))
353
+ });
354
+ await put("/strapi-plugin-oidc/whitelist/settings", {
355
+ useWhitelist,
356
+ enforceOIDC
357
+ });
358
+ const syncResponse = await put("/strapi-plugin-oidc/whitelist/sync", {
359
+ users: users.map((u) => ({ email: u.email, roles: u.roles }))
360
+ });
361
+ setInitialOIDCRoles(JSON.parse(JSON.stringify(oidcRoles)));
362
+ setInitialUseWhitelist(useWhitelist);
363
+ setInitialEnforceOIDC(enforceOIDC);
364
+ get("/strapi-plugin-oidc/whitelist").then((getResponse) => {
365
+ setUsers(getResponse.data.whitelistUsers);
366
+ setInitialUsers(JSON.parse(JSON.stringify(getResponse.data.whitelistUsers)));
367
+ });
368
+ if (syncResponse.data && syncResponse.data.matchedExistingUsersCount > 0) {
369
+ setMatched(syncResponse.data.matchedExistingUsersCount);
370
+ setTimeout(() => {
371
+ setMatched(0);
372
+ }, 3e3);
373
+ } else {
374
+ setSuccess(true);
375
+ setTimeout(() => {
376
+ setSuccess(false);
377
+ }, 3e3);
378
+ }
379
+ } catch (e) {
380
+ console.error(e);
381
+ setError(true);
382
+ setTimeout(() => {
383
+ setError(false);
384
+ }, 3e3);
385
+ } finally {
386
+ setLoading(false);
387
+ }
388
+ };
389
+ const onRegisterWhitelist = async (email, selectedRoles) => {
390
+ const newUser = { email, roles: selectedRoles, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
391
+ setUsers([...users, newUser]);
392
+ };
393
+ const onDeleteWhitelist = async (email) => {
394
+ setUsers(users.filter((u) => u.email !== email));
395
+ };
396
+ const onToggleWhitelist = (e) => {
397
+ const newValue = e.target.checked;
398
+ setUseWhitelist(newValue);
399
+ };
400
+ const onToggleEnforce = (e) => {
401
+ const newValue = e.target.checked;
402
+ setEnforceOIDC(newValue);
403
+ };
404
+ const isDirty = useWhitelist !== initialUseWhitelist || enforceOIDC !== initialEnforceOIDC || JSON.stringify(oidcRoles) !== JSON.stringify(initialOidcRoles) || JSON.stringify(users) !== JSON.stringify(initialUsers);
405
+ return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Protect, { permissions: [{ action: "plugin::strapi-plugin-oidc.read", subject: null }], children: [
406
+ /* @__PURE__ */ jsxRuntime.jsx(
407
+ admin.Layouts.Header,
408
+ {
409
+ title: formatMessage(getTrad("page.title.oidc")),
410
+ subtitle: formatMessage(getTrad("page.title"))
411
+ }
412
+ ),
413
+ showSuccess && /* @__PURE__ */ jsxRuntime.jsx(SuccessAlertMessage, { onClose: () => setSuccess(false) }),
414
+ showError && /* @__PURE__ */ jsxRuntime.jsx(ErrorAlertMessage, { onClose: () => setError(false) }),
415
+ showMatched > 0 && /* @__PURE__ */ jsxRuntime.jsx(MatchedUserAlertMessage, { count: showMatched, onClose: () => setMatched(0) }),
416
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
417
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { background: "neutral0", hasRadius: true, shadow: "filterShadow", padding: 6, children: [
418
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", tag: "h2", children: formatMessage(getTrad("roles.title")) }) }),
419
+ /* @__PURE__ */ jsxRuntime.jsx(
420
+ Role,
421
+ {
422
+ roles,
423
+ oidcRoles,
424
+ onChangeRole
425
+ }
426
+ )
427
+ ] }),
428
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { background: "neutral0", hasRadius: true, shadow: "filterShadow", padding: 6, children: [
429
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", paddingBottom: 4, children: [
430
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", tag: "h2", children: formatMessage(getTrad("whitelist.title")) }),
431
+ /* @__PURE__ */ jsxRuntime.jsx(
432
+ CustomSwitch,
433
+ {
434
+ checked: useWhitelist,
435
+ onChange: onToggleWhitelist,
436
+ label: useWhitelist ? formatMessage(getTrad("whitelist.toggle.enabled")) : formatMessage(getTrad("whitelist.toggle.disabled"))
437
+ }
438
+ )
439
+ ] }),
440
+ /* @__PURE__ */ jsxRuntime.jsx(
441
+ Whitelist,
442
+ {
443
+ loading,
444
+ users,
445
+ roles,
446
+ oidcRoles,
447
+ useWhitelist,
448
+ onSave: onRegisterWhitelist,
449
+ onDelete: onDeleteWhitelist
450
+ }
451
+ )
452
+ ] }),
453
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral0", hasRadius: true, shadow: "filterShadow", padding: 6, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
454
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", children: [
455
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", tag: "h4", children: formatMessage(getTrad("enforce.title")) }),
456
+ /* @__PURE__ */ jsxRuntime.jsx(
457
+ CustomSwitch,
458
+ {
459
+ checked: enforceOIDC,
460
+ onChange: onToggleEnforce,
461
+ disabled: useWhitelist && users.length === 0,
462
+ label: enforceOIDC ? formatMessage(getTrad("enforce.toggle.enabled")) : formatMessage(getTrad("enforce.toggle.disabled"))
463
+ }
464
+ )
465
+ ] }),
466
+ enforceOIDC && enforceOIDC !== initialEnforceOIDC && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "danger100", padding: 3, hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "center", children: [
467
+ /* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { fill: "danger600" }),
468
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: formatMessage(getTrad("enforce.warning")) })
469
+ ] }) })
470
+ ] }) }),
471
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
472
+ designSystem.Button,
473
+ {
474
+ size: "L",
475
+ onClick: onSaveAll,
476
+ disabled: !isDirty || loading,
477
+ loading,
478
+ children: formatMessage(getTrad("page.save"))
479
+ }
480
+ ) })
481
+ ] }) })
482
+ ] });
483
+ }
484
+ const HomePage = react.memo(HomePage$1);
485
+ function App() {
486
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
487
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { index: true, element: /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) }),
488
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "*", element: /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {}) })
489
+ ] }) });
490
+ }
491
+ exports.default = App;