Add support for manual edit of KES configuration file (#2354)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
This commit is contained in:
@@ -51,6 +51,9 @@ import GCPKMSAdd from "./Encryption/GCPKMSAdd";
|
||||
import GemaltoKMSAdd from "./Encryption/GemaltoKMSAdd";
|
||||
import AWSKMSAdd from "./Encryption/AWSKMSAdd";
|
||||
import SelectWrapper from "../../../Common/FormComponents/SelectWrapper/SelectWrapper";
|
||||
import Tabs from "@mui/material/Tabs";
|
||||
import Tab from "@mui/material/Tab";
|
||||
import CodeMirrorWrapper from "../../../Common/FormComponents/CodeMirrorWrapper/CodeMirrorWrapper";
|
||||
|
||||
interface IEncryptionProps {
|
||||
classes: any;
|
||||
@@ -88,6 +91,12 @@ const Encryption = ({ classes }: IEncryptionProps) => {
|
||||
const replicas = useSelector(
|
||||
(state: AppState) => state.createTenant.fields.encryption.replicas
|
||||
);
|
||||
const rawConfiguration = useSelector(
|
||||
(state: AppState) => state.createTenant.fields.encryption.rawConfiguration
|
||||
);
|
||||
const encryptionTab = useSelector(
|
||||
(state: AppState) => state.createTenant.fields.encryption.encryptionTab
|
||||
);
|
||||
const enableEncryption = useSelector(
|
||||
(state: AppState) => state.createTenant.fields.encryption.enableEncryption
|
||||
);
|
||||
@@ -175,6 +184,11 @@ const Encryption = ({ classes }: IEncryptionProps) => {
|
||||
if (enableEncryption) {
|
||||
encryptionValidation = [
|
||||
...encryptionValidation,
|
||||
{
|
||||
fieldKey: "rawConfiguration",
|
||||
required: encryptionTab > 0,
|
||||
value: rawConfiguration,
|
||||
},
|
||||
{
|
||||
fieldKey: "replicas",
|
||||
required: true,
|
||||
@@ -239,7 +253,6 @@ const Encryption = ({ classes }: IEncryptionProps) => {
|
||||
}
|
||||
|
||||
const commonVal = commonFormValidation(encryptionValidation);
|
||||
|
||||
dispatch(
|
||||
isPageValid({
|
||||
pageName: "encryption",
|
||||
@@ -249,6 +262,8 @@ const Encryption = ({ classes }: IEncryptionProps) => {
|
||||
|
||||
setValidationErrors(commonVal);
|
||||
}, [
|
||||
rawConfiguration,
|
||||
encryptionTab,
|
||||
enableEncryption,
|
||||
encryptionType,
|
||||
gcpProjectID,
|
||||
@@ -309,29 +324,64 @@ const Encryption = ({ classes }: IEncryptionProps) => {
|
||||
|
||||
{enableEncryption && (
|
||||
<Fragment>
|
||||
<Grid item xs={12} className={classes.encryptionTypeOptions}>
|
||||
<RadioGroupSelector
|
||||
currentSelection={encryptionType}
|
||||
id="encryptionType"
|
||||
name="encryptionType"
|
||||
label="Encryption Options"
|
||||
onChange={(e) => {
|
||||
updateField("encryptionType", e.target.value);
|
||||
<Grid item xs={12}>
|
||||
<Tabs
|
||||
value={encryptionTab}
|
||||
onChange={(e: React.ChangeEvent<{}>, value: number) => {
|
||||
updateField("encryptionTab", value);
|
||||
}}
|
||||
selectorOptions={[
|
||||
{ label: "Vault", value: "vault" },
|
||||
{ label: "AWS", value: "aws" },
|
||||
{ label: "Gemalto", value: "gemalto" },
|
||||
{ label: "GCP", value: "gcp" },
|
||||
{ label: "Azure", value: "azure" },
|
||||
]}
|
||||
/>
|
||||
indicatorColor="primary"
|
||||
textColor="primary"
|
||||
aria-label="cluster-tabs"
|
||||
variant="scrollable"
|
||||
scrollButtons="auto"
|
||||
>
|
||||
<Tab id="kms-options" label="Options" />
|
||||
<Tab id="kms-raw-configuration" label="Raw Edit" />
|
||||
</Tabs>
|
||||
</Grid>
|
||||
{encryptionType === "vault" && <VaultKMSAdd />}
|
||||
{encryptionType === "azure" && <AzureKMSAdd />}
|
||||
{encryptionType === "gcp" && <GCPKMSAdd />}
|
||||
{encryptionType === "aws" && <AWSKMSAdd />}
|
||||
{encryptionType === "gemalto" && <GemaltoKMSAdd />}
|
||||
|
||||
{encryptionTab ? (
|
||||
<Fragment>
|
||||
<Grid item xs={12}>
|
||||
<CodeMirrorWrapper
|
||||
value={rawConfiguration}
|
||||
mode={"yaml"}
|
||||
onBeforeChange={(editor, data, value) => {
|
||||
updateField("rawConfiguration", value);
|
||||
}}
|
||||
editorHeight={"550px"}
|
||||
/>
|
||||
</Grid>
|
||||
</Fragment>
|
||||
) : (
|
||||
<Fragment>
|
||||
<Grid item xs={12} className={classes.encryptionTypeOptions}>
|
||||
<RadioGroupSelector
|
||||
currentSelection={encryptionType}
|
||||
id="encryptionType"
|
||||
name="encryptionType"
|
||||
label="KMS"
|
||||
onChange={(e) => {
|
||||
updateField("encryptionType", e.target.value);
|
||||
}}
|
||||
selectorOptions={[
|
||||
{ label: "Vault", value: "vault" },
|
||||
{ label: "AWS", value: "aws" },
|
||||
{ label: "Gemalto", value: "gemalto" },
|
||||
{ label: "GCP", value: "gcp" },
|
||||
{ label: "Azure", value: "azure" },
|
||||
]}
|
||||
/>
|
||||
</Grid>
|
||||
{encryptionType === "vault" && <VaultKMSAdd />}
|
||||
{encryptionType === "azure" && <AzureKMSAdd />}
|
||||
{encryptionType === "gcp" && <GCPKMSAdd />}
|
||||
{encryptionType === "aws" && <AWSKMSAdd />}
|
||||
{encryptionType === "gemalto" && <GemaltoKMSAdd />}
|
||||
</Fragment>
|
||||
)}
|
||||
|
||||
<div className={classes.headerElement}>
|
||||
<h4 className={classes.h3Section}>Additional Configurations</h4>
|
||||
</div>
|
||||
|
||||
@@ -48,6 +48,9 @@ const AWSKMSAdd = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const classes = useStyles();
|
||||
|
||||
const encryptionTab = useSelector(
|
||||
(state: AppState) => state.createTenant.fields.encryption.encryptionTab
|
||||
);
|
||||
const awsEndpoint = useSelector(
|
||||
(state: AppState) => state.createTenant.fields.encryption.awsEndpoint
|
||||
);
|
||||
@@ -72,29 +75,31 @@ const AWSKMSAdd = () => {
|
||||
useEffect(() => {
|
||||
let encryptionValidation: IValidation[] = [];
|
||||
|
||||
encryptionValidation = [
|
||||
...encryptionValidation,
|
||||
{
|
||||
fieldKey: "aws_endpoint",
|
||||
required: true,
|
||||
value: awsEndpoint,
|
||||
},
|
||||
{
|
||||
fieldKey: "aws_region",
|
||||
required: true,
|
||||
value: awsRegion,
|
||||
},
|
||||
{
|
||||
fieldKey: "aws_accessKey",
|
||||
required: true,
|
||||
value: awsAccessKey,
|
||||
},
|
||||
{
|
||||
fieldKey: "aws_secretKey",
|
||||
required: true,
|
||||
value: awsSecretKey,
|
||||
},
|
||||
];
|
||||
if (!encryptionTab) {
|
||||
encryptionValidation = [
|
||||
...encryptionValidation,
|
||||
{
|
||||
fieldKey: "aws_endpoint",
|
||||
required: true,
|
||||
value: awsEndpoint,
|
||||
},
|
||||
{
|
||||
fieldKey: "aws_region",
|
||||
required: true,
|
||||
value: awsRegion,
|
||||
},
|
||||
{
|
||||
fieldKey: "aws_accessKey",
|
||||
required: true,
|
||||
value: awsAccessKey,
|
||||
},
|
||||
{
|
||||
fieldKey: "aws_secretKey",
|
||||
required: true,
|
||||
value: awsSecretKey,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const commonVal = commonFormValidation(encryptionValidation);
|
||||
|
||||
@@ -106,7 +111,14 @@ const AWSKMSAdd = () => {
|
||||
);
|
||||
|
||||
setValidationErrors(commonVal);
|
||||
}, [awsEndpoint, awsRegion, awsSecretKey, awsAccessKey, dispatch]);
|
||||
}, [
|
||||
encryptionTab,
|
||||
awsEndpoint,
|
||||
awsRegion,
|
||||
awsSecretKey,
|
||||
awsAccessKey,
|
||||
dispatch,
|
||||
]);
|
||||
|
||||
// Common
|
||||
const updateField = useCallback(
|
||||
|
||||
@@ -48,6 +48,9 @@ const AzureKMSAdd = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const classes = useStyles();
|
||||
|
||||
const encryptionTab = useSelector(
|
||||
(state: AppState) => state.createTenant.fields.encryption.encryptionTab
|
||||
);
|
||||
const azureEndpoint = useSelector(
|
||||
(state: AppState) => state.createTenant.fields.encryption.azureEndpoint
|
||||
);
|
||||
@@ -67,29 +70,31 @@ const AzureKMSAdd = () => {
|
||||
useEffect(() => {
|
||||
let encryptionValidation: IValidation[] = [];
|
||||
|
||||
encryptionValidation = [
|
||||
...encryptionValidation,
|
||||
{
|
||||
fieldKey: "azure_endpoint",
|
||||
required: true,
|
||||
value: azureEndpoint,
|
||||
},
|
||||
{
|
||||
fieldKey: "azure_tenant_id",
|
||||
required: true,
|
||||
value: azureTenantID,
|
||||
},
|
||||
{
|
||||
fieldKey: "azure_client_id",
|
||||
required: true,
|
||||
value: azureClientID,
|
||||
},
|
||||
{
|
||||
fieldKey: "azure_client_secret",
|
||||
required: true,
|
||||
value: azureClientSecret,
|
||||
},
|
||||
];
|
||||
if (!encryptionTab) {
|
||||
encryptionValidation = [
|
||||
...encryptionValidation,
|
||||
{
|
||||
fieldKey: "azure_endpoint",
|
||||
required: true,
|
||||
value: azureEndpoint,
|
||||
},
|
||||
{
|
||||
fieldKey: "azure_tenant_id",
|
||||
required: true,
|
||||
value: azureTenantID,
|
||||
},
|
||||
{
|
||||
fieldKey: "azure_client_id",
|
||||
required: true,
|
||||
value: azureClientID,
|
||||
},
|
||||
{
|
||||
fieldKey: "azure_client_secret",
|
||||
required: true,
|
||||
value: azureClientSecret,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const commonVal = commonFormValidation(encryptionValidation);
|
||||
|
||||
@@ -102,6 +107,7 @@ const AzureKMSAdd = () => {
|
||||
|
||||
setValidationErrors(commonVal);
|
||||
}, [
|
||||
encryptionTab,
|
||||
azureEndpoint,
|
||||
azureTenantID,
|
||||
azureClientID,
|
||||
|
||||
@@ -53,6 +53,9 @@ const GemaltoKMSAdd = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const classes = useStyles();
|
||||
|
||||
const encryptionTab = useSelector(
|
||||
(state: AppState) => state.createTenant.fields.encryption.encryptionTab
|
||||
);
|
||||
const gemaltoCA = useSelector(
|
||||
(state: AppState) => state.createTenant.certificates.gemaltoCA
|
||||
);
|
||||
@@ -75,31 +78,33 @@ const GemaltoKMSAdd = () => {
|
||||
useEffect(() => {
|
||||
let encryptionValidation: IValidation[] = [];
|
||||
|
||||
encryptionValidation = [
|
||||
...encryptionValidation,
|
||||
{
|
||||
fieldKey: "gemalto_endpoint",
|
||||
required: true,
|
||||
value: gemaltoEndpoint,
|
||||
},
|
||||
{
|
||||
fieldKey: "gemalto_token",
|
||||
required: true,
|
||||
value: gemaltoToken,
|
||||
},
|
||||
{
|
||||
fieldKey: "gemalto_domain",
|
||||
required: true,
|
||||
value: gemaltoDomain,
|
||||
},
|
||||
{
|
||||
fieldKey: "gemalto_retry",
|
||||
required: false,
|
||||
value: gemaltoRetry,
|
||||
customValidation: parseInt(gemaltoRetry) < 0,
|
||||
customValidationMessage: "Value needs to be 0 or greater",
|
||||
},
|
||||
];
|
||||
if (!encryptionTab) {
|
||||
encryptionValidation = [
|
||||
...encryptionValidation,
|
||||
{
|
||||
fieldKey: "gemalto_endpoint",
|
||||
required: true,
|
||||
value: gemaltoEndpoint,
|
||||
},
|
||||
{
|
||||
fieldKey: "gemalto_token",
|
||||
required: true,
|
||||
value: gemaltoToken,
|
||||
},
|
||||
{
|
||||
fieldKey: "gemalto_domain",
|
||||
required: true,
|
||||
value: gemaltoDomain,
|
||||
},
|
||||
{
|
||||
fieldKey: "gemalto_retry",
|
||||
required: false,
|
||||
value: gemaltoRetry,
|
||||
customValidation: parseInt(gemaltoRetry) < 0,
|
||||
customValidationMessage: "Value needs to be 0 or greater",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const commonVal = commonFormValidation(encryptionValidation);
|
||||
|
||||
@@ -111,7 +116,14 @@ const GemaltoKMSAdd = () => {
|
||||
);
|
||||
|
||||
setValidationErrors(commonVal);
|
||||
}, [gemaltoEndpoint, gemaltoToken, gemaltoDomain, gemaltoRetry, dispatch]);
|
||||
}, [
|
||||
encryptionTab,
|
||||
gemaltoEndpoint,
|
||||
gemaltoToken,
|
||||
gemaltoDomain,
|
||||
gemaltoRetry,
|
||||
dispatch,
|
||||
]);
|
||||
|
||||
// Common
|
||||
const updateField = useCallback(
|
||||
|
||||
@@ -55,6 +55,9 @@ const VaultKMSAdd = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const classes = useStyles();
|
||||
|
||||
const encryptionTab = useSelector(
|
||||
(state: AppState) => state.createTenant.fields.encryption.encryptionTab
|
||||
);
|
||||
const vaultEndpoint = useSelector(
|
||||
(state: AppState) => state.createTenant.fields.encryption.vaultEndpoint
|
||||
);
|
||||
@@ -95,38 +98,40 @@ const VaultKMSAdd = () => {
|
||||
useEffect(() => {
|
||||
let encryptionValidation: IValidation[] = [];
|
||||
|
||||
encryptionValidation = [
|
||||
...encryptionValidation,
|
||||
{
|
||||
fieldKey: "vault_endpoint",
|
||||
required: true,
|
||||
value: vaultEndpoint,
|
||||
},
|
||||
{
|
||||
fieldKey: "vault_id",
|
||||
required: true,
|
||||
value: vaultId,
|
||||
},
|
||||
{
|
||||
fieldKey: "vault_secret",
|
||||
required: true,
|
||||
value: vaultSecret,
|
||||
},
|
||||
{
|
||||
fieldKey: "vault_ping",
|
||||
required: false,
|
||||
value: vaultPing,
|
||||
customValidation: parseInt(vaultPing) < 0,
|
||||
customValidationMessage: "Value needs to be 0 or greater",
|
||||
},
|
||||
{
|
||||
fieldKey: "vault_retry",
|
||||
required: false,
|
||||
value: vaultRetry,
|
||||
customValidation: parseInt(vaultRetry) < 0,
|
||||
customValidationMessage: "Value needs to be 0 or greater",
|
||||
},
|
||||
];
|
||||
if (!encryptionTab) {
|
||||
encryptionValidation = [
|
||||
...encryptionValidation,
|
||||
{
|
||||
fieldKey: "vault_endpoint",
|
||||
required: true,
|
||||
value: vaultEndpoint,
|
||||
},
|
||||
{
|
||||
fieldKey: "vault_id",
|
||||
required: true,
|
||||
value: vaultId,
|
||||
},
|
||||
{
|
||||
fieldKey: "vault_secret",
|
||||
required: true,
|
||||
value: vaultSecret,
|
||||
},
|
||||
{
|
||||
fieldKey: "vault_ping",
|
||||
required: false,
|
||||
value: vaultPing,
|
||||
customValidation: parseInt(vaultPing) < 0,
|
||||
customValidationMessage: "Value needs to be 0 or greater",
|
||||
},
|
||||
{
|
||||
fieldKey: "vault_retry",
|
||||
required: false,
|
||||
value: vaultRetry,
|
||||
customValidation: parseInt(vaultRetry) < 0,
|
||||
customValidationMessage: "Value needs to be 0 or greater",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const commonVal = commonFormValidation(encryptionValidation);
|
||||
|
||||
@@ -139,6 +144,7 @@ const VaultKMSAdd = () => {
|
||||
|
||||
setValidationErrors(commonVal);
|
||||
}, [
|
||||
encryptionTab,
|
||||
vaultEndpoint,
|
||||
vaultEngine,
|
||||
vaultId,
|
||||
|
||||
@@ -180,6 +180,8 @@ const initialState: ICreateTenant = {
|
||||
enableTLS: true,
|
||||
},
|
||||
encryption: {
|
||||
rawConfiguration: "",
|
||||
encryptionTab: 0,
|
||||
enableEncryption: false,
|
||||
encryptionType: "vault",
|
||||
gemaltoEndpoint: "",
|
||||
|
||||
@@ -70,6 +70,8 @@ export const createTenantAsync = createAsyncThunk(
|
||||
const vaultCertificate = certificates.vaultCertificate;
|
||||
const vaultCA = certificates.vaultCA;
|
||||
const gemaltoCA = certificates.gemaltoCA;
|
||||
const rawConfiguration = fields.encryption.rawConfiguration;
|
||||
const encryptionTab = fields.encryption.encryptionTab;
|
||||
const enableEncryption = fields.encryption.enableEncryption;
|
||||
const encryptionType = fields.encryption.encryptionType;
|
||||
const gemaltoEndpoint = fields.encryption.gemaltoEndpoint;
|
||||
@@ -490,6 +492,7 @@ export const createTenantAsync = createAsyncThunk(
|
||||
dataSend = {
|
||||
...dataSend,
|
||||
encryption: {
|
||||
raw: encryptionTab ? rawConfiguration : "",
|
||||
replicas: kesReplicas,
|
||||
securityContext: kesSecurityContext,
|
||||
image: kesImage,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -96,6 +96,7 @@ export interface IGemaltoConfiguration {
|
||||
}
|
||||
|
||||
export interface ITenantEncryptionResponse {
|
||||
raw: string;
|
||||
image: string;
|
||||
replicas: string;
|
||||
securityContext: ISecurityContext;
|
||||
@@ -219,6 +220,8 @@ export interface ISecurityFields {
|
||||
}
|
||||
|
||||
export interface IEncryptionFields {
|
||||
rawConfiguration: string;
|
||||
encryptionTab: number;
|
||||
enableEncryption: boolean;
|
||||
encryptionType: string;
|
||||
gemaltoEndpoint: string;
|
||||
|
||||
Reference in New Issue
Block a user