@keycloakify/keycloak-admin-ui
Version:
Repackaged Keycloak Admin UI
95 lines • 10.1 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { ExpandableSection } from "@patternfly/react-core";
import { useState } from "react";
import { FormProvider, useFormContext, useWatch } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { NumberControl, SelectControl, TextAreaControl, TextControl, } from "../../ui-shared";
import { DefaultSwitchControl } from "../../components/SwitchControl";
import "./discovery-settings.css";
const Fields = ({ readOnly }) => {
const { t } = useTranslation();
const form = useFormContext();
const { control } = form;
const wantAuthnSigned = useWatch({
control,
name: "config.wantAuthnRequestsSigned",
});
const wantAssertionsEncrypted = useWatch({
control,
name: "config.wantAssertionsEncrypted",
});
const validateSignature = useWatch({
control,
name: "config.validateSignature",
});
const useMetadataDescriptorUrl = useWatch({
control,
name: "config.useMetadataDescriptorUrl",
});
const principalType = useWatch({
control,
name: "config.principalType",
});
return (_jsx("div", { className: "pf-v5-c-form pf-m-horizontal", children: _jsxs(FormProvider, { ...form, children: [_jsx(TextControl, { name: "config.entityId", label: t("serviceProviderEntityId"), labelIcon: t("serviceProviderEntityIdHelp") }), _jsx(TextControl, { name: "config.idpEntityId", label: t("identityProviderEntityId"), labelIcon: t("identityProviderEntityIdHelp"), "data-testid": "identityProviderEntityId", id: "kc-identity-provider-entity-id" }), _jsx(TextControl, { name: "config.singleSignOnServiceUrl", label: t("ssoServiceUrl"), labelIcon: t("ssoServiceUrlHelp"), type: "url", readOnly: readOnly, rules: { required: t("required") } }), _jsx(TextControl, { name: "config.artifactResolutionServiceUrl", label: t("artifactResolutionServiceUrl"), labelIcon: t("artifactResolutionServiceUrlHelp"), type: "url", isDisabled: readOnly }), _jsx(TextControl, { name: "config.singleLogoutServiceUrl", label: t("singleLogoutServiceUrl"), labelIcon: t("singleLogoutServiceUrlHelp"), type: "url", readOnly: readOnly }), _jsx(DefaultSwitchControl, { name: "config.backchannelSupported", label: t("backchannelLogout"), isDisabled: readOnly, stringify: true }), _jsx(DefaultSwitchControl, { name: "config.sendIdTokenOnLogout", label: t("sendIdTokenOnLogout"), defaultValue: "true", isDisabled: readOnly, stringify: true }), _jsx(DefaultSwitchControl, { name: "config.sendClientIdOnLogout", label: t("sendClientIdOnLogout"), isDisabled: readOnly, stringify: true }), _jsx(SelectControl, { name: "config.nameIDPolicyFormat", label: t("nameIdPolicyFormat"), labelIcon: t("nameIdPolicyFormatHelp"), controller: {
defaultValue: "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
}, isDisabled: readOnly, options: [
{
key: "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
value: t("persistent"),
},
{
key: "urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
value: t("transient"),
},
{
key: "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",
value: t("email"),
},
{
key: "urn:oasis:names:tc:SAML:2.0:nameid-format:kerberos",
value: t("kerberos"),
},
{
key: "urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName",
value: t("x509"),
},
{
key: "urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName",
value: t("windowsDomainQN"),
},
{
key: "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified",
value: t("unspecified"),
},
] }), _jsx(SelectControl, { name: "config.principalType", label: t("principalType"), labelIcon: t("principalTypeHelp"), controller: {
defaultValue: "SUBJECT",
}, isDisabled: readOnly, options: [
{ key: "SUBJECT", value: t("subjectNameId") },
{ key: "ATTRIBUTE", value: t("attributeName") },
{ key: "FRIENDLY_ATTRIBUTE", value: t("attributeFriendlyName") },
] }), (principalType === null || principalType === void 0 ? void 0 : principalType.includes("ATTRIBUTE")) && (_jsx(TextControl, { name: "config.principalAttribute", label: t("principalAttribute"), labelIcon: t("principalAttributeHelp"), readOnly: readOnly })), _jsx(DefaultSwitchControl, { name: "config.allowCreate", label: t("allowCreate"), isDisabled: readOnly, stringify: true }), _jsx(DefaultSwitchControl, { name: "config.postBindingResponse", label: t("httpPostBindingResponse"), isDisabled: readOnly, stringify: true }), _jsx(DefaultSwitchControl, { name: "config.artifactBindingResponse", label: t("artifactBindingResponse"), isDisabled: readOnly, stringify: true }), _jsx(DefaultSwitchControl, { name: "config.postBindingAuthnRequest", label: t("httpPostBindingAuthnRequest"), isDisabled: readOnly, stringify: true }), _jsx(DefaultSwitchControl, { name: "config.postBindingLogout", label: t("httpPostBindingLogout"), isDisabled: readOnly, stringify: true }), _jsx(DefaultSwitchControl, { name: "config.wantAuthnRequestsSigned", label: t("wantAuthnRequestsSigned"), isDisabled: readOnly, stringify: true }), wantAuthnSigned === "true" && (_jsxs(_Fragment, { children: [_jsx(SelectControl, { name: "config.signatureAlgorithm", label: t("signatureAlgorithm"), labelIcon: t("signatureAlgorithmHelp"), isDisabled: readOnly, controller: {
defaultValue: "RSA_SHA256",
}, options: [
"RSA_SHA1",
"RSA_SHA256",
"RSA_SHA256_MGF1",
"RSA_SHA512",
"RSA_SHA512_MGF1",
"DSA_SHA1",
] }), _jsx(SelectControl, { name: "config.xmlSigKeyInfoKeyNameTransformer", label: t("samlSignatureKeyName"), labelIcon: t("samlSignatureKeyNameHelp"), isDisabled: readOnly, controller: {
defaultValue: t("keyID"),
}, options: ["NONE", t("keyID"), t("certSubject")] })] })), _jsx(DefaultSwitchControl, { name: "config.wantAssertionsSigned", label: t("wantAssertionsSigned"), isDisabled: readOnly, stringify: true }), _jsx(DefaultSwitchControl, { name: "config.wantAssertionsEncrypted", label: t("wantAssertionsEncrypted"), isDisabled: readOnly, stringify: true }), wantAssertionsEncrypted === "true" && (_jsx(SelectControl, { name: "config.encryptionAlgorithm", label: t("encryptionAlgorithm"), labelIcon: t("encryptionAlgorithmHelp"), isDisabled: readOnly, controller: {
defaultValue: "RSA-OAEP",
}, options: ["RSA-OAEP", "RSA1_5"] })), _jsx(DefaultSwitchControl, { name: "config.forceAuthn", label: t("forceAuthentication"), isDisabled: readOnly, stringify: true }), _jsx(DefaultSwitchControl, { name: "config.validateSignature", label: t("validateSignature"), isDisabled: readOnly, stringify: true }), validateSignature === "true" && (_jsxs(_Fragment, { children: [_jsx(TextControl, { name: "config.metadataDescriptorUrl", label: t("metadataDescriptorUrl"), labelIcon: t("metadataDescriptorUrlHelp"), type: "url", readOnly: readOnly, rules: {
required: {
value: useMetadataDescriptorUrl === "true",
message: t("required"),
},
} }), _jsx(DefaultSwitchControl, { name: "config.useMetadataDescriptorUrl", label: t("useMetadataDescriptorUrl"), isDisabled: readOnly, stringify: true }), useMetadataDescriptorUrl !== "true" && (_jsx(TextAreaControl, { name: "config.signingCertificate", label: t("validatingX509Certs"), labelIcon: t("validatingX509CertsHelp"), readOnly: readOnly }))] })), _jsx(DefaultSwitchControl, { name: "config.signSpMetadata", label: t("signServiceProviderMetadata"), isDisabled: readOnly, stringify: true }), _jsx(DefaultSwitchControl, { name: "config.loginHint", label: t("passSubject"), isDisabled: readOnly, stringify: true }), _jsx(NumberControl, { name: "config.allowedClockSkew", label: t("allowedClockSkew"), labelIcon: t("allowedClockSkewHelp"), controller: { defaultValue: 0, rules: { min: 0, max: 2147483 } }, isDisabled: readOnly }), _jsx(NumberControl, { name: "config.attributeConsumingServiceIndex", label: t("attributeConsumingServiceIndex"), labelIcon: t("attributeConsumingServiceIndexHelp"), controller: { defaultValue: 0, rules: { min: 0, max: 2147483 } }, isDisabled: readOnly }), _jsx(TextControl, { name: "config.attributeConsumingServiceName", label: t("attributeConsumingServiceName"), labelIcon: t("attributeConsumingServiceNameHelp"), readOnly: readOnly })] }) }));
};
export const DescriptorSettings = ({ readOnly }) => {
const { t } = useTranslation();
const [isExpanded, setIsExpanded] = useState(false);
return readOnly ? (_jsx(ExpandableSection, { className: "keycloak__discovery-settings__metadata", toggleText: isExpanded ? t("hideMetaData") : t("showMetaData"), onToggle: (_event, isOpen) => setIsExpanded(isOpen), isExpanded: isExpanded, children: _jsx(Fields, { readOnly: readOnly }) })) : (_jsx(Fields, { readOnly: readOnly }));
};
//# sourceMappingURL=DescriptorSettings.js.map