2020-11-02 20:15:09 +00:00
|
|
|
import React, { useState } from "react";
|
|
|
|
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 (
|
|
|
|
<>
|
|
|
|
<FormGroup
|
|
|
|
label={t("signatureAlgorithm")}
|
|
|
|
fieldId="kc-signature-algorithm"
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:signature-algorithm"
|
|
|
|
forLabel={t("signatureAlgorithm")}
|
|
|
|
forID="kc-signature-algorithm"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<Controller
|
2021-02-28 20:02:31 +00:00
|
|
|
name="attributes.token-endpoint-auth-signing-alg"
|
2020-11-02 20:15:09 +00:00
|
|
|
defaultValue={providers[0]}
|
2021-02-28 20:02:31 +00:00
|
|
|
control={control}
|
2020-11-02 20:15:09 +00:00
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Select
|
2021-03-17 07:10:30 +00:00
|
|
|
maxHeight={200}
|
2020-11-02 20:15:09 +00:00
|
|
|
toggleId="kc-signature-algorithm"
|
|
|
|
onToggle={() => isOpen(!open)}
|
|
|
|
onSelect={(_, value) => {
|
|
|
|
onChange(value as string);
|
|
|
|
isOpen(false);
|
|
|
|
}}
|
|
|
|
selections={value}
|
|
|
|
variant={SelectVariant.single}
|
|
|
|
aria-label={t("signatureAlgorithm")}
|
|
|
|
isOpen={open}
|
|
|
|
>
|
|
|
|
{providers.map((option) => (
|
|
|
|
<SelectOption
|
|
|
|
selected={option === value}
|
|
|
|
key={option}
|
|
|
|
value={option}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</Select>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|