2022-08-03 12:12:07 +00:00
|
|
|
import { useState } from "react";
|
2020-11-02 20:15:09 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2021-02-28 20:02:31 +00:00
|
|
|
import { Controller, useFormContext } from "react-hook-form";
|
2020-11-02 20:15:09 +00:00
|
|
|
import {
|
|
|
|
FormGroup,
|
|
|
|
Select,
|
|
|
|
SelectOption,
|
|
|
|
SelectVariant,
|
|
|
|
} from "@patternfly/react-core";
|
|
|
|
|
|
|
|
import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
|
|
|
|
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
|
|
|
import { sortProviders } from "../../util";
|
|
|
|
|
2021-02-28 20:02:31 +00:00
|
|
|
export const SignedJWT = () => {
|
|
|
|
const { control } = useFormContext();
|
2020-11-02 20:15:09 +00:00
|
|
|
const providers = sortProviders(
|
2020-11-12 12:55:52 +00:00
|
|
|
useServerInfo().providers!.clientSignature.providers
|
2020-11-02 20:15:09 +00:00
|
|
|
);
|
|
|
|
const { t } = useTranslation("clients");
|
|
|
|
|
|
|
|
const [open, isOpen] = useState(false);
|
|
|
|
return (
|
2021-08-26 12:15:28 +00:00
|
|
|
<FormGroup
|
|
|
|
label={t("signatureAlgorithm")}
|
|
|
|
fieldId="kc-signature-algorithm"
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:signature-algorithm"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:signatureAlgorithm"
|
2020-11-02 20:15:09 +00:00
|
|
|
/>
|
2021-08-26 12:15:28 +00:00
|
|
|
}
|
|
|
|
>
|
|
|
|
<Controller
|
2021-12-08 15:08:42 +00:00
|
|
|
name="attributes.token.endpoint.auth.signing.alg"
|
2021-08-26 12:15:28 +00:00
|
|
|
defaultValue=""
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Select
|
|
|
|
maxHeight={200}
|
|
|
|
toggleId="kc-signature-algorithm"
|
2021-11-30 13:07:44 +00:00
|
|
|
onToggle={isOpen}
|
2021-08-26 12:15:28 +00:00
|
|
|
onSelect={(_, value) => {
|
2021-11-30 13:07:44 +00:00
|
|
|
onChange(value.toString());
|
2021-08-26 12:15:28 +00:00
|
|
|
isOpen(false);
|
|
|
|
}}
|
|
|
|
selections={value || t("anyAlgorithm")}
|
|
|
|
variant={SelectVariant.single}
|
|
|
|
aria-label={t("signatureAlgorithm")}
|
|
|
|
isOpen={open}
|
|
|
|
>
|
|
|
|
<SelectOption selected={value === ""} key="any" value="">
|
|
|
|
{t("anyAlgorithm")}
|
|
|
|
</SelectOption>
|
|
|
|
<>
|
|
|
|
{providers.map((option) => (
|
|
|
|
<SelectOption
|
|
|
|
selected={option === value}
|
|
|
|
key={option}
|
|
|
|
value={option}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</>
|
|
|
|
</Select>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
2020-11-02 20:15:09 +00:00
|
|
|
);
|
|
|
|
};
|