[WIFI-11713] Enabled radius for SSIDs with no encryption

Signed-off-by: Charles <charles.bourque96@gmail.com>
This commit is contained in:
Charles
2022-11-24 13:46:19 +00:00
parent b316531edf
commit 0387befc9f
7 changed files with 148 additions and 118 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "wlan-cloud-owprov-ui", "name": "wlan-cloud-owprov-ui",
"version": "2.8.0(18)", "version": "2.8.0(19)",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "wlan-cloud-owprov-ui", "name": "wlan-cloud-owprov-ui",
"version": "2.8.0(18)", "version": "2.8.0(19)",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@chakra-ui/icons": "^2.0.11", "@chakra-ui/icons": "^2.0.11",

View File

@@ -1,6 +1,6 @@
{ {
"name": "wlan-cloud-owprov-ui", "name": "wlan-cloud-owprov-ui",
"version": "2.8.0(18)", "version": "2.8.0(19)",
"description": "", "description": "",
"main": "index.tsx", "main": "index.tsx",
"scripts": { "scripts": {

View File

@@ -15,6 +15,7 @@ interface Props {
isKeyNeeded: boolean; isKeyNeeded: boolean;
isUsingRadius: boolean; isUsingRadius: boolean;
isPasspoint?: boolean; isPasspoint?: boolean;
canUseRadius: boolean;
} }
const EncryptionForm = ({ const EncryptionForm = ({
@@ -26,6 +27,7 @@ const EncryptionForm = ({
isKeyNeeded, isKeyNeeded,
isUsingRadius, isUsingRadius,
isPasspoint, isPasspoint,
canUseRadius,
}: Props) => ( }: Props) => (
<> <>
<Flex mt={4}> <Flex mt={4}>
@@ -77,7 +79,9 @@ const EncryptionForm = ({
defaultValue defaultValue
/> />
</SimpleGrid> </SimpleGrid>
{isUsingRadius && <Radius editing={editing} namePrefix={radiusPrefix} isPasspoint={isPasspoint} />} {(isUsingRadius || canUseRadius) && (
<Radius editing={editing} namePrefix={radiusPrefix} isPasspoint={isPasspoint} isNotRequired={canUseRadius} />
)}
</> </>
); );

View File

@@ -19,6 +19,9 @@ type Props = {
variableBlock?: string; variableBlock?: string;
// eslint-disable-next-line react/no-unused-prop-types // eslint-disable-next-line react/no-unused-prop-types
isPasspoint?: boolean; isPasspoint?: boolean;
isEnabled: boolean;
onEnableToggle: () => void;
isNotRequired: boolean;
}; };
const RadiusForm = ({ const RadiusForm = ({
editing, editing,
@@ -29,6 +32,9 @@ const RadiusForm = ({
onDynamicChange, onDynamicChange,
isDynamicEnabled, isDynamicEnabled,
variableBlock, variableBlock,
isEnabled,
onEnableToggle,
isNotRequired,
}: Props) => ( }: Props) => (
<> <>
<Flex mt={6}> <Flex mt={6}>
@@ -37,14 +43,18 @@ const RadiusForm = ({
Radius Radius
</Heading> </Heading>
</div> </div>
{isNotRequired && <Switch isChecked={isEnabled} onChange={onEnableToggle} size="lg" mt={2} mr={2} />}
{isEnabled && (
<ConfigurationResourcePicker <ConfigurationResourcePicker
name={namePrefix} name={namePrefix}
prefix="interface.ssid.radius" prefix="interface.ssid.radius"
isDisabled={!editing} isDisabled={!editing}
defaultValue={INTERFACE_SSID_RADIUS_SCHEMA} defaultValue={INTERFACE_SSID_RADIUS_SCHEMA}
/> />
)}
</Flex> </Flex>
{isUsingCustom || !variableBlock ? ( {isEnabled &&
(isUsingCustom || !variableBlock ? (
<> <>
<SimpleGrid minChildWidth="300px" spacing="20px"> <SimpleGrid minChildWidth="300px" spacing="20px">
<StringField <StringField
@@ -167,7 +177,7 @@ const RadiusForm = ({
</> </>
) : ( ) : (
<LockedRadius variableBlockId={variableBlock} /> <LockedRadius variableBlockId={variableBlock} />
)} ))}
</> </>
); );

View File

@@ -1,11 +1,15 @@
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { INTERFACE_SSID_RADIUS_SCHEMA } from '../../../../interfacesConstants';
import RadiusForm from './Radius'; import RadiusForm from './Radius';
import useFastField from 'hooks/useFastField'; import useFastField from 'hooks/useFastField';
type Props = { editing: boolean; namePrefix: string; isPasspoint?: boolean }; type Props = { editing: boolean; namePrefix: string; isPasspoint?: boolean; isNotRequired: boolean };
const Radius = ({ editing, namePrefix, isPasspoint }: Props) => { const Radius = ({ editing, namePrefix, isPasspoint, isNotRequired }: Props) => {
const { t } = useTranslation();
const { value: customRadius } = useFastField({ name: `${namePrefix}.__variableBlock` }); const { value: customRadius } = useFastField({ name: `${namePrefix}.__variableBlock` });
const { value: radius, onChange: onRadiusChange } = useFastField({ name: `${namePrefix}` });
const { value: accounting, onChange: setAccounting } = useFastField({ name: `${namePrefix}.accounting` }); const { value: accounting, onChange: setAccounting } = useFastField({ name: `${namePrefix}.accounting` });
const { value: dynamicAuth, onChange: setDynamicAuth } = useFastField({ const { value: dynamicAuth, onChange: setDynamicAuth } = useFastField({
name: `${namePrefix}.dynamic-authorization`, name: `${namePrefix}.dynamic-authorization`,
@@ -27,6 +31,11 @@ const Radius = ({ editing, namePrefix, isPasspoint }: Props) => {
const isAccountingEnabled = useMemo(() => accounting !== undefined, [accounting !== undefined]); const isAccountingEnabled = useMemo(() => accounting !== undefined, [accounting !== undefined]);
const isEnabled = React.useMemo(() => radius !== undefined, [radius !== undefined]);
const onEnableToggle = React.useCallback(() => {
if (isEnabled) onRadiusChange(undefined);
else onRadiusChange(INTERFACE_SSID_RADIUS_SCHEMA(t, true).cast());
}, [isEnabled]);
const onEnableDynamicChange = (e: React.ChangeEvent<HTMLInputElement>) => { const onEnableDynamicChange = (e: React.ChangeEvent<HTMLInputElement>) => {
if (e.target.checked) { if (e.target.checked) {
setDynamicAuth({ setDynamicAuth({
@@ -51,7 +60,10 @@ const Radius = ({ editing, namePrefix, isPasspoint }: Props) => {
isDynamicEnabled={isDynamicEnabled} isDynamicEnabled={isDynamicEnabled}
variableBlock={customRadius} variableBlock={customRadius}
namePrefix={namePrefix} namePrefix={namePrefix}
isEnabled={isEnabled}
onEnableToggle={onEnableToggle}
isPasspoint={isPasspoint} isPasspoint={isPasspoint}
isNotRequired={isNotRequired}
/> />
); );
}; };

View File

@@ -1,6 +1,7 @@
import React, { useCallback, useMemo } from 'react'; import React, { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { import {
ENCRYPTION_PROTOS_CAN_RADIUS,
ENCRYPTION_PROTOS_REQUIRE_IEEE, ENCRYPTION_PROTOS_REQUIRE_IEEE,
ENCRYPTION_PROTOS_REQUIRE_KEY, ENCRYPTION_PROTOS_REQUIRE_KEY,
ENCRYPTION_PROTOS_REQUIRE_RADIUS, ENCRYPTION_PROTOS_REQUIRE_RADIUS,
@@ -57,12 +58,13 @@ const Encryption = ({
[isPasspoint], [isPasspoint],
); );
const { isKeyNeeded, needIeee, isUsingRadius } = useMemo( const { isKeyNeeded, needIeee, isUsingRadius, canUseRadius } = useMemo(
() => ({ () => ({
isKeyNeeded: ENCRYPTION_PROTOS_REQUIRE_KEY.includes(encryptionValue?.proto ?? ''), isKeyNeeded: ENCRYPTION_PROTOS_REQUIRE_KEY.includes(encryptionValue?.proto ?? ''),
needIeee: ENCRYPTION_PROTOS_REQUIRE_IEEE.includes(encryptionValue?.proto ?? ''), needIeee: ENCRYPTION_PROTOS_REQUIRE_IEEE.includes(encryptionValue?.proto ?? ''),
isUsingRadius: isUsingRadius:
ENCRYPTION_PROTOS_REQUIRE_RADIUS.includes(encryptionValue?.proto ?? '') || radiusValue !== undefined, ENCRYPTION_PROTOS_REQUIRE_RADIUS.includes(encryptionValue?.proto ?? '') || radiusValue !== undefined,
canUseRadius: ENCRYPTION_PROTOS_CAN_RADIUS.includes(encryptionValue?.proto ?? ''),
}), }),
[encryptionValue?.proto, radiusValue !== undefined], [encryptionValue?.proto, radiusValue !== undefined],
); );
@@ -77,6 +79,7 @@ const Encryption = ({
isKeyNeeded={isKeyNeeded} isKeyNeeded={isKeyNeeded}
isUsingRadius={isUsingRadius} isUsingRadius={isUsingRadius}
isPasspoint={isPasspoint} isPasspoint={isPasspoint}
canUseRadius={canUseRadius}
/> />
); );
}; };

View File

@@ -41,6 +41,7 @@ export const ENCRYPTION_PROTOS_REQUIRE_IEEE = [
'owe', 'owe',
'owe-transition', 'owe-transition',
]; ];
export const ENCRYPTION_PROTOS_CAN_RADIUS = ['none'];
export const ENCRYPTION_PROTOS_REQUIRE_RADIUS = [ export const ENCRYPTION_PROTOS_REQUIRE_RADIUS = [
'psk2-radius', 'psk2-radius',
'wpa', 'wpa',