2023-11-14 11:04:55 +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 { AlertVariant, PageSection, Text } from "@patternfly/react-core";
|
2022-12-02 14:54:30 +00:00
|
|
|
import type { TFunction } from "i18next";
|
2023-01-26 09:31:07 +00:00
|
|
|
import { useFormContext } from "react-hook-form";
|
2022-12-02 14:54:30 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2023-11-14 11:04:55 +00:00
|
|
|
import { ScrollForm } from "ui-shared";
|
2022-05-30 11:07:33 +00:00
|
|
|
import type { AddAlertFunction } from "../components/alert/Alerts";
|
2022-09-14 09:55:25 +00:00
|
|
|
import { convertAttributeNameToForm, toUpperCase } from "../util";
|
2023-11-14 11:04:55 +00:00
|
|
|
import type { FormFields, SaveOptions } from "./ClientDetails";
|
2021-07-21 15:08:40 +00:00
|
|
|
import { AdvancedSettings } from "./advanced/AdvancedSettings";
|
2021-02-28 20:02:31 +00:00
|
|
|
import { AuthenticationOverrides } from "./advanced/AuthenticationOverrides";
|
2022-12-02 14:54:30 +00:00
|
|
|
import { ClusteringPanel } from "./advanced/ClusteringPanel";
|
2021-07-21 15:08:40 +00:00
|
|
|
import { FineGrainOpenIdConnect } from "./advanced/FineGrainOpenIdConnect";
|
|
|
|
import { FineGrainSamlEndpointConfig } from "./advanced/FineGrainSamlEndpointConfig";
|
|
|
|
import { OpenIdConnectCompatibilityModes } from "./advanced/OpenIdConnectCompatibilityModes";
|
2022-05-30 11:07:33 +00:00
|
|
|
import { RevocationPanel } from "./advanced/RevocationPanel";
|
|
|
|
|
|
|
|
export const parseResult = (
|
|
|
|
result: GlobalRequestResult,
|
|
|
|
prefixKey: string,
|
|
|
|
addAlert: AddAlertFunction,
|
2023-07-11 14:03:21 +00:00
|
|
|
t: TFunction,
|
2022-05-30 11:07:33 +00:00
|
|
|
) => {
|
|
|
|
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 }),
|
2023-07-11 14:03:21 +00:00
|
|
|
AlertVariant.success,
|
2022-05-30 11:07:33 +00:00
|
|
|
);
|
|
|
|
addAlert(
|
|
|
|
t(prefixKey + "Fail", { failedNodes: result.failedRequests }),
|
2023-07-11 14:03:21 +00:00
|
|
|
AlertVariant.danger,
|
2022-05-30 11:07:33 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
addAlert(
|
|
|
|
t(prefixKey + "Success", { successNodes: result.successRequests }),
|
2023-07-11 14:03:21 +00:00
|
|
|
AlertVariant.success,
|
2022-05-30 11:07:33 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
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) => {
|
2023-09-08 13:17:17 +00:00
|
|
|
const { t } = useTranslation();
|
2022-05-30 11:07:33 +00:00
|
|
|
const openIdConnect = "openid-connect";
|
|
|
|
|
2022-12-02 14:54:30 +00:00
|
|
|
const { setValue } = useFormContext();
|
2022-05-30 11:07:33 +00:00
|
|
|
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[]) => {
|
|
|
|
for (const name of names) {
|
2022-09-14 09:55:25 +00:00
|
|
|
setValue(
|
2022-12-02 14:54:30 +00:00
|
|
|
convertAttributeNameToForm<FormFields>(`attributes.${name}`),
|
2023-07-11 14:03:21 +00:00
|
|
|
attributes?.[name] || "",
|
2022-09-14 09:55:25 +00:00
|
|
|
);
|
2021-02-28 20:02:31 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
2023-11-14 11:04:55 +00:00
|
|
|
label={t("jumpToSection")}
|
2022-05-30 11:07:33 +00:00
|
|
|
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">
|
2023-09-08 13:17:17 +00:00
|
|
|
{t("fineGrainOpenIdConnectConfigurationHelp")}
|
2022-05-30 11:07:33 +00:00
|
|
|
</Text>
|
|
|
|
<FineGrainOpenIdConnect
|
|
|
|
save={save}
|
2022-09-14 09:55:25 +00:00
|
|
|
reset={() => {
|
|
|
|
resetFields([
|
|
|
|
"logoUri",
|
|
|
|
"policyUri",
|
|
|
|
"tosUri",
|
|
|
|
"access.token.signed.response.alg",
|
|
|
|
"id.token.signed.response.alg",
|
|
|
|
"id.token.encrypted.response.alg",
|
|
|
|
"id.token.encrypted.response.enc",
|
|
|
|
"user.info.response.signature.alg",
|
2023-03-16 08:05:38 +00:00
|
|
|
"user.info.encrypted.response.alg",
|
|
|
|
"user.info.encrypted.response.enc",
|
2022-09-14 09:55:25 +00:00
|
|
|
"request.object.signature.alg",
|
|
|
|
"request.object.encryption.alg",
|
|
|
|
"request.object.encryption.enc",
|
|
|
|
"request.object.required",
|
|
|
|
"request.uris",
|
2023-03-16 08:05:38 +00:00
|
|
|
"authorization.signed.response.alg",
|
2022-09-14 09:55:25 +00:00
|
|
|
"authorization.encrypted.response.alg",
|
|
|
|
"authorization.encrypted.response.enc",
|
|
|
|
]);
|
|
|
|
}}
|
2022-05-30 11:07:33 +00:00
|
|
|
/>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: t("openIdConnectCompatibilityModes"),
|
|
|
|
isHidden: protocol !== openIdConnect,
|
|
|
|
panel: (
|
|
|
|
<>
|
|
|
|
<Text className="pf-u-pb-lg">
|
2023-09-13 14:05:17 +00:00
|
|
|
{t("openIdConnectCompatibilityModesHelp")}
|
2022-05-30 11:07:33 +00:00
|
|
|
</Text>
|
|
|
|
<OpenIdConnectCompatibilityModes
|
|
|
|
save={() => save()}
|
|
|
|
reset={() =>
|
2023-03-16 08:05:38 +00:00
|
|
|
resetFields([
|
|
|
|
"exclude.session.state.from.auth.response",
|
|
|
|
"use.refresh.tokens",
|
|
|
|
"client_credentials.use_refresh_token",
|
|
|
|
"token.response.type.bearer.lower-case",
|
|
|
|
])
|
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">
|
2023-09-13 14:05:17 +00:00
|
|
|
{t("fineGrainSamlEndpointConfigHelp")}
|
2022-05-30 11:07:33 +00:00
|
|
|
</Text>
|
|
|
|
<FineGrainSamlEndpointConfig
|
|
|
|
save={() => save()}
|
|
|
|
reset={() =>
|
2022-09-14 09:55:25 +00:00
|
|
|
resetFields([
|
|
|
|
"logoUri",
|
|
|
|
"policyUri",
|
|
|
|
"tosUri",
|
|
|
|
"saml_assertion_consumer_url_post",
|
|
|
|
"saml_assertion_consumer_url_redirect",
|
|
|
|
"saml_single_logout_service_url_post",
|
|
|
|
"saml_single_logout_service_url_redirect",
|
|
|
|
"saml_single_logout_service_url_artifact",
|
|
|
|
"saml_artifact_binding_url",
|
|
|
|
"saml_artifact_resolution_service_url",
|
|
|
|
])
|
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">
|
2023-09-13 14:05:17 +00:00
|
|
|
{t("advancedSettings" + toUpperCase(protocol || ""))}
|
2022-05-30 11:07:33 +00:00
|
|
|
</Text>
|
|
|
|
<AdvancedSettings
|
|
|
|
protocol={protocol}
|
|
|
|
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">
|
2023-09-13 14:05:17 +00:00
|
|
|
{t("authenticationOverridesHelp")}
|
2022-05-30 11:07:33 +00:00
|
|
|
</Text>
|
|
|
|
<AuthenticationOverrides
|
|
|
|
protocol={protocol}
|
|
|
|
save={() => save()}
|
|
|
|
reset={() => {
|
|
|
|
setValue(
|
|
|
|
"authenticationFlowBindingOverrides.browser",
|
2023-07-11 14:03:21 +00:00
|
|
|
authenticationFlowBindingOverrides?.browser,
|
2022-05-30 11:07:33 +00:00
|
|
|
);
|
|
|
|
setValue(
|
|
|
|
"authenticationFlowBindingOverrides.direct_grant",
|
2023-07-11 14:03:21 +00:00
|
|
|
authenticationFlowBindingOverrides?.direct_grant,
|
2022-05-30 11:07:33 +00:00
|
|
|
);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
borders
|
|
|
|
/>
|
2021-04-01 14:14:19 +00:00
|
|
|
</PageSection>
|
2021-02-28 20:02:31 +00:00
|
|
|
);
|
|
|
|
};
|