2020-09-22 12:43:51 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2021-04-26 11:48:09 +00:00
|
|
|
import { Controller, useFormContext } from "react-hook-form";
|
2020-08-31 18:26:25 +00:00
|
|
|
import {
|
|
|
|
FormGroup,
|
|
|
|
Switch,
|
|
|
|
Checkbox,
|
|
|
|
Grid,
|
|
|
|
GridItem,
|
2021-03-19 07:49:33 +00:00
|
|
|
InputGroup,
|
2020-08-31 18:26:25 +00:00
|
|
|
} from "@patternfly/react-core";
|
2021-04-26 11:48:09 +00:00
|
|
|
|
2022-03-09 16:42:23 +00:00
|
|
|
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
|
2020-10-28 18:17:15 +00:00
|
|
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
2021-03-09 13:59:41 +00:00
|
|
|
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
2022-08-09 08:32:16 +00:00
|
|
|
import { convertAttributeNameToForm } from "../../util";
|
2021-03-09 13:59:41 +00:00
|
|
|
|
2021-04-26 11:48:09 +00:00
|
|
|
import "./capability-config.css";
|
|
|
|
|
2021-03-09 13:59:41 +00:00
|
|
|
type CapabilityConfigProps = {
|
|
|
|
unWrap?: boolean;
|
|
|
|
protocol?: string;
|
|
|
|
};
|
2020-10-28 18:17:15 +00:00
|
|
|
|
2021-03-09 13:59:41 +00:00
|
|
|
export const CapabilityConfig = ({
|
|
|
|
unWrap,
|
|
|
|
protocol: type,
|
|
|
|
}: CapabilityConfigProps) => {
|
2020-09-17 13:51:40 +00:00
|
|
|
const { t } = useTranslation("clients");
|
2022-03-09 16:42:23 +00:00
|
|
|
const { control, watch, setValue } = useFormContext<ClientRepresentation>();
|
2021-03-09 13:59:41 +00:00
|
|
|
const protocol = type || watch("protocol");
|
2021-03-19 07:49:33 +00:00
|
|
|
const clientAuthentication = watch("publicClient");
|
2021-04-26 07:40:59 +00:00
|
|
|
const authorization = watch("authorizationServicesEnabled");
|
2021-03-09 13:59:41 +00:00
|
|
|
|
2020-09-17 13:51:40 +00:00
|
|
|
return (
|
2021-04-26 11:48:09 +00:00
|
|
|
<FormAccess
|
|
|
|
isHorizontal
|
|
|
|
role="manage-clients"
|
|
|
|
unWrap={unWrap}
|
|
|
|
className="keycloak__capability-config__form"
|
2021-10-06 11:05:27 +00:00
|
|
|
data-testid="capability-config-form"
|
2021-04-26 11:48:09 +00:00
|
|
|
>
|
2021-08-26 12:15:28 +00:00
|
|
|
{protocol === "openid-connect" && (
|
|
|
|
<>
|
|
|
|
<FormGroup
|
|
|
|
hasNoPaddingTop
|
|
|
|
label={t("clientAuthentication")}
|
|
|
|
fieldId="kc-authentication"
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:authentication"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:authentication"
|
2021-03-09 13:59:41 +00:00
|
|
|
/>
|
2021-08-26 12:15:28 +00:00
|
|
|
}
|
|
|
|
>
|
|
|
|
<Controller
|
|
|
|
name="publicClient"
|
|
|
|
defaultValue={false}
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Switch
|
|
|
|
data-testid="authentication"
|
|
|
|
id="kc-authentication-switch"
|
|
|
|
name="publicClient"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
isChecked={!value}
|
|
|
|
onChange={(value) => {
|
|
|
|
onChange(!value);
|
|
|
|
if (!value) {
|
|
|
|
setValue("authorizationServicesEnabled", false);
|
|
|
|
setValue("serviceAccountsEnabled", false);
|
2022-08-09 08:32:16 +00:00
|
|
|
setValue(
|
|
|
|
convertAttributeNameToForm(
|
|
|
|
"attributes.oidc.ciba.grant.enabled"
|
|
|
|
),
|
|
|
|
false
|
|
|
|
);
|
2021-08-26 12:15:28 +00:00
|
|
|
}
|
|
|
|
}}
|
2022-08-30 13:07:51 +00:00
|
|
|
aria-label={t("clientAuthentication")}
|
2021-04-13 00:05:00 +00:00
|
|
|
/>
|
2021-08-26 12:15:28 +00:00
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
hasNoPaddingTop
|
|
|
|
label={t("clientAuthorization")}
|
|
|
|
fieldId="kc-authorization"
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:authorization"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:authorization"
|
2021-03-09 13:59:41 +00:00
|
|
|
/>
|
2021-08-26 12:15:28 +00:00
|
|
|
}
|
|
|
|
>
|
|
|
|
<Controller
|
|
|
|
name="authorizationServicesEnabled"
|
|
|
|
defaultValue={false}
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Switch
|
|
|
|
data-testid="authorization"
|
|
|
|
id="kc-authorization-switch"
|
|
|
|
name="authorizationServicesEnabled"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
isChecked={value && !clientAuthentication}
|
|
|
|
onChange={(value) => {
|
|
|
|
onChange(value);
|
|
|
|
if (value) {
|
|
|
|
setValue("serviceAccountsEnabled", true);
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
isDisabled={clientAuthentication}
|
2022-08-30 13:07:51 +00:00
|
|
|
aria-label={t("clientAuthorization")}
|
2021-08-26 12:15:28 +00:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
hasNoPaddingTop
|
|
|
|
label={t("authenticationFlow")}
|
|
|
|
fieldId="kc-flow"
|
|
|
|
>
|
2022-03-02 21:59:37 +00:00
|
|
|
<Grid id="authenticationFlowGrid">
|
2021-08-26 12:15:28 +00:00
|
|
|
<GridItem lg={4} sm={6}>
|
|
|
|
<Controller
|
|
|
|
name="standardFlowEnabled"
|
|
|
|
defaultValue={true}
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<InputGroup>
|
|
|
|
<Checkbox
|
|
|
|
data-testid="standard"
|
|
|
|
label={t("standardFlow")}
|
|
|
|
id="kc-flow-standard"
|
|
|
|
name="standardFlowEnabled"
|
2022-03-02 21:59:37 +00:00
|
|
|
isChecked={value.toString() === "true"}
|
2021-08-26 12:15:28 +00:00
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:standardFlow"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:standardFlow"
|
2021-08-26 12:15:28 +00:00
|
|
|
/>
|
|
|
|
</InputGroup>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</GridItem>
|
|
|
|
<GridItem lg={8} sm={6}>
|
|
|
|
<Controller
|
|
|
|
name="directAccessGrantsEnabled"
|
|
|
|
defaultValue={true}
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<InputGroup>
|
|
|
|
<Checkbox
|
|
|
|
data-testid="direct"
|
|
|
|
label={t("directAccess")}
|
|
|
|
id="kc-flow-direct"
|
|
|
|
name="directAccessGrantsEnabled"
|
|
|
|
isChecked={value}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:directAccess"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:directAccess"
|
2021-08-26 12:15:28 +00:00
|
|
|
/>
|
|
|
|
</InputGroup>
|
|
|
|
)}
|
2020-09-17 13:51:40 +00:00
|
|
|
/>
|
2021-08-26 12:15:28 +00:00
|
|
|
</GridItem>
|
|
|
|
<GridItem lg={4} sm={6}>
|
|
|
|
<Controller
|
|
|
|
name="implicitFlowEnabled"
|
2022-03-02 21:59:37 +00:00
|
|
|
defaultValue={true}
|
2021-08-26 12:15:28 +00:00
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<InputGroup>
|
|
|
|
<Checkbox
|
|
|
|
data-testid="implicit"
|
|
|
|
label={t("implicitFlow")}
|
|
|
|
id="kc-flow-implicit"
|
|
|
|
name="implicitFlowEnabled"
|
2022-03-02 21:59:37 +00:00
|
|
|
isChecked={value.toString() === "true"}
|
2021-08-26 12:15:28 +00:00
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:implicitFlow"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:implicitFlow"
|
2021-08-26 12:15:28 +00:00
|
|
|
/>
|
|
|
|
</InputGroup>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</GridItem>
|
|
|
|
<GridItem lg={8} sm={6}>
|
|
|
|
<Controller
|
|
|
|
name="serviceAccountsEnabled"
|
|
|
|
defaultValue={false}
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<InputGroup>
|
|
|
|
<Checkbox
|
|
|
|
data-testid="service-account"
|
|
|
|
label={t("serviceAccount")}
|
|
|
|
id="kc-flow-service-account"
|
|
|
|
name="serviceAccountsEnabled"
|
|
|
|
isChecked={
|
2022-03-02 21:59:37 +00:00
|
|
|
value.toString() === "true" ||
|
|
|
|
(clientAuthentication && authorization)
|
2021-08-26 12:15:28 +00:00
|
|
|
}
|
|
|
|
onChange={onChange}
|
|
|
|
isDisabled={
|
|
|
|
(clientAuthentication && !authorization) ||
|
|
|
|
(!clientAuthentication && authorization)
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:serviceAccount"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:serviceAccount"
|
2021-08-26 12:15:28 +00:00
|
|
|
/>
|
|
|
|
</InputGroup>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</GridItem>
|
2022-03-02 21:59:37 +00:00
|
|
|
<GridItem lg={8} sm={6}>
|
|
|
|
<Controller
|
2022-08-09 08:32:16 +00:00
|
|
|
name={convertAttributeNameToForm(
|
|
|
|
"attributes.oauth2.device.authorization.grant.enabled"
|
|
|
|
)}
|
2022-03-02 21:59:37 +00:00
|
|
|
defaultValue={false}
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<InputGroup>
|
|
|
|
<Checkbox
|
|
|
|
data-testid="oauth-device-authorization-grant"
|
|
|
|
label={t("oauthDeviceAuthorizationGrant")}
|
|
|
|
id="kc-oauth-device-authorization-grant"
|
|
|
|
name="oauth2.device.authorization.grant.enabled"
|
|
|
|
isChecked={value.toString() === "true"}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:oauthDeviceAuthorizationGrant"
|
|
|
|
fieldLabelId="clients:oauthDeviceAuthorizationGrant"
|
|
|
|
/>
|
|
|
|
</InputGroup>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</GridItem>
|
|
|
|
<GridItem lg={8} sm={6}>
|
|
|
|
<Controller
|
2022-08-09 08:32:16 +00:00
|
|
|
name={convertAttributeNameToForm(
|
|
|
|
"attributes.oidc.ciba.grant.enabled"
|
|
|
|
)}
|
2022-03-02 21:59:37 +00:00
|
|
|
defaultValue={false}
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<InputGroup>
|
|
|
|
<Checkbox
|
|
|
|
data-testid="oidc-ciba-grant"
|
|
|
|
label={t("oidcCibaGrant")}
|
|
|
|
id="kc-oidc-ciba-grant"
|
|
|
|
name="oidc.ciba.grant.enabled"
|
|
|
|
isChecked={value.toString() === "true"}
|
|
|
|
onChange={onChange}
|
|
|
|
isDisabled={clientAuthentication}
|
|
|
|
/>
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:oidcCibaGrant"
|
|
|
|
fieldLabelId="clients:oidcCibaGrant"
|
|
|
|
/>
|
|
|
|
</InputGroup>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</GridItem>
|
2021-08-26 12:15:28 +00:00
|
|
|
</Grid>
|
|
|
|
</FormGroup>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{protocol === "saml" && (
|
|
|
|
<>
|
|
|
|
<FormGroup
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:encryptAssertions"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:encryptAssertions"
|
2021-03-09 13:59:41 +00:00
|
|
|
/>
|
2021-08-26 12:15:28 +00:00
|
|
|
}
|
|
|
|
label={t("encryptAssertions")}
|
|
|
|
fieldId="kc-encrypt"
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
|
|
|
<Controller
|
2022-08-09 08:32:16 +00:00
|
|
|
name={convertAttributeNameToForm("attributes.saml.encrypt")}
|
2021-08-26 12:15:28 +00:00
|
|
|
control={control}
|
2022-03-02 21:59:37 +00:00
|
|
|
defaultValue={false}
|
2021-08-26 12:15:28 +00:00
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Switch
|
|
|
|
data-testid="encrypt"
|
|
|
|
id="kc-encrypt"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
2022-03-02 21:59:37 +00:00
|
|
|
isChecked={value}
|
|
|
|
onChange={onChange}
|
2022-08-30 13:07:51 +00:00
|
|
|
aria-label={t("encryptAssertions")}
|
2020-09-17 13:51:40 +00:00
|
|
|
/>
|
2021-08-26 12:15:28 +00:00
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:clientSignature"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:clientSignature"
|
2021-03-09 13:59:41 +00:00
|
|
|
/>
|
2021-08-26 12:15:28 +00:00
|
|
|
}
|
|
|
|
label={t("clientSignature")}
|
|
|
|
fieldId="kc-client-signature"
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
|
|
|
<Controller
|
2022-08-09 08:32:16 +00:00
|
|
|
name={convertAttributeNameToForm(
|
|
|
|
"attributes.saml.client.signature"
|
|
|
|
)}
|
2021-08-26 12:15:28 +00:00
|
|
|
control={control}
|
2022-03-02 21:59:37 +00:00
|
|
|
defaultValue={false}
|
2021-08-26 12:15:28 +00:00
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Switch
|
|
|
|
data-testid="client-signature"
|
|
|
|
id="kc-client-signature"
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
2022-03-02 21:59:37 +00:00
|
|
|
isChecked={value}
|
|
|
|
onChange={onChange}
|
2022-08-30 13:07:51 +00:00
|
|
|
aria-label={t("clientSignature")}
|
2021-08-26 12:15:28 +00:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
</>
|
|
|
|
)}
|
2020-10-28 18:17:15 +00:00
|
|
|
</FormAccess>
|
2020-09-17 13:51:40 +00:00
|
|
|
);
|
|
|
|
};
|