2021-02-28 20:02:31 +00:00
|
|
|
import React, { useState } from "react";
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import { Control, Controller } from "react-hook-form";
|
|
|
|
import {
|
|
|
|
ActionGroup,
|
|
|
|
Button,
|
|
|
|
FormGroup,
|
|
|
|
Select,
|
|
|
|
SelectOption,
|
|
|
|
SelectVariant,
|
|
|
|
Switch,
|
|
|
|
} from "@patternfly/react-core";
|
|
|
|
|
|
|
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
|
|
|
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
|
|
|
import { TimeSelector } from "../../components/time-selector/TimeSelector";
|
2021-08-10 11:49:08 +00:00
|
|
|
import { TokenLifespan } from "./TokenLifespan";
|
2021-02-28 20:02:31 +00:00
|
|
|
|
|
|
|
type AdvancedSettingsProps = {
|
|
|
|
control: Control<Record<string, any>>;
|
|
|
|
save: () => void;
|
|
|
|
reset: () => void;
|
|
|
|
protocol?: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const AdvancedSettings = ({
|
|
|
|
control,
|
|
|
|
save,
|
|
|
|
reset,
|
|
|
|
protocol,
|
|
|
|
}: AdvancedSettingsProps) => {
|
|
|
|
const { t } = useTranslation("clients");
|
|
|
|
const [open, setOpen] = useState(false);
|
|
|
|
return (
|
|
|
|
<FormAccess role="manage-realm" isHorizontal>
|
|
|
|
{protocol !== "openid-connect" && (
|
|
|
|
<FormGroup
|
|
|
|
label={t("assertionLifespan")}
|
|
|
|
fieldId="assertionLifespan"
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:assertionLifespan"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:assertionLifespan"
|
2021-02-28 20:02:31 +00:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<Controller
|
2021-12-08 15:08:42 +00:00
|
|
|
name="attributes.saml.assertion.lifespan"
|
2021-02-28 20:02:31 +00:00
|
|
|
defaultValue=""
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<TimeSelector
|
|
|
|
units={["minutes", "days", "hours"]}
|
|
|
|
value={value}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
)}
|
|
|
|
{protocol === "openid-connect" && (
|
|
|
|
<>
|
2021-08-10 11:49:08 +00:00
|
|
|
<TokenLifespan
|
|
|
|
id="accessTokenLifespan"
|
2021-12-08 15:08:42 +00:00
|
|
|
name="attributes.access.token.lifespan"
|
2021-08-10 11:49:08 +00:00
|
|
|
defaultValue=""
|
|
|
|
units={["minutes", "days", "hours"]}
|
|
|
|
control={control}
|
|
|
|
/>
|
2021-02-28 20:02:31 +00:00
|
|
|
|
|
|
|
<FormGroup
|
|
|
|
label={t("oAuthMutual")}
|
|
|
|
fieldId="oAuthMutual"
|
|
|
|
hasNoPaddingTop
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:oAuthMutual"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:oAuthMutual"
|
2021-02-28 20:02:31 +00:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<Controller
|
|
|
|
name="attributes.tls-client-certificate-bound-access-tokens"
|
|
|
|
defaultValue={false}
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Switch
|
2021-07-12 14:09:14 +00:00
|
|
|
id="oAuthMutual-switch"
|
2021-02-28 20:02:31 +00:00
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
isChecked={value === "true"}
|
|
|
|
onChange={(value) => onChange("" + value)}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("keyForCodeExchange")}
|
|
|
|
fieldId="keyForCodeExchange"
|
|
|
|
hasNoPaddingTop
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:keyForCodeExchange"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:keyForCodeExchange"
|
2021-02-28 20:02:31 +00:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<Controller
|
2021-12-08 15:08:42 +00:00
|
|
|
name="attributes.pkce.code.challenge.method"
|
2021-03-17 13:40:19 +00:00
|
|
|
defaultValue=""
|
2021-02-28 20:02:31 +00:00
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Select
|
|
|
|
toggleId="keyForCodeExchange"
|
|
|
|
variant={SelectVariant.single}
|
2021-11-30 13:07:44 +00:00
|
|
|
onToggle={setOpen}
|
2021-02-28 20:02:31 +00:00
|
|
|
isOpen={open}
|
|
|
|
onSelect={(_, value) => {
|
|
|
|
onChange(value);
|
|
|
|
setOpen(false);
|
|
|
|
}}
|
2021-03-17 13:40:19 +00:00
|
|
|
selections={[value || t("common:choose")]}
|
2021-02-28 20:02:31 +00:00
|
|
|
>
|
|
|
|
{["", "S256", "plain"].map((v) => (
|
2021-03-17 13:40:19 +00:00
|
|
|
<SelectOption key={v} value={v}>
|
|
|
|
{v || t("common:choose")}
|
|
|
|
</SelectOption>
|
2021-02-28 20:02:31 +00:00
|
|
|
))}
|
|
|
|
</Select>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
<ActionGroup>
|
2021-08-16 09:22:56 +00:00
|
|
|
<Button variant="secondary" onClick={save}>
|
2021-02-28 20:02:31 +00:00
|
|
|
{t("common:save")}
|
|
|
|
</Button>
|
|
|
|
<Button variant="link" onClick={reset}>
|
2021-03-12 16:30:14 +00:00
|
|
|
{t("common:revert")}
|
2021-02-28 20:02:31 +00:00
|
|
|
</Button>
|
|
|
|
</ActionGroup>
|
|
|
|
</FormAccess>
|
|
|
|
);
|
|
|
|
};
|