!17 单点登录迁移到后端

Merge pull request !17 from 刘远鹏/openkylin/nile
This commit is contained in:
杨敏 2024-04-23 02:22:36 +00:00 committed by Gitee
commit b79c9bc97a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 14 additions and 7 deletions

View File

@ -41,7 +41,7 @@
#include <openssl/pem.h>
#define UKUI_GREETER "/usr/sbin/ukui-greeter"
#define UKUI_SCREENSAVER "/usr/bin/ukui-screensaver-dialog"
#define UKUI_SCREENSAVER "/usr/bin/ukui-screensaver-backend"
#define GREETER_DBUS_PATH "/"
#define GREETER_DBUS_INTERFACE "org.ukui.greeter"
@ -916,13 +916,13 @@ bool ServiceInterface::sendPassword(QString username,QByteArray password)
rsac.decrypt(password, decryptText, priKey); // 解密
//如果处于登录状态
qDebug()<<"sendPassword"<<loginAppList.count();
qDebug()<<"sendPassword"<<loginAppList.count()<<loginAppList;
if(loginAppList.contains("lightdm")){
qDebug()<<"login:";
isFirstLogin = false;
QString publicKey = getLoginPubKey(loginAppList.value("lightdm"),GREETER_DBUS_PATH,GREETER_DBUS_INTERFACE);
QString publicKey = getLoginPubKey(loginAppList.value("lightdm"),SCREENSAVER_DBUS_PATH,SCREENSAVER_DBUS_INTERFACE);
rsac.encrypt(decryptText, encryptText, publicKey.toLatin1());
return sendLoginPassword(loginAppList.value("lightdm"),GREETER_DBUS_PATH,GREETER_DBUS_INTERFACE,username,encryptText);
return sendLoginPassword(loginAppList.value("lightdm"),SCREENSAVER_DBUS_PATH,SCREENSAVER_DBUS_INTERFACE,username,encryptText);
}
//处于锁屏状态
@ -934,6 +934,14 @@ bool ServiceInterface::sendPassword(QString username,QByteArray password)
return sendLoginPassword(loginAppList.value(username),SCREENSAVER_DBUS_PATH,SCREENSAVER_DBUS_INTERFACE,username,encryptText);
}
if(loginAppList.count()>0){
qDebug()<<"login by screensaver:";
isFirstLogin = false;
QString publicKey = getLoginPubKey(loginAppList.value(loginAppList.firstKey()),SCREENSAVER_DBUS_PATH,SCREENSAVER_DBUS_INTERFACE);
rsac.encrypt(decryptText, encryptText, publicKey.toLatin1());
return sendLoginPassword(loginAppList.value(loginAppList.firstKey()),SCREENSAVER_DBUS_PATH,SCREENSAVER_DBUS_INTERFACE,username,encryptText);
}
//如果是第一次调用,则配置自动登录
if(isFirstLogin){
qDebug()<<"isFirstLogin:";
@ -965,13 +973,13 @@ bool ServiceInterface::handleFirstSingleLogn(QString username,QByteArray decrypt
qDebug()<<loginAppList.count();
if(loginAppList.contains("lightdm")){
isFirstLogin = false;
QString publicKey = getLoginPubKey(loginAppList.value("lightdm"),GREETER_DBUS_PATH,GREETER_DBUS_INTERFACE);
QString publicKey = getLoginPubKey(loginAppList.value("lightdm"),SCREENSAVER_DBUS_PATH,SCREENSAVER_DBUS_INTERFACE);
if(publicKey.isEmpty()){
qDebug()<<"get Login PubKey failed!";
return false;
}
rsac.encrypt(decryptText, encryptText, publicKey.toLatin1());
return sendLoginPassword(loginAppList.value("lightdm"),GREETER_DBUS_PATH,GREETER_DBUS_INTERFACE,username,encryptText);
return sendLoginPassword(loginAppList.value("lightdm"),SCREENSAVER_DBUS_PATH,SCREENSAVER_DBUS_INTERFACE,username,encryptText);
}
return ret;
}
@ -1018,7 +1026,6 @@ bool ServiceInterface::sendLoginPassword(QString service,QString path,QString i
path,
interface,
QDBusConnection::systemBus());
QDBusReply<bool> stateReply = iface.call("sendPassword",username,array);
if(!stateReply.isValid()){
disconnect(connection);