Removed admin key generation from security
This commit is contained in:
@@ -29,10 +29,6 @@ export const Security = (): JSX.Element => {
|
|||||||
const [adminKey, setAdminKey] = useState<string>(
|
const [adminKey, setAdminKey] = useState<string>(
|
||||||
fromByteArray(config.security?.adminKey ?? new Uint8Array(0)),
|
fromByteArray(config.security?.adminKey ?? new Uint8Array(0)),
|
||||||
);
|
);
|
||||||
const [adminKeyVisible, setAdminKeyVisible] = useState<boolean>(false);
|
|
||||||
const [adminKeyBitCount, setAdminKeyBitCount] = useState<number>(
|
|
||||||
config.security?.adminKey.length ?? 16,
|
|
||||||
);
|
|
||||||
const [adminKeyValidationText, setAdminKeyValidationText] =
|
const [adminKeyValidationText, setAdminKeyValidationText] =
|
||||||
useState<string>();
|
useState<string>();
|
||||||
|
|
||||||
@@ -54,32 +50,7 @@ export const Security = (): JSX.Element => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const privateKeyClickEvent = () => {
|
const validateKey = (
|
||||||
const privateKey = getX25519PrivateKey();
|
|
||||||
const publicKey = getX25519PublicKey(privateKey);
|
|
||||||
|
|
||||||
setPrivateKey(fromByteArray(privateKey));
|
|
||||||
setPublicKey(fromByteArray(publicKey));
|
|
||||||
validatePass(
|
|
||||||
fromByteArray(privateKey),
|
|
||||||
privateKeyBitCount,
|
|
||||||
setPrivateKeyValidationText,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const adminKeyClickEvent = () => {
|
|
||||||
setAdminKey(
|
|
||||||
btoa(
|
|
||||||
cryptoRandomString({
|
|
||||||
length: adminKeyBitCount ?? 0,
|
|
||||||
type: "alphanumeric",
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
setAdminKeyValidationText(undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
const validatePass = (
|
|
||||||
input: string,
|
input: string,
|
||||||
count: number,
|
count: number,
|
||||||
setValidationText: (
|
setValidationText: (
|
||||||
@@ -98,12 +69,25 @@ export const Security = (): JSX.Element => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const privateKeyClickEvent = () => {
|
||||||
|
const privateKey = getX25519PrivateKey();
|
||||||
|
const publicKey = getX25519PublicKey(privateKey);
|
||||||
|
|
||||||
|
setPrivateKey(fromByteArray(privateKey));
|
||||||
|
setPublicKey(fromByteArray(publicKey));
|
||||||
|
validateKey(
|
||||||
|
fromByteArray(privateKey),
|
||||||
|
privateKeyBitCount,
|
||||||
|
setPrivateKeyValidationText,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const privateKeyInputChangeEvent = (
|
const privateKeyInputChangeEvent = (
|
||||||
e: React.ChangeEvent<HTMLInputElement>,
|
e: React.ChangeEvent<HTMLInputElement>,
|
||||||
) => {
|
) => {
|
||||||
const privateKeyB64String = e.currentTarget?.value;
|
const privateKeyB64String = e.currentTarget?.value;
|
||||||
setPrivateKey(privateKeyB64String);
|
setPrivateKey(privateKeyB64String);
|
||||||
validatePass(
|
validateKey(
|
||||||
privateKeyB64String,
|
privateKeyB64String,
|
||||||
privateKeyBitCount,
|
privateKeyBitCount,
|
||||||
setPrivateKeyValidationText,
|
setPrivateKeyValidationText,
|
||||||
@@ -116,19 +100,13 @@ export const Security = (): JSX.Element => {
|
|||||||
const adminKeyInputChangeEvent = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const adminKeyInputChangeEvent = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const psk = e.currentTarget?.value;
|
const psk = e.currentTarget?.value;
|
||||||
setAdminKey(psk);
|
setAdminKey(psk);
|
||||||
validatePass(psk, privateKeyBitCount, setAdminKeyValidationText);
|
validateKey(psk, privateKeyBitCount, setAdminKeyValidationText);
|
||||||
};
|
};
|
||||||
|
|
||||||
const privateKeySelectChangeEvent = (e: string) => {
|
const privateKeySelectChangeEvent = (e: string) => {
|
||||||
const count = Number.parseInt(e);
|
const count = Number.parseInt(e);
|
||||||
setPrivateKeyBitCount(count);
|
setPrivateKeyBitCount(count);
|
||||||
validatePass(privateKey, count, setPrivateKeyValidationText);
|
validateKey(privateKey, count, setPrivateKeyValidationText);
|
||||||
};
|
|
||||||
|
|
||||||
const adminKeySelectChangeEvent = (e: string) => {
|
|
||||||
const count = Number.parseInt(e);
|
|
||||||
setAdminKeyBitCount(count);
|
|
||||||
validatePass(privateKey, count, setAdminKeyValidationText);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -205,24 +183,16 @@ export const Security = (): JSX.Element => {
|
|||||||
'If true, device is considered to be "managed" by a mesh administrator via admin messages',
|
'If true, device is considered to be "managed" by a mesh administrator via admin messages',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "passwordGenerator",
|
type: "text",
|
||||||
name: "adminKey",
|
name: "adminKey",
|
||||||
label: "Admin Key",
|
label: "Admin Key",
|
||||||
description:
|
description:
|
||||||
"The public key authorized to send admin messages to this node",
|
"The public key authorized to send admin messages to this node",
|
||||||
validationText: adminKeyValidationText,
|
validationText: adminKeyValidationText,
|
||||||
devicePSKBitCount: adminKeyBitCount,
|
|
||||||
inputChange: adminKeyInputChangeEvent,
|
inputChange: adminKeyInputChangeEvent,
|
||||||
selectChange: adminKeySelectChangeEvent,
|
|
||||||
hide: !adminKeyVisible,
|
|
||||||
buttonClick: adminKeyClickEvent,
|
|
||||||
disabledBy: [{ fieldName: "adminChannelEnabled" }],
|
disabledBy: [{ fieldName: "adminChannelEnabled" }],
|
||||||
properties: {
|
properties: {
|
||||||
value: adminKey,
|
value: adminKey,
|
||||||
action: {
|
|
||||||
icon: adminKeyVisible ? EyeOff : Eye,
|
|
||||||
onClick: () => setAdminKeyVisible(!adminKeyVisible),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user