@keycloakify/keycloak-admin-ui
Version:
Repackaged Keycloak Admin UI
30 lines • 6.63 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { HelpItem } from "../../ui-shared";
import { ActionGroup, Button, FormGroup, MenuToggle, Select, SelectList, SelectOption, } from "@patternfly/react-core";
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { DefaultSwitchControl } from "../../components/SwitchControl";
import { FormAccess } from "../../components/form/FormAccess";
import { KeyValueInput } from "../../components/key-value-form/KeyValueInput";
import { MultiLineInput } from "../../components/multi-line-input/MultiLineInput";
import { TimeSelector } from "../../components/time-selector/TimeSelector";
import { useRealm } from "../../context/realm-context/RealmContext";
import { convertAttributeNameToForm } from "../../util";
import useIsFeatureEnabled, { Feature } from "../../utils/useIsFeatureEnabled";
import { TokenLifespan } from "../../clients/advanced/TokenLifespan";
export const AdvancedSettings = ({ save, reset, protocol, hasConfigureAccess, }) => {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const { realmRepresentation: realm } = useRealm();
const isFeatureEnabled = useIsFeatureEnabled();
const isDPoPEnabled = isFeatureEnabled(Feature.DPoP);
const { control } = useFormContext();
return (_jsxs(FormAccess, { role: "manage-realm", fineGrainedAccess: hasConfigureAccess, isHorizontal: true, children: [protocol !== "openid-connect" && (_jsx(FormGroup, { label: t("assertionLifespan"), fieldId: "assertionLifespan", labelIcon: _jsx(HelpItem, { helpText: t("assertionLifespanHelp"), fieldLabelId: "assertionLifespan" }), children: _jsx(Controller, { name: convertAttributeNameToForm("attributes.saml.assertion.lifespan"), defaultValue: "", control: control, render: ({ field }) => (_jsx(TimeSelector, { units: ["minute", "day", "hour"], value: field.value, onChange: field.onChange })) }) })), protocol === "openid-connect" && (_jsxs(_Fragment, { children: [_jsx(TokenLifespan, { id: "accessTokenLifespan", name: convertAttributeNameToForm("attributes.access.token.lifespan"), defaultValue: realm === null || realm === void 0 ? void 0 : realm.accessTokenLifespan, units: ["minute", "day", "hour"] }), _jsx(TokenLifespan, { id: "clientSessionIdle", name: convertAttributeNameToForm("attributes.client.session.idle.timeout"), defaultValue: realm === null || realm === void 0 ? void 0 : realm.clientSessionIdleTimeout, units: ["minute", "day", "hour"] }), _jsx(TokenLifespan, { id: "clientSessionMax", name: convertAttributeNameToForm("attributes.client.session.max.lifespan"), defaultValue: realm === null || realm === void 0 ? void 0 : realm.clientSessionMaxLifespan, units: ["minute", "day", "hour"] }), _jsx(TokenLifespan, { id: "clientOfflineSessionIdle", name: convertAttributeNameToForm("attributes.client.offline.session.idle.timeout"), defaultValue: realm === null || realm === void 0 ? void 0 : realm.offlineSessionIdleTimeout, units: ["minute", "day", "hour"] }), (realm === null || realm === void 0 ? void 0 : realm.offlineSessionMaxLifespanEnabled) && (_jsx(TokenLifespan, { id: "clientOfflineSessionMax", name: convertAttributeNameToForm("attributes.client.offline.session.max.lifespan"), defaultValue: (realm === null || realm === void 0 ? void 0 : realm.offlineSessionMaxLifespanEnabled)
? realm.offlineSessionMaxLifespan
: undefined, units: ["minute", "day", "hour"] })), _jsx(DefaultSwitchControl, { name: convertAttributeNameToForm("attributes.tls.client.certificate.bound.access.tokens"), label: t("oAuthMutual"), labelIcon: t("oAuthMutualHelp"), stringify: true }), isDPoPEnabled && (_jsx(DefaultSwitchControl, { name: convertAttributeNameToForm("attributes.dpop.bound.access.tokens"), label: t("oAuthDPoP"), labelIcon: t("oAuthDPoPHelp"), stringify: true })), _jsx(FormGroup, { label: t("keyForCodeExchange"), fieldId: "keyForCodeExchange", hasNoPaddingTop: true, labelIcon: _jsx(HelpItem, { helpText: t("keyForCodeExchangeHelp"), fieldLabelId: "keyForCodeExchange" }), children: _jsx(Controller, { name: convertAttributeNameToForm("attributes.pkce.code.challenge.method"), defaultValue: "", control: control, render: ({ field }) => (_jsx(Select, { toggle: (ref) => (_jsx(MenuToggle, { id: "keyForCodeExchange", ref: ref, onClick: () => setOpen(!open), isExpanded: open, children: [field.value || t("choose")] })), isOpen: open, onOpenChange: (isOpen) => setOpen(isOpen), onSelect: (_, value) => {
field.onChange(value);
setOpen(false);
}, selected: field.value, children: _jsx(SelectList, { children: ["", "S256", "plain"].map((v) => (_jsx(SelectOption, { value: v, children: v || t("choose") }, v))) }) })) }) }), _jsx(DefaultSwitchControl, { name: convertAttributeNameToForm("attributes.require.pushed.authorization.requests"), label: t("pushedAuthorizationRequestRequired"), labelIcon: t("pushedAuthorizationRequestRequiredHelp"), stringify: true }), _jsx(DefaultSwitchControl, { name: convertAttributeNameToForm("attributes.client.use.lightweight.access.token.enabled"), label: t("lightweightAccessToken"), labelIcon: t("lightweightAccessTokenHelp"), stringify: true }), _jsx(DefaultSwitchControl, { name: convertAttributeNameToForm("attributes.client.introspection.response.allow.jwt.claim.enabled"), label: t("supportJwtClaimInIntrospectionResponse"), labelIcon: t("supportJwtClaimInIntrospectionResponseHelp"), stringify: true }), _jsx(FormGroup, { label: t("acrToLoAMapping"), fieldId: "acrToLoAMapping", labelIcon: _jsx(HelpItem, { helpText: t("acrToLoAMappingHelp"), fieldLabelId: "acrToLoAMapping" }), children: _jsx(KeyValueInput, { label: t("acrToLoAMapping"), name: convertAttributeNameToForm("attributes.acr.loa.map") }) }), _jsx(FormGroup, { label: t("defaultACRValues"), fieldId: "defaultACRValues", labelIcon: _jsx(HelpItem, { helpText: t("defaultACRValuesHelp"), fieldLabelId: "defaultACRValues" }), children: _jsx(MultiLineInput, { id: "defaultACRValues", "aria-label": "defaultACRValues", name: convertAttributeNameToForm("attributes.default.acr.values"), stringify: true }) })] })), _jsxs(ActionGroup, { children: [_jsx(Button, { variant: "secondary", onClick: save, "data-testid": "OIDCAdvancedSave", children: t("save") }), _jsx(Button, { variant: "link", onClick: reset, "data-testid": "OIDCAdvancedRevert", children: t("revert") })] })] }));
};
//# sourceMappingURL=AdvancedSettings.js.map