fix(single login): single login
Description:单点登录迁移到后端 Log: 无
This commit is contained in:
parent
8554181481
commit
93207c3600
|
@ -645,9 +645,6 @@ int DbusUpperInterface::SetInformation(QString strJson)
|
||||||
case LOCK_CMD_ID_BIOAUTH_STOPAUTH:
|
case LOCK_CMD_ID_BIOAUTH_STOPAUTH:
|
||||||
nRet = BioStopAuth(rootObj);
|
nRet = BioStopAuth(rootObj);
|
||||||
break;
|
break;
|
||||||
case LOCK_CMD_ID_SEND_USER_PASSWORD:
|
|
||||||
nRet = sendPassword(rootObj);
|
|
||||||
break;
|
|
||||||
case LOCK_CMD_ID_KWIN_BLOCK_SHORTCUT:
|
case LOCK_CMD_ID_KWIN_BLOCK_SHORTCUT:
|
||||||
nRet = blockShortcut(rootObj);
|
nRet = blockShortcut(rootObj);
|
||||||
break;
|
break;
|
||||||
|
@ -2108,15 +2105,11 @@ QString DbusUpperInterface::getPublicEncrypt()
|
||||||
return QString(pubKey);
|
return QString(pubKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DbusUpperInterface::sendPassword(const QJsonObject &objInfo)
|
bool DbusUpperInterface::sendPassword(const QString username,QByteArray password)
|
||||||
{
|
{
|
||||||
if(priKey.isEmpty())
|
if(priKey.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QJsonObject obj = objInfo["Content"].toObject();
|
|
||||||
QString username = obj["username"].toString();
|
|
||||||
QByteArray password = obj["password"].toVariant().toByteArray();
|
|
||||||
|
|
||||||
QByteArray decryptText;
|
QByteArray decryptText;
|
||||||
rsac.decrypt(password, decryptText, priKey); // 解密
|
rsac.decrypt(password, decryptText, priKey); // 解密
|
||||||
|
|
||||||
|
@ -2124,7 +2117,15 @@ bool DbusUpperInterface::sendPassword(const QJsonObject &objInfo)
|
||||||
if(m_pamAuth && m_pamAuth->inAuthentication() && (m_pamAuth->authenticationUser() == username)){
|
if(m_pamAuth && m_pamAuth->inAuthentication() && (m_pamAuth->authenticationUser() == username)){
|
||||||
m_pamAuth->respond(QString(decryptText));
|
m_pamAuth->respond(QString(decryptText));
|
||||||
}
|
}
|
||||||
|
else if(m_pamAuth){
|
||||||
|
m_pamAuth->authenticate(username);
|
||||||
|
QTimer::singleShot(100, this, [=](){
|
||||||
|
m_pamAuth->respond(QString(decryptText));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DbusUpperInterface::BioFindDeviceByName(QJsonObject &reqObj, QJsonObject &retObj)
|
void DbusUpperInterface::BioFindDeviceByName(QJsonObject &reqObj, QJsonObject &retObj)
|
||||||
|
|
|
@ -126,6 +126,10 @@ public:
|
||||||
*/
|
*/
|
||||||
int SetInformation(QString strJson);
|
int SetInformation(QString strJson);
|
||||||
|
|
||||||
|
QString getPublicEncrypt();
|
||||||
|
|
||||||
|
bool sendPassword(const QString username,QByteArray password);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* @brief 服务退出
|
* @brief 服务退出
|
||||||
|
@ -347,10 +351,6 @@ private:
|
||||||
|
|
||||||
int BioStopAuth(const QJsonObject &objInfo);
|
int BioStopAuth(const QJsonObject &objInfo);
|
||||||
|
|
||||||
QString getPublicEncrypt();
|
|
||||||
|
|
||||||
bool sendPassword(const QJsonObject &objInfo);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief 初始化数据
|
* @brief 初始化数据
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "dbusupperinterface.h"
|
#include "dbusupperinterface.h"
|
||||||
#include "screensaveradaptor.h"
|
#include "screensaveradaptor.h"
|
||||||
#include "personalizeddata.h"
|
#include "personalizeddata.h"
|
||||||
|
#include "msysdbus.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -102,5 +103,15 @@ int main(int argc, char *argv[])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MSysDbus *m_sysDbus = new MSysDbus(interface,nullptr);
|
||||||
|
|
||||||
|
QString displayNum = QString(qgetenv("DISPLAY")).replace(":", "").replace(".", "_");
|
||||||
|
QString sysService = "org.ukui.screensaver._" + displayNum;
|
||||||
|
if (!QDBusConnection::systemBus().registerService("org.ukui.screensaver")) {
|
||||||
|
qDebug()<<"registerService failed";
|
||||||
|
}
|
||||||
|
|
||||||
|
QDBusConnection::systemBus().registerObject("/", "org.ukui.screensaver",m_sysDbus, QDBusConnection::ExportAllSlots);
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,56 +16,47 @@
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
#include <QDBusInterface>
|
#include <QDBusInterface>
|
||||||
|
#include <QDebug>
|
||||||
#include <QDBusReply>
|
#include <QDBusReply>
|
||||||
|
#include "dbusupperinterface.h"
|
||||||
#include "msysdbus.h"
|
#include "msysdbus.h"
|
||||||
#include "rsac.h"
|
#include "rsac.h"
|
||||||
#include "lockdialogmodel.h"
|
|
||||||
#include <openssl/rsa.h>
|
#include <openssl/rsa.h>
|
||||||
#include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
MSysDbus::MSysDbus(LockDialogModel *model, QObject *parent)
|
MSysDbus::MSysDbus(DbusUpperInterface *interface,QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_modelLockDialog(model)
|
, m_interface(interface)
|
||||||
|
|
||||||
{
|
{
|
||||||
registerUniauth();
|
registerUniauth();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MSysDbus::sendPassword(const QString username,QByteArray password)
|
bool MSysDbus::sendPassword(const QString username,QByteArray password)
|
||||||
{
|
{
|
||||||
|
if(m_interface)
|
||||||
if(m_modelLockDialog){
|
return m_interface->sendPassword(username,password);
|
||||||
return Q_EMIT m_modelLockDialog->sendPassword(username,password);
|
|
||||||
}
|
qWarning()<<"m_interface is nullptr";
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MSysDbus::getPublicEncrypt()
|
QString MSysDbus::getPublicEncrypt()
|
||||||
{
|
{
|
||||||
if(m_modelLockDialog){
|
if(m_interface)
|
||||||
return Q_EMIT m_modelLockDialog->getPublicEncrypt();
|
return m_interface->getPublicEncrypt();
|
||||||
}
|
|
||||||
|
qWarning()<<"m_interface is nullptr";
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSysDbus::initRSA()
|
|
||||||
{
|
|
||||||
//rsac.generateKeyPair(priKey, pubKey, 2048);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MSysDbus::registerUniauth()
|
void MSysDbus::registerUniauth()
|
||||||
{
|
{
|
||||||
QDBusInterface iface("org.ukui.UniauthBackend",
|
QDBusInterface iface("org.ukui.UniauthBackend",
|
||||||
"/org/ukui/UniauthBackend",
|
"/org/ukui/UniauthBackend",
|
||||||
"org.ukui.UniauthBackend",
|
"org.ukui.UniauthBackend",
|
||||||
QDBusConnection::systemBus());
|
QDBusConnection::systemBus());
|
||||||
QDBusReply<QString> stateReply = iface.call("registerLoginApp");
|
iface.call("registerLoginApp");
|
||||||
if(!stateReply.isValid())
|
|
||||||
{
|
|
||||||
qDebug() << "registerLoginApp:" << stateReply.error();
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,6 +66,6 @@ void MSysDbus::sendSignalLoginFinished(QString username,bool res)
|
||||||
"/org/ukui/UniauthBackend",
|
"/org/ukui/UniauthBackend",
|
||||||
"org.ukui.UniauthBackend",
|
"org.ukui.UniauthBackend",
|
||||||
QDBusConnection::systemBus());
|
QDBusConnection::systemBus());
|
||||||
QDBusReply<QString> stateReply = iface.call("sendSignalLoginFinished",username,res);
|
iface.call("sendSignalLoginFinished",username,res);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,14 +22,13 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include "rsac.h"
|
#include "rsac.h"
|
||||||
|
class DbusUpperInterface;
|
||||||
|
|
||||||
class LockDialogModel;
|
|
||||||
class MSysDbus: public QObject
|
class MSysDbus: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit MSysDbus(LockDialogModel *model, QObject *parent = nullptr);
|
explicit MSysDbus(DbusUpperInterface *interface,QObject *parent = nullptr);
|
||||||
void setAuthWidget(LockDialogModel *model);
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
Q_SCRIPTABLE bool sendPassword(const QString username,QByteArray password);
|
Q_SCRIPTABLE bool sendPassword(const QString username,QByteArray password);
|
||||||
|
@ -38,15 +37,10 @@ Q_SIGNALS:
|
||||||
void closed();
|
void closed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initRSA();
|
|
||||||
void registerUniauth();
|
void registerUniauth();
|
||||||
void sendSignalLoginFinished(QString username,bool res);
|
void sendSignalLoginFinished(QString username,bool res);
|
||||||
|
|
||||||
QString m_userName = "";
|
DbusUpperInterface *m_interface = nullptr;
|
||||||
QString m_password = "";
|
|
||||||
LockDialogModel *m_modelLockDialog = nullptr;
|
|
||||||
QByteArray priKey, pubKey;
|
|
||||||
RSAC rsac;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
#include "fullbackgroundwidget.h"
|
#include "fullbackgroundwidget.h"
|
||||||
#include "screensaverwndadaptor.h"
|
#include "screensaverwndadaptor.h"
|
||||||
#include "pluginsloader.h"
|
#include "pluginsloader.h"
|
||||||
#include "msysdbus.h"
|
|
||||||
#include "languagesetting.h"
|
#include "languagesetting.h"
|
||||||
#include "displayservice.h"
|
#include "displayservice.h"
|
||||||
|
|
||||||
|
@ -164,12 +163,6 @@ int main(int argc, char *argv[])
|
||||||
syslog(LOG_INFO, "[ukui-screensaver-dialog] window show done!!");
|
syslog(LOG_INFO, "[ukui-screensaver-dialog] window show done!!");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MSysDbus *m_sysDbus = new MSysDbus(lockDialogModel,window);
|
|
||||||
|
|
||||||
if (!QDBusConnection::systemBus().registerService("org.ukui.screensaver")) {
|
|
||||||
qDebug()<<"registerService failed";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(cmdArgs.isLock) {
|
if(cmdArgs.isLock) {
|
||||||
Q_EMIT lockDialogModel->showLock(false);
|
Q_EMIT lockDialogModel->showLock(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -948,6 +948,7 @@ void AuthDialog::onPamAuthCompleted()
|
||||||
setUkeyTypeTip("");
|
setUkeyTypeTip("");
|
||||||
authMode = UNKNOWN;
|
authMode = UNKNOWN;
|
||||||
m_uCurLoginOptType = LOGINOPT_TYPE_PASSWORD;
|
m_uCurLoginOptType = LOGINOPT_TYPE_PASSWORD;
|
||||||
|
|
||||||
Q_EMIT authSucceed(m_curUserInfo->name());
|
Q_EMIT authSucceed(m_curUserInfo->name());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue