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" text: "placeholder"
} }
function load() { function load() {
clear() clear();
append({ "text": i18n("None"), "type": PlasmaNM.Enums.NoneSecurity }) append({ "text": i18n("None"), "type": PlasmaNM.Enums.NoneSecurity });
append({ "text": i18n("WEP Key"), "type": PlasmaNM.Enums.StaticWep }) append({ "text": i18n("WEP Key"), "type": PlasmaNM.Enums.StaticWep });
append({ "text": i18n("Dynamic WEP"), "type": PlasmaNM.Enums.DynamicWep }) append({ "text": i18n("Dynamic WEP"), "type": PlasmaNM.Enums.DynamicWep });
append({ "text": i18n("WPA/WPA2 Personal"), "type": PlasmaNM.Enums.Wpa2Psk }) append({ "text": i18n("WPA/WPA2 Personal"), "type": PlasmaNM.Enums.Wpa2Psk });
append({ "text": i18n("WPA/WPA2 Enterprise"), "type": PlasmaNM.Enums.Wpa2Eap }) 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"]) { switch (securitySettings["key-mgmt"]) {
case "none": case "none":
securityCombobox.currentIndex = 0 securityCombobox.currentIndex = 0;
break break;
case "ieee8021x": case "ieee8021x":
securityCombobox.currentIndex = 1 securityCombobox.currentIndex = 1;
break break;
case "wpa-psk": case "wpa-psk":
securityCombobox.currentIndex = 3 securityCombobox.currentIndex = 3;
break break;
case "wpa-eap": case "wpa-eap":
securityCombobox.currentIndex = 4 securityCombobox.currentIndex = 4;
break break;
case "sae":
securityCombobox.currentIndex = 5;
break;
case "wpa-eap-suite-b-192":
securityCombobox.currentIndex = 6;
break;
default: default:
securityCombobox.currentIndex = 0 securityCombobox.currentIndex = 0;
break break;
} }
} }
} }
@ -153,7 +163,7 @@ Kirigami.ScrollablePage {
} }
Controls.Label { 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----" text: "----Not yet implemented----"
color: "red" color: "red"
} }

View file

@ -163,6 +163,12 @@ void WifiSettings::addConnectionFromQML(const QVariantMap &QMLmap)
securitySettings->setWepKeyFlags(NetworkManager::Setting::SecretFlagType::AgentOwned); securitySettings->setWepKeyFlags(NetworkManager::Setting::SecretFlagType::AgentOwned);
securitySettings->setWepKey0(securMap["password"].toString()); 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()); 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()); 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 // TODO can't set password for AP
// needs further inspection // needs further inspection
if (wirelessSetting->mode() == NetworkManager::WirelessSetting::Ap) { if (wirelessSetting->mode() == NetworkManager::WirelessSetting::Ap) {