kcms/wifi: Add WPA3 support

BUG: 483729
https://invent.kde.org/plasma/plasma-mobile/-/issues/336

This implements WPA3 support in the wifi KCM. However, the wifi KCM in general is missing implementations for many things (ex. WPA2/3 enterprise). We really should eventually pursue https://invent.kde.org/teams/plasma-mobile/issues/-/issues/294
This commit is contained in:
Devin Lin 2024-06-23 21:23:28 -04:00
parent ce89bfe491
commit a930eabbb2
2 changed files with 37 additions and 17 deletions

View file

@ -92,28 +92,38 @@ Kirigami.ScrollablePage {
text: "placeholder"
}
function load() {
clear()
append({ "text": i18n("None"), "type": PlasmaNM.Enums.NoneSecurity })
append({ "text": i18n("WEP Key"), "type": PlasmaNM.Enums.StaticWep })
append({ "text": i18n("Dynamic WEP"), "type": PlasmaNM.Enums.DynamicWep })
append({ "text": i18n("WPA/WPA2 Personal"), "type": PlasmaNM.Enums.Wpa2Psk })
append({ "text": i18n("WPA/WPA2 Enterprise"), "type": PlasmaNM.Enums.Wpa2Eap })
clear();
append({ "text": i18n("None"), "type": PlasmaNM.Enums.NoneSecurity });
append({ "text": i18n("WEP Key"), "type": PlasmaNM.Enums.StaticWep });
append({ "text": i18n("Dynamic WEP"), "type": PlasmaNM.Enums.DynamicWep });
append({ "text": i18n("WPA/WPA2 Personal"), "type": PlasmaNM.Enums.Wpa2Psk });
append({ "text": i18n("WPA/WPA2 Enterprise"), "type": PlasmaNM.Enums.Wpa2Eap });
append({ "text": i18n("WPA3 Personal"), "type": PlasmaNM.Enums.SAE });
append({ "text": i18n("WPA3 Enterprise"), "type": PlasmaNM.Enums.Wpa3SuiteB192 });
// See https://networkmanager.dev/docs/api/latest/settings-802-11-wireless-security.html
switch (securitySettings["key-mgmt"]) {
case "none":
securityCombobox.currentIndex = 0
break
securityCombobox.currentIndex = 0;
break;
case "ieee8021x":
securityCombobox.currentIndex = 1
break
securityCombobox.currentIndex = 1;
break;
case "wpa-psk":
securityCombobox.currentIndex = 3
break
securityCombobox.currentIndex = 3;
break;
case "wpa-eap":
securityCombobox.currentIndex = 4
break
securityCombobox.currentIndex = 4;
break;
case "sae":
securityCombobox.currentIndex = 5;
break;
case "wpa-eap-suite-b-192":
securityCombobox.currentIndex = 6;
break;
default:
securityCombobox.currentIndex = 0
break
securityCombobox.currentIndex = 0;
break;
}
}
}
@ -153,7 +163,7 @@ Kirigami.ScrollablePage {
}
Controls.Label {
visible: securityCombobox.currentIndex !== 3 && securityCombobox.currentIndex !== 0
visible: ![0, 3, 5].includes(securityCombobox.currentIndex) // only supports WPA PSK, SAE
text: "----Not yet implemented----"
color: "red"
}

View file

@ -163,6 +163,12 @@ void WifiSettings::addConnectionFromQML(const QVariantMap &QMLmap)
securitySettings->setWepKeyFlags(NetworkManager::Setting::SecretFlagType::AgentOwned);
securitySettings->setWepKey0(securMap["password"].toString());
}
if (type == NetworkManager::SAE) {
securitySettings->setKeyMgmt(NetworkManager::WirelessSecuritySetting::KeyMgmt::SAE);
securitySettings->setAuthAlg(NetworkManager::WirelessSecuritySetting::AuthAlg::Open);
securitySettings->setPskFlags(NetworkManager::Setting::SecretFlagType::AgentOwned);
securitySettings->setPsk(securMap["password"].toString());
}
map.insert("802-11-wireless-security", securitySettings->toMap());
}
}
@ -223,6 +229,10 @@ void WifiSettings::updateConnectionFromQML(const QString &path, const QVariantMa
securitySetting->setPsk(secMap["password"].toString());
}
if ((securitySetting->keyMgmt() == NetworkManager::WirelessSecuritySetting::SAE) && (secMap.value("type") == NetworkManager::SAE)) {
securitySetting->setPsk(secMap["password"].toString());
}
// TODO can't set password for AP
// needs further inspection
if (wirelessSetting->mode() == NetworkManager::WirelessSetting::Ap) {