2022-05-30 11:07:33 +00:00
|
|
|
import React from "react";
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import { useFormContext } from "react-hook-form";
|
|
|
|
import { AlertVariant, PageSection, Text } from "@patternfly/react-core";
|
|
|
|
|
2021-08-26 08:39:35 +00:00
|
|
|
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
|
|
|
|
import type GlobalRequestResult from "@keycloak/keycloak-admin-client/lib/defs/globalRequestResult";
|
2022-05-30 11:07:33 +00:00
|
|
|
|
|
|
|
import type { AddAlertFunction } from "../components/alert/Alerts";
|
2021-07-21 15:08:40 +00:00
|
|
|
import { ScrollForm } from "../components/scroll-form/ScrollForm";
|
|
|
|
import { convertToFormValues, toUpperCase } from "../util";
|
|
|
|
import { AdvancedSettings } from "./advanced/AdvancedSettings";
|
2021-02-28 20:02:31 +00:00
|
|
|
import { AuthenticationOverrides } from "./advanced/AuthenticationOverrides";
|
2021-07-21 15:08:40 +00:00
|
|
|
import { FineGrainOpenIdConnect } from "./advanced/FineGrainOpenIdConnect";
|
|
|
|
import { FineGrainSamlEndpointConfig } from "./advanced/FineGrainSamlEndpointConfig";
|
|
|
|
import { OpenIdConnectCompatibilityModes } from "./advanced/OpenIdConnectCompatibilityModes";
|
2021-05-04 17:58:18 +00:00
|
|
|
import type { SaveOptions } from "./ClientDetails";
|
2022-05-30 11:07:33 +00:00
|
|
|
import type { TFunction } from "i18next";
|
|
|
|
import { RevocationPanel } from "./advanced/RevocationPanel";
|
|
|
|
import { ClusteringPanel } from "./advanced/ClusteringPanel";
|
|
|
|
|
|
|
|
export const parseResult = (
|
|
|
|
result: GlobalRequestResult,
|
|
|
|
prefixKey: string,
|
|
|
|
addAlert: AddAlertFunction,
|
|
|
|
t: TFunction
|
|
|
|
) => {
|
|
|
|
const successCount = result.successRequests?.length || 0;
|
|
|
|
const failedCount = result.failedRequests?.length || 0;
|
2021-02-28 20:02:31 +00:00
|
|
|
|
2022-05-30 11:07:33 +00:00
|
|
|
if (successCount === 0 && failedCount === 0) {
|
|
|
|
addAlert(t("noAdminUrlSet"), AlertVariant.warning);
|
|
|
|
} else if (failedCount > 0) {
|
|
|
|
addAlert(
|
|
|
|
t(prefixKey + "Success", { successNodes: result.successRequests }),
|
|
|
|
AlertVariant.success
|
|
|
|
);
|
|
|
|
addAlert(
|
|
|
|
t(prefixKey + "Fail", { failedNodes: result.failedRequests }),
|
|
|
|
AlertVariant.danger
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
addAlert(
|
|
|
|
t(prefixKey + "Success", { successNodes: result.successRequests }),
|
|
|
|
AlertVariant.success
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export type AdvancedProps = {
|
2021-03-17 13:40:19 +00:00
|
|
|
save: (options?: SaveOptions) => void;
|
2021-02-28 20:02:31 +00:00
|
|
|
client: ClientRepresentation;
|
|
|
|
};
|
|
|
|
|
2022-05-30 11:07:33 +00:00
|
|
|
export const AdvancedTab = ({ save, client }: AdvancedProps) => {
|
|
|
|
const { t } = useTranslation("clients");
|
|
|
|
const openIdConnect = "openid-connect";
|
|
|
|
|
|
|
|
const { setValue, control, reset } = useFormContext();
|
|
|
|
const {
|
2022-03-07 14:28:26 +00:00
|
|
|
publicClient,
|
2021-02-28 20:02:31 +00:00
|
|
|
attributes,
|
|
|
|
protocol,
|
|
|
|
authenticationFlowBindingOverrides,
|
2022-05-30 11:07:33 +00:00
|
|
|
} = client;
|
2021-02-28 20:02:31 +00:00
|
|
|
|
|
|
|
const resetFields = (names: string[]) => {
|
|
|
|
const values: { [name: string]: string } = {};
|
|
|
|
for (const name of names) {
|
2021-12-08 15:08:42 +00:00
|
|
|
values[`attributes.${name}`] = attributes?.[name];
|
2021-02-28 20:02:31 +00:00
|
|
|
}
|
|
|
|
reset(values);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2021-04-20 19:46:07 +00:00
|
|
|
<PageSection variant="light" className="pf-u-py-0">
|
2022-05-30 11:07:33 +00:00
|
|
|
<ScrollForm
|
|
|
|
sections={[
|
|
|
|
{
|
|
|
|
title: t("revocation"),
|
|
|
|
isHidden: protocol !== openIdConnect,
|
|
|
|
panel: <RevocationPanel client={client} save={save} />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: t("clustering"),
|
|
|
|
isHidden: !publicClient,
|
|
|
|
panel: <ClusteringPanel client={client} save={save} />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: t("fineGrainOpenIdConnectConfiguration"),
|
|
|
|
isHidden: protocol !== openIdConnect,
|
|
|
|
panel: (
|
|
|
|
<>
|
|
|
|
<Text className="pf-u-pb-lg">
|
|
|
|
{t("clients-help:fineGrainOpenIdConnectConfiguration")}
|
|
|
|
</Text>
|
|
|
|
<FineGrainOpenIdConnect
|
|
|
|
save={save}
|
|
|
|
reset={() =>
|
|
|
|
convertToFormValues(attributes, (key, value) =>
|
|
|
|
setValue(`attributes.${key}`, value)
|
2022-03-07 14:28:26 +00:00
|
|
|
)
|
|
|
|
}
|
2022-05-30 11:07:33 +00:00
|
|
|
/>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: t("openIdConnectCompatibilityModes"),
|
|
|
|
isHidden: protocol !== openIdConnect,
|
|
|
|
panel: (
|
|
|
|
<>
|
|
|
|
<Text className="pf-u-pb-lg">
|
|
|
|
{t("clients-help:openIdConnectCompatibilityModes")}
|
|
|
|
</Text>
|
|
|
|
<OpenIdConnectCompatibilityModes
|
|
|
|
control={control}
|
|
|
|
save={() => save()}
|
|
|
|
reset={() =>
|
|
|
|
resetFields(["exclude.session.state.from.auth.response"])
|
2022-03-07 14:28:26 +00:00
|
|
|
}
|
2022-05-30 11:07:33 +00:00
|
|
|
/>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: t("fineGrainSamlEndpointConfig"),
|
|
|
|
isHidden: protocol === openIdConnect,
|
|
|
|
panel: (
|
|
|
|
<>
|
|
|
|
<Text className="pf-u-pb-lg">
|
|
|
|
{t("clients-help:fineGrainSamlEndpointConfig")}
|
|
|
|
</Text>
|
|
|
|
<FineGrainSamlEndpointConfig
|
|
|
|
control={control}
|
|
|
|
save={() => save()}
|
|
|
|
reset={() =>
|
|
|
|
convertToFormValues(attributes, (key, value) =>
|
|
|
|
setValue(`attributes.${key}`, value)
|
|
|
|
)
|
2022-03-07 14:28:26 +00:00
|
|
|
}
|
|
|
|
/>
|
2022-05-30 11:07:33 +00:00
|
|
|
</>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: t("advancedSettings"),
|
|
|
|
panel: (
|
|
|
|
<>
|
|
|
|
<Text className="pf-u-pb-lg">
|
|
|
|
{t(
|
|
|
|
"clients-help:advancedSettings" +
|
|
|
|
toUpperCase(protocol || "")
|
|
|
|
)}
|
|
|
|
</Text>
|
|
|
|
<AdvancedSettings
|
|
|
|
protocol={protocol}
|
|
|
|
control={control}
|
|
|
|
save={() => save()}
|
|
|
|
reset={() => {
|
|
|
|
resetFields([
|
|
|
|
"saml.assertion.lifespan",
|
|
|
|
"access.token.lifespan",
|
|
|
|
"tls.client.certificate.bound.access.tokens",
|
|
|
|
"pkce.code.challenge.method",
|
|
|
|
]);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: t("authenticationOverrides"),
|
|
|
|
panel: (
|
|
|
|
<>
|
|
|
|
<Text className="pf-u-pb-lg">
|
|
|
|
{t("clients-help:authenticationOverrides")}
|
|
|
|
</Text>
|
|
|
|
<AuthenticationOverrides
|
|
|
|
protocol={protocol}
|
|
|
|
control={control}
|
|
|
|
save={() => save()}
|
|
|
|
reset={() => {
|
|
|
|
setValue(
|
|
|
|
"authenticationFlowBindingOverrides.browser",
|
|
|
|
authenticationFlowBindingOverrides?.browser
|
|
|
|
);
|
|
|
|
setValue(
|
|
|
|
"authenticationFlowBindingOverrides.direct_grant",
|
|
|
|
authenticationFlowBindingOverrides?.direct_grant
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
borders
|
|
|
|
/>
|
2021-04-01 14:14:19 +00:00
|
|
|
</PageSection>
|
2021-02-28 20:02:31 +00:00
|
|
|
);
|
|
|
|
};
|