All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.AuthenticationSection-CEzcDulC.js.map Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
{"version":3,"file":"AuthenticationSection-CEzcDulC.js","sources":["../../../../../node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@patternfly/react-icons/dist/esm/icons/cog-icon.js","../../src/authentication/BindFlowDialog.tsx","../../src/authentication/DuplicateFlowModal.tsx","../../src/authentication/components/RequiredActionConfigModal.tsx","../../src/authentication/RequiredActions.tsx","../../src/authentication/components/UsedBy.tsx","../../src/authentication/policies/CibaPolicy.tsx","../../src/authentication/policies/OtpPolicy.tsx","../../src/authentication/policies/PolicyRow.tsx","../../src/authentication/policies/util.ts","../../src/authentication/policies/PasswordPolicy.tsx","../../src/authentication/policies/WebauthnPolicy.tsx","../../src/authentication/policies/Policies.tsx","../../src/authentication/AuthenticationSection.tsx"],"sourcesContent":["import { createIcon } from '../createIcon';\n\nexport const CogIconConfig = {\n  name: 'CogIcon',\n  height: 512,\n  width: 512,\n  svgPath: 'M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z',\n  yOffset: 0,\n  xOffset: 0,\n};\n\nexport const CogIcon = createIcon(CogIconConfig);\n\nexport default CogIcon;","import type RealmRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/realmRepresentation\";\nimport {\n  AlertVariant,\n  Button,\n  ButtonVariant,\n  Form,\n  Modal,\n} from \"@patternfly/react-core\";\nimport { FormProvider, useForm } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { SelectControl } from \"@keycloak/keycloak-ui-shared\";\nimport { useAlerts } from \"../components/alert/Alerts\";\nimport { useRealm } from \"../context/realm-context/RealmContext\";\nimport { REALM_FLOWS } from \"./AuthenticationSection\";\nimport { useAdminClient } from \"../admin-client\";\n\ntype BindingForm = {\n  bindingType: keyof RealmRepresentation;\n};\n\ntype BindFlowDialogProps = {\n  flowAlias: string;\n  onClose: (used?: boolean) => void;\n};\n\nexport const BindFlowDialog = ({ flowAlias, onClose }: BindFlowDialogProps) => {\n  const { adminClient } = useAdminClient();\n\n  const { t } = useTranslation();\n  const form = useForm();\n  const { addAlert, addError } = useAlerts();\n  const { realm } = useRealm();\n\n  const onSubmit = async ({ bindingType }: BindingForm) => {\n    const realmRep = await adminClient.realms.findOne({ realm });\n\n    try {\n      await adminClient.realms.update(\n        { realm },\n        { ...realmRep, [bindingType]: flowAlias },\n      );\n      addAlert(t(\"updateFlowSuccess\"), AlertVariant.success);\n    } catch (error) {\n      addError(\"updateFlowError\", error);\n    }\n\n    onClose(true);\n  };\n\n  const flowKeys = Array.from(REALM_FLOWS.keys());\n\n  return (\n     onClose()}\n      actions={[\n        ,\n         onClose()}\n        >\n          {t(\"cancel\")}\n        ,\n      ]}\n      isOpen\n    >\n      
\n \n f !== \"dockerAuthenticationFlow\")\n .map((key) => ({\n key,\n value: t(`flow.${REALM_FLOWS.get(key)}`),\n }))}\n controller={{ defaultValue: flowKeys[0] }}\n menuAppendTo=\"parent\"\n aria-label={t(\"chooseBindingType\")}\n />\n \n
\n \n );\n};\n","import AuthenticationFlowRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/authenticationFlowRepresentation\";\nimport {\n AlertVariant,\n Button,\n ButtonVariant,\n Form,\n Modal,\n ModalVariant,\n} from \"@patternfly/react-core\";\nimport { useEffect } from \"react\";\nimport { FormProvider, useForm } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { useNavigate } from \"react-router-dom\";\nimport { useAdminClient } from \"../admin-client\";\nimport { useAlerts } from \"../components/alert/Alerts\";\nimport { useRealm } from \"../context/realm-context/RealmContext\";\nimport { NameDescription } from \"./form/NameDescription\";\nimport { toFlow } from \"./routes/Flow\";\n\ntype DuplicateFlowModalProps = {\n name: string;\n description: string;\n toggleDialog: () => void;\n onComplete: () => void;\n};\n\nexport const DuplicateFlowModal = ({\n name,\n description,\n toggleDialog,\n onComplete,\n}: DuplicateFlowModalProps) => {\n const { adminClient } = useAdminClient();\n\n const { t } = useTranslation();\n const form = useForm({ mode: \"onChange\" });\n const { setValue, getValues, handleSubmit } = form;\n const { addAlert, addError } = useAlerts();\n const navigate = useNavigate();\n const { realm } = useRealm();\n\n useEffect(() => {\n setValue(\"alias\", t(\"copyOf\", { name }));\n setValue(\"description\", description);\n }, [name, description]);\n\n const onSubmit = async () => {\n const form = getValues();\n try {\n await adminClient.authenticationManagement.copyFlow({\n flow: name,\n newName: form.alias!,\n });\n const newFlow = (\n await adminClient.authenticationManagement.getFlows()\n ).find((flow) => flow.alias === form.alias)!;\n\n if (form.description !== description) {\n newFlow.description = form.description;\n await adminClient.authenticationManagement.updateFlow(\n { flowId: newFlow.id! },\n newFlow,\n );\n }\n addAlert(t(\"copyFlowSuccess\"), AlertVariant.success);\n navigate(\n toFlow({\n realm,\n id: newFlow.id!,\n usedBy: \"notInUse\",\n builtIn: newFlow.builtIn ? \"builtIn\" : undefined,\n }),\n );\n } catch (error) {\n addError(\"copyFlowError\", error);\n }\n onComplete();\n };\n\n return (\n \n {t(\"duplicate\")}\n ,\n \n {t(\"cancel\")}\n ,\n ]}\n isOpen\n >\n \n \n \n \n \n \n );\n};\n","import RequiredActionConfigInfoRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/requiredActionConfigInfoRepresentation\";\nimport RequiredActionConfigRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/requiredActionConfigRepresentation\";\nimport type RequiredActionProviderRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/requiredActionProviderRepresentation\";\nimport {\n ActionGroup,\n AlertVariant,\n Button,\n ButtonVariant,\n Form,\n Modal,\n ModalVariant,\n} from \"@patternfly/react-core\";\nimport { TrashIcon } from \"@patternfly/react-icons\";\nimport { useState } from \"react\";\nimport { FormProvider, useForm } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { useAdminClient } from \"../../admin-client\";\nimport { useAlerts } from \"../../components/alert/Alerts\";\nimport { DynamicComponents } from \"../../components/dynamic/DynamicComponents\";\nimport { convertFormValuesToObject, convertToFormValues } from \"../../util\";\nimport { useFetch } from \"../../utils/useFetch\";\n\ntype RequiredActionConfigModalForm = {\n // alias: string;\n config: { [index: string]: string };\n};\n\ntype RequiredActionConfigModalProps = {\n requiredAction: RequiredActionProviderRepresentation;\n onClose: () => void;\n};\n\nexport const RequiredActionConfigModal = ({\n requiredAction,\n onClose,\n}: RequiredActionConfigModalProps) => {\n const { adminClient } = useAdminClient();\n const { t } = useTranslation();\n const { addAlert, addError } = useAlerts();\n\n const [configDescription, setConfigDescription] =\n useState();\n\n const form = useForm();\n const { setValue, handleSubmit } = form;\n\n // // default config all required actions should have\n // const defaultConfigProperties = [];\n\n const setupForm = (config?: RequiredActionConfigRepresentation) => {\n convertToFormValues(config || {}, setValue);\n };\n\n useFetch(\n async () => {\n const configDescription =\n await adminClient.authenticationManagement.getRequiredActionConfigDescription(\n {\n alias: requiredAction.alias!,\n },\n );\n\n const config =\n await adminClient.authenticationManagement.getRequiredActionConfig({\n alias: requiredAction.alias!,\n });\n\n // merge default and fetched config properties\n configDescription.properties = [\n //...defaultConfigProperties!,\n ...configDescription.properties!,\n ];\n\n return { configDescription, config };\n },\n ({ configDescription, config }) => {\n setConfigDescription(configDescription);\n setupForm(config);\n },\n [],\n );\n\n const save = async (saved: RequiredActionConfigModalForm) => {\n const newConfig = convertFormValuesToObject(saved);\n try {\n await adminClient.authenticationManagement.updateRequiredActionConfig(\n { alias: requiredAction.alias! },\n newConfig,\n );\n setupForm(newConfig);\n addAlert(t(\"configSaveSuccess\"), AlertVariant.success);\n onClose();\n } catch (error) {\n addError(\"configSaveError\", error);\n }\n };\n\n return (\n \n
\n \n \n \n \n \n \n {t(\"cancel\")}\n \n {\n await adminClient.authenticationManagement.removeRequiredActionConfig(\n {\n alias: requiredAction.alias!,\n },\n );\n form.reset({});\n onClose();\n }}\n >\n {t(\"clear\")} \n \n \n
\n \n );\n};\n","import type RequiredActionProviderRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/requiredActionProviderRepresentation\";\nimport type RequiredActionProviderSimpleRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/requiredActionProviderSimpleRepresentation\";\nimport { AlertVariant, Button, Switch } from \"@patternfly/react-core\";\nimport { CogIcon } from \"@patternfly/react-icons\";\nimport { useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { useAdminClient } from \"../admin-client\";\nimport { useAlerts } from \"../components/alert/Alerts\";\nimport { KeycloakSpinner } from \"../components/keycloak-spinner/KeycloakSpinner\";\nimport { addTrailingSlash, toKey } from \"../util\";\nimport { useFetch } from \"../utils/useFetch\";\nimport { DraggableTable } from \"./components/DraggableTable\";\nimport { RequiredActionConfigModal } from \"./components/RequiredActionConfigModal\";\nimport { fetchWithError } from \"@keycloak/keycloak-admin-client\";\nimport { getAuthorizationHeaders } from \"../utils/getAuthorizationHeaders\";\nimport { useRealm } from \"../context/realm-context/RealmContext\";\n\ntype DataType = RequiredActionProviderRepresentation &\n RequiredActionProviderSimpleRepresentation & {\n configurable?: boolean;\n };\n\ntype Row = {\n name: string;\n enabled: boolean;\n defaultAction: boolean;\n data: DataType;\n};\n\nexport const RequiredActions = () => {\n const { adminClient } = useAdminClient();\n\n const { t } = useTranslation();\n const { addAlert, addError } = useAlerts();\n\n const [actions, setActions] = useState();\n const [selectedAction, setSelectedAction] = useState();\n const [key, setKey] = useState(0);\n const refresh = () => setKey(key + 1);\n const { realm: realmName } = useRealm();\n\n const loadActions = async (): Promise<\n RequiredActionProviderRepresentation[]\n > => {\n const requiredActionsRequest = await fetchWithError(\n `${addTrailingSlash(\n adminClient.baseUrl,\n )}admin/realms/${realmName}/ui-ext/authentication-management/required-actions`,\n {\n method: \"GET\",\n headers: getAuthorizationHeaders(await adminClient.getAccessToken()),\n },\n );\n\n return (await requiredActionsRequest.json()) as DataType[];\n };\n\n useFetch(\n async () => {\n const [requiredActions, unregisteredRequiredActions] = await Promise.all([\n loadActions(),\n adminClient.authenticationManagement.getUnregisteredRequiredActions(),\n ]);\n return [\n ...requiredActions.map((action) => ({\n name: action.name!,\n enabled: action.enabled!,\n defaultAction: action.defaultAction!,\n data: action,\n })),\n ...unregisteredRequiredActions.map((action) => ({\n name: action.name!,\n enabled: false,\n defaultAction: false,\n data: action,\n })),\n ];\n },\n (actions) => setActions(actions),\n [key],\n );\n\n const isUnregisteredAction = (data: DataType): boolean => {\n return !(\"alias\" in data);\n };\n\n const updateAction = async (\n action: DataType,\n field: \"enabled\" | \"defaultAction\",\n ) => {\n try {\n if (field in action) {\n action[field] = !action[field];\n // remove configurable property from action which only exists for the admin ui\n delete action.configurable;\n await adminClient.authenticationManagement.updateRequiredAction(\n { alias: action.alias! },\n action,\n );\n } else if (isUnregisteredAction(action)) {\n await adminClient.authenticationManagement.registerRequiredAction({\n name: action.name,\n providerId: action.providerId,\n });\n }\n refresh();\n addAlert(t(\"updatedRequiredActionSuccess\"), AlertVariant.success);\n } catch (error) {\n addError(\"updatedRequiredActionError\", error);\n }\n };\n\n const executeMove = async (\n action: RequiredActionProviderRepresentation,\n times: number,\n ) => {\n try {\n const alias = action.alias!;\n for (let index = 0; index < Math.abs(times); index++) {\n if (times > 0) {\n await adminClient.authenticationManagement.lowerRequiredActionPriority(\n {\n alias,\n },\n );\n } else {\n await adminClient.authenticationManagement.raiseRequiredActionPriority(\n {\n alias,\n },\n );\n }\n }\n refresh();\n\n addAlert(t(\"updatedRequiredActionSuccess\"), AlertVariant.success);\n } catch (error) {\n addError(\"updatedRequiredActionError\", error);\n }\n };\n\n if (!actions) {\n return ;\n }\n\n return (\n <>\n {selectedAction && (\n setSelectedAction(undefined)}\n />\n )}\n {\n const keys = actions.map((e) => e.name);\n const newIndex = items.indexOf(nameDragged);\n const oldIndex = keys.indexOf(nameDragged);\n const dragged = actions[oldIndex].data;\n if (!dragged.alias) return;\n\n const times = newIndex - oldIndex;\n executeMove(dragged, times);\n }}\n columns={[\n {\n name: \"name\",\n displayKey: \"action\",\n width: 50,\n },\n {\n name: \"enabled\",\n displayKey: \"enabled\",\n cellRenderer: (row) => (\n {\n updateAction(row.data, \"enabled\");\n }}\n aria-label={toKey(row.name)}\n />\n ),\n width: 20,\n },\n {\n name: \"default\",\n displayKey: \"setAsDefaultAction\",\n thTooltipText: \"authDefaultActionTooltip\",\n cellRenderer: (row) => (\n {\n updateAction(row.data, \"defaultAction\");\n }}\n aria-label={toKey(row.name)}\n />\n ),\n width: 20,\n },\n {\n name: \"config\",\n displayKey: \"configure\",\n cellRenderer: (row) =>\n row.data.configurable ? (\n setSelectedAction(row.data)}\n >\n \n \n ) : undefined,\n width: 10,\n },\n ]}\n data={actions}\n />\n \n );\n};\n","import RealmRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/realmRepresentation\";\nimport {\n Button,\n Modal,\n ModalVariant,\n Popover,\n Text,\n TextContent,\n TextVariants,\n} from \"@patternfly/react-core\";\nimport { CheckCircleIcon } from \"@patternfly/react-icons\";\nimport { useTranslation } from \"react-i18next\";\nimport { useAdminClient } from \"../../admin-client\";\nimport { fetchUsedBy } from \"../../components/role-mapping/resource\";\nimport { KeycloakDataTable } from \"../../components/table-toolbar/KeycloakDataTable\";\nimport useToggle from \"../../utils/useToggle\";\nimport { AuthenticationType, REALM_FLOWS } from \"../AuthenticationSection\";\n\nimport style from \"./used-by.module.css\";\n\ntype UsedByProps = {\n authType: AuthenticationType;\n realm: RealmRepresentation;\n};\n\nconst Label = ({ label }: { label: string }) => (\n <>\n {label}\n \n);\n\ntype UsedByModalProps = {\n id: string;\n onClose: () => void;\n isSpecificClient: boolean;\n};\n\nconst UsedByModal = ({ id, isSpecificClient, onClose }: UsedByModalProps) => {\n const { adminClient } = useAdminClient();\n\n const { t } = useTranslation();\n\n const loader = async (\n first?: number,\n max?: number,\n search?: string,\n ): Promise<{ name: string }[]> => {\n const result = await fetchUsedBy(adminClient, {\n id,\n type: isSpecificClient ? \"clients\" : \"idp\",\n first: first || 0,\n max: max || 10,\n search,\n });\n return result.map((p) => ({ name: p }));\n };\n\n return (\n \n {t(\"flowUsedBy\")}\n \n {t(\"flowUsedByDescription\", {\n value: isSpecificClient ? t(\"clients\") : t(\"identiyProviders\"),\n })}\n \n \n }\n variant={ModalVariant.medium}\n isOpen\n onClose={onClose}\n actions={[\n \n {t(\"close\")}\n ,\n ]}\n >\n \n \n );\n};\n\nexport const UsedBy = ({ authType: { id, usedBy }, realm }: UsedByProps) => {\n const { t } = useTranslation();\n const [open, toggle] = useToggle();\n\n const key = Object.entries(realm).find(\n (e) => e[1] === usedBy?.values[0],\n )?.[0];\n\n return (\n <>\n {open && (\n \n )}\n {(usedBy?.type === \"SPECIFIC_PROVIDERS\" ||\n usedBy?.type === \"SPECIFIC_CLIENTS\") &&\n (usedBy.values.length <= 8 ? (\n \n {t(\n \"appliedBy\" +\n (usedBy.type === \"SPECIFIC_CLIENTS\"\n ? \"Clients\"\n : \"Providers\"),\n )}{\" \"}\n {usedBy.values.map((used, index) => (\n <>\n {used}\n {index < usedBy.values.length - 1 ? \", \" : \"\"}\n \n ))}\n
\n }\n >\n \n \n ) : (\n \n ))}\n {usedBy?.type === \"DEFAULT\" && (\n



© 2015 - 2025 Weber Informatics LLC | Privacy Policy