Коммит 36be23a3 создал по автору sgakerru's avatar sgakerru
Просмотр файлов

AuthService: WIP handle corp wifi

1. Со стороны сервиса - метод создания и подключения временного
соединения к `WPA2-EAP` сети без сохранения пароля через `nmcli`.

Метод принимает из SDDM-темы в
качестве аргументов `ssid`, `логин`, `пароль`.

Позже внутри будет считываться доменное имя из конфигов.

2. Со стороны интерфейса SDDM-темы -
обработка этого отдельного случая (WPA2-EAP):

1) Дополнительное поле для ввода логина.

2) Отдельная обработка подключения через `AuthService`,
а не `plasma-nm` `handler`.
владелец fb25e873
......@@ -685,6 +685,7 @@ PlasmaCore.ColorScope {
WirelessNetworkManager {
wirelessStatus: root.wirelessStatus
wirelessStatusMsg: root.wirelessStatusMsg
authService: mosAuthService
}
}
......
......@@ -15,15 +15,20 @@ import org.kde.plasma.networkmanagement 0.2 as PlasmaNM
import QtGraphicalEffects 1.15
import org.mos.auth 0.1 as MosAuthPlugin
FocusScope {
id: root
readonly property int defaultOffset: PlasmaCore.Units.gridUnit * 10
readonly property int fontSize: PlasmaCore.Theme.defaultFont.pointSize + 2
readonly property int selectedConnectionSecurityType: getSelectedConnectionSecurityType()
readonly property bool predictableWirelessPassword: isConnectionHasPassword()
readonly property bool selectedConnectionActivated: isSelectedConnectionActivated()
readonly property bool selectedConnectionIsEnterprise: isSelectedConnectionHasEnterpriseSecurity()
readonly property bool selectedConnectionIsAllowedEap: isSelectedConnectionHasAllowedEap()
readonly property bool selectedConnectionSaved: isSelectedConnectionSaved()
readonly property bool waitingConnectionFinish: (wirelessStatus === PlasmaNM.Enums.Deactivating
|| wirelessStatus === PlasmaNM.Enums.Activating)
......@@ -36,12 +41,17 @@ FocusScope {
// From parent
required property int wirelessStatus
required property string wirelessStatusMsg
required property MosAuthPlugin.AuthService authService
function getDataByRole(role: PlasmaNM.NetworkModel, index = -1) {
index = (index === -1) ? wifiSelect.currentIndex : index;
return filteredModel.data(filteredModel.index(index, 0), role);
}
function getSelectedConnectionSecurityType(): int {
return getDataByRole(PlasmaNM.NetworkModel.SecurityTypeRole);
}
function getProcessedWifiName(): string {
const noname = "...";
......@@ -66,10 +76,11 @@ FocusScope {
if (devicePath === undefined) {
return false;
}
const securityType = getDataByRole(PlasmaNM.NetworkModel.SecurityTypeRole);
const securityType = selectedConnectionSecurityType;
const passwordIsStatic = (securityType === PlasmaNM.Enums.StaticWep
|| securityType === PlasmaNM.Enums.WpaPsk
|| securityType === PlasmaNM.Enums.Wpa2Psk
|| securityType === PlasmaNM.Enums.Wpa2Eap
|| securityType === PlasmaNM.Enums.SAE);
const uuid = getDataByRole(PlasmaNM.NetworkModel.UuidRole) ?? "";
return !uuid && passwordIsStatic;
......@@ -81,7 +92,7 @@ FocusScope {
}
function isSelectedConnectionHasEnterpriseSecurity(): bool {
const securityType = getDataByRole(PlasmaNM.NetworkModel.SecurityTypeRole);
const securityType = selectedConnectionSecurityType;
const enterpriseSecurity = (securityType === PlasmaNM.Enums.DynamicWep
|| securityType === PlasmaNM.Enums.Leap
|| securityType === PlasmaNM.Enums.WpaEap
......@@ -90,6 +101,11 @@ FocusScope {
return enterpriseSecurity;
}
function isSelectedConnectionHasAllowedEap(): bool {
return (selectedConnectionSecurityType === PlasmaNM.Enums.Wpa2Eap
&& true);
}
function isSelectedConnectionSaved(): bool {
const uuid = getDataByRole(PlasmaNM.NetworkModel.UuidRole) ?? "";
return uuid;
......@@ -107,7 +123,11 @@ FocusScope {
const uuid = getDataByRole(PlasmaNM.NetworkModel.UuidRole) ?? "";
const password = wifiPasswordInput.text.trim();
if (connectionState === PlasmaNM.Enums.Deactivated) {
if (selectedConnectionIsAllowedEap) {
const login = eapLoginInput.text.trim();
const ssid = getDataByRole(PlasmaNM.NetworkModel.SsidRole);
authService.handleEapWifi(ssid, login, password);
} else if (connectionState === PlasmaNM.Enums.Deactivated) {
if (!predictableWirelessPassword && !uuid) {
// Новое соединение без пароля
handler.addAndActivateConnection(devicePath, specificPath);
......@@ -143,6 +163,10 @@ FocusScope {
value: Math.min(root.height / 3, wifiSelect.popup.contentItem.contentHeight)
}
MosAuthPlugin.AuthService {
id: authService
}
PlasmaNM.Handler {
id: handler
}
......@@ -284,7 +308,7 @@ FocusScope {
}
PlasmaComponents3.Label {
id: connectionNotification
id: enterpriseConnectionNotification
Layout.bottomMargin: PlasmaCore.Units.gridUnit
Layout.fillWidth: true
......@@ -292,7 +316,7 @@ FocusScope {
font.pointSize: root.fontSize
horizontalAlignment: Text.AlignHCenter
text: "До входа в систему нельзя подключаться к корпоративной сети.\n\nПопробуйте другое соединение."
visible: root.selectedConnectionIsEnterprise
visible: root.selectedConnectionIsEnterprise && !root.selectedConnectionIsAllowedEap
wrapMode: Text.Wrap
}
......@@ -346,17 +370,29 @@ FocusScope {
}
}
PlasmaComponents3.TextField {
id: eapLoginInput
Layout.fillWidth: true
visible: root.selectedConnectionIsAllowedEap
font.pointSize: fontSize + 1
placeholderText: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Username")
onAccepted: wifiPasswordInput.forceActiveFocus()
}
RowLayout {
PlasmaExtras.PasswordField {
id: wifiPasswordInput
Layout.fillWidth: true
enabled: root.predictableWirelessPassword
&& !root.selectedConnectionIsEnterprise
&& (!root.selectedConnectionIsEnterprise
|| root.selectedConnectionIsAllowedEap)
&& !root.waitingConnectionFinish
focus: true
font.pointSize: root.fontSize + 1
placeholderText: "Введите пароль"
placeholderText: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Password")
onAccepted: root.handleWifiConnection()
}
......@@ -380,7 +416,8 @@ FocusScope {
Layout.fillWidth: true
Layout.preferredHeight: wifiPasswordInput.implicitHeight
enabled: !root.selectedConnectionIsEnterprise
enabled: (!root.selectedConnectionIsEnterprise
|| root.selectedConnectionIsAllowedEap)
&& root.wirelessStatus !== PlasmaNM.Enums.Deactivating
text: {
......
......@@ -184,6 +184,26 @@ void AuthService::prepareGuest()
prepareGuestProcess->start("/bin/sh", QStringList() << "-c" << cmd);
}
void AuthService::handleEapWifi(const QString &ssid, const QString &login, const QString &pass)
{
const QString connectionName = "temp-corp-сonnection";
QProcess *createWifi = new QProcess(this);
const QString deleteIfExist = QString("nmcli connection delete %1").arg(connectionName);
const QString checkExist = QString("nmcli connection show %1").arg(connectionName);
const QString create = QString("nmcli connection add save no type wifi con-name %1 "
"autoconnect no connection.permissions sddm "
"wifi-sec.key-mgmt wpa-eap 802-1x.password-flags 2 "
"802-1x.eap peap 802-1x.phase2-auth mschapv2 "
"802-1x.identity \"%2\" 802-1x.domain-suffix-match %3 ssid %4")
.arg(connectionName).arg(login).arg("hq.corp.mos.ru").arg(ssid);
const QString connectTo = QString("echo %1 | nmcli connection up %2 --ask").arg(pass).arg(connectionName);
const QString cmd = deleteIfExist + " ; " + checkExist + " || (" + create + " && " + connectTo + ")";
createWifi->start("/bin/sh", QStringList() << "-c" << cmd);
}
bool AuthService::guestEnabled() const
{
return config->guestEnabled();
......
......@@ -39,6 +39,10 @@ public:
Q_INVOKABLE void prepareGuest();
Q_INVOKABLE void handleEapWifi(const QString &ssid, //
const QString &login,
const QString &pass);
Q_SIGNALS:
void registerUserFinished(bool result);
void prepareGuestFinished(bool result);
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать