mirror of
https://github.com/chenx-dust/EZ4Connect.git
synced 2026-09-20 10:23:33 +08:00
feat: 支持 aTrust RADIUS 认证的动态码输入
This commit is contained in:
@@ -11,6 +11,8 @@ ConnectionSession::ConnectionSession(CoreProcess *coreProcess, QObject *parent)
|
||||
connect(coreProcess, &CoreProcess::graphCaptcha, this, &ConnectionSession::graphCaptcha);
|
||||
connect(coreProcess, &CoreProcess::smsCode, this, &ConnectionSession::smsCode);
|
||||
connect(coreProcess, &CoreProcess::totpCode, this, &ConnectionSession::totpCode);
|
||||
connect(coreProcess, &CoreProcess::randCode, this, &ConnectionSession::randCode);
|
||||
connect(coreProcess, &CoreProcess::radiusCode, this, &ConnectionSession::radiusCode);
|
||||
connect(coreProcess, &CoreProcess::ssoAuth, this, &ConnectionSession::ssoAuth);
|
||||
connect(coreProcess, &CoreProcess::askSudoPass,
|
||||
this, &ConnectionSession::handleSudoPasswordRequest);
|
||||
|
||||
@@ -30,6 +30,8 @@ signals:
|
||||
void graphCaptcha(const QString &graphFile);
|
||||
void smsCode(bool showSkipSecondaryAuthOption);
|
||||
void totpCode();
|
||||
void randCode();
|
||||
void radiusCode(bool showSkipSecondaryAuthOption);
|
||||
void ssoAuth();
|
||||
void askSudoPass();
|
||||
void savedSudoPasswordRejected();
|
||||
|
||||
@@ -27,6 +27,8 @@ signals:
|
||||
void graphCaptcha(const QString &graphFile);
|
||||
void smsCode(bool showSkipSecondaryAuthOption);
|
||||
void totpCode();
|
||||
void randCode();
|
||||
void radiusCode(bool showSkipSecondaryAuthOption);
|
||||
void ssoAuth();
|
||||
void askSudoPass();
|
||||
void started();
|
||||
|
||||
@@ -22,6 +22,15 @@ CoreOutputEvent CoreOutputParser::parse(const QString &output)
|
||||
{
|
||||
return CoreOutputEvent::TotpCode;
|
||||
}
|
||||
if (output.contains("Please enter rand code:"))
|
||||
{
|
||||
return CoreOutputEvent::RandCode;
|
||||
}
|
||||
// aTrust RADIUS Access-Challenge:核心在密码认证后输出此提示并等待用户输入短信验证码。
|
||||
if (output.contains("Please enter the RADIUS token:"))
|
||||
{
|
||||
return CoreOutputEvent::RadiusCodeWithSkipOption;
|
||||
}
|
||||
if (output.contains("Please enter the callback url:"))
|
||||
{
|
||||
return CoreOutputEvent::SsoCallback;
|
||||
@@ -97,5 +106,6 @@ bool CoreOutputParser::hasInteractivePrompt(const QByteArray &output)
|
||||
|| output.contains("Please enter your SMS code:")
|
||||
|| output.contains("Please enter your TOTP code:")
|
||||
|| output.contains("Please enter rand code:")
|
||||
|| output.contains("Please enter the RADIUS token:")
|
||||
|| output.contains("Please enter the callback url:");
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ enum class CoreOutputEvent
|
||||
SmsCodeWithSkipOption,
|
||||
SmsCode,
|
||||
TotpCode,
|
||||
RandCode,
|
||||
RadiusCodeWithSkipOption,
|
||||
SsoCallback,
|
||||
ClientStarted,
|
||||
CaptchaFailed,
|
||||
|
||||
@@ -101,6 +101,12 @@ void ZjuConnectProcess::processOutputLines(const QList<QByteArray> &lines)
|
||||
case CoreOutputEvent::TotpCode:
|
||||
emit totpCode();
|
||||
break;
|
||||
case CoreOutputEvent::RandCode:
|
||||
emit randCode();
|
||||
break;
|
||||
case CoreOutputEvent::RadiusCodeWithSkipOption:
|
||||
emit radiusCode(true);
|
||||
break;
|
||||
case CoreOutputEvent::SsoCallback:
|
||||
emit ssoAuth();
|
||||
break;
|
||||
|
||||
@@ -233,6 +233,50 @@ void AuthDialogCoordinator::requestSmsCode(bool showSkipSecondaryAuthOption)
|
||||
emit interactiveInputSubmitted(input + "\n");
|
||||
}
|
||||
|
||||
void AuthDialogCoordinator::requestRadiusCode(bool showSkipSecondaryAuthOption)
|
||||
{
|
||||
qInfo().noquote() << "需要 RADIUS 动态口令(短信验证码)";
|
||||
|
||||
QDialog dialog(parentWidget);
|
||||
dialog.setWindowTitle("RADIUS 动态口令");
|
||||
|
||||
auto *layout = new QVBoxLayout(&dialog);
|
||||
layout->addWidget(new QLabel("请输入收到的短信验证码(RADIUS token):", &dialog));
|
||||
|
||||
auto *codeEdit = new QLineEdit(&dialog);
|
||||
layout->addWidget(codeEdit);
|
||||
|
||||
auto *skipCheckBox = new QCheckBox("跳过以后的二次认证", &dialog);
|
||||
skipCheckBox->setVisible(showSkipSecondaryAuthOption);
|
||||
layout->addWidget(skipCheckBox);
|
||||
|
||||
auto *buttonBox = new QDialogButtonBox(
|
||||
QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
|
||||
&dialog
|
||||
);
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
|
||||
layout->addWidget(buttonBox);
|
||||
|
||||
const bool accepted = dialog.exec() == QDialog::Accepted;
|
||||
if (!accepted)
|
||||
{
|
||||
qInfo().noquote() << "RADIUS 动态口令输入已取消";
|
||||
emit interactiveInputCancelled();
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray input;
|
||||
input = codeEdit->text().toLocal8Bit();
|
||||
if (showSkipSecondaryAuthOption && skipCheckBox->isChecked())
|
||||
{
|
||||
input.prepend('$');
|
||||
}
|
||||
|
||||
qInfo().noquote() << "RADIUS 动态口令已提交";
|
||||
emit interactiveInputSubmitted(input + "\n");
|
||||
}
|
||||
|
||||
void AuthDialogCoordinator::requestTotpCode()
|
||||
{
|
||||
qInfo().noquote() << "需要 TOTP 验证码";
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
void requestGraphCaptcha(const QString &graphFile);
|
||||
void requestSmsCode(bool showSkipSecondaryAuthOption);
|
||||
void requestTotpCode();
|
||||
void requestRadiusCode(bool showSkipSecondaryAuthOption);
|
||||
void requestSsoLogin();
|
||||
|
||||
signals:
|
||||
|
||||
@@ -58,6 +58,18 @@ MainWindowCoordinator::MainWindowCoordinator(
|
||||
authenticationCoordinator,
|
||||
&AuthDialogCoordinator::requestTotpCode
|
||||
);
|
||||
connect(
|
||||
connectionSession,
|
||||
&ConnectionSession::randCode,
|
||||
authenticationCoordinator,
|
||||
[this]() { authenticationCoordinator->requestSmsCode(false); }
|
||||
);
|
||||
connect(
|
||||
connectionSession,
|
||||
&ConnectionSession::radiusCode,
|
||||
authenticationCoordinator,
|
||||
&AuthDialogCoordinator::requestRadiusCode
|
||||
);
|
||||
connect(
|
||||
connectionSession,
|
||||
&ConnectionSession::ssoAuth,
|
||||
|
||||
Reference in New Issue
Block a user