mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-17 20:08:28 +00:00
OIDC fixes :
force timeout on request finished fix oidc crash Fix basic auth mode for oidc. Make sure refresh token is optionnal fix oidc connector scope parsing in case of QT >= 9.0 sso page to manually cancel sso connection
This commit is contained in:
parent
df49481bde
commit
285ae13eb8
4 changed files with 30 additions and 4 deletions
|
|
@ -338,6 +338,9 @@ App::App(int &argc, char *argv[])
|
|||
mEventCountNotifier = new EventCountNotifier(this);
|
||||
mDateUpdateTimer.start();
|
||||
|
||||
mOIDCRefreshTimer.setInterval(1000);
|
||||
mOIDCRefreshTimer.setSingleShot(false);
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
exportDesktopFile();
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -305,8 +305,16 @@ void OIDCModel::stopTimeoutTimer() {
|
|||
|
||||
void OIDCModel::openIdConfigReceived() {
|
||||
auto reply = dynamic_cast<QNetworkReply *>(sender());
|
||||
auto document = QJsonDocument::fromJson(reply->readAll());
|
||||
if (document.isNull()) return;
|
||||
auto replyArray = reply->readAll();
|
||||
lInfo() << log().arg("Reply :") << replyArray;
|
||||
auto document = QJsonDocument::fromJson(replyArray);
|
||||
if (document.isNull()) {
|
||||
lWarning() << log().arg("Reply is empty");
|
||||
//: OIDC reply is empty !
|
||||
emit requestFailed(tr("oidc_authentication_empty_reply_error"));
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
auto rootArray = document.toVariant().toMap();
|
||||
if (rootArray.contains("authorization_endpoint")) {
|
||||
mOidc.setAuthorizationUrl(QUrl(rootArray["authorization_endpoint"].toString()));
|
||||
|
|
|
|||
|
|
@ -59,6 +59,10 @@ CoreModel::CoreModel(const QString &configPath, QThread *parent)
|
|||
}
|
||||
|
||||
CoreModel::~CoreModel() {
|
||||
for (auto &oidc : mOpenIdConnections) {
|
||||
oidc->deleteLater();
|
||||
}
|
||||
mOpenIdConnections.clear();
|
||||
}
|
||||
|
||||
std::shared_ptr<CoreModel> CoreModel::create(const QString &configPath, QThread *parent) {
|
||||
|
|
@ -417,7 +421,7 @@ void CoreModel::onAuthenticationRequested(const std::shared_ptr<linphone::Core>
|
|||
qDebug() << "onAuthenticationRequested for Bearer. Initialize OpenID connection for " << username << "@"
|
||||
<< realm << " at " << serverUrl;
|
||||
QString key = username + '@' + realm + ' ' + serverUrl;
|
||||
if (mOpenIdConnections.contains(key)) mOpenIdConnections[key]->deleteLater();
|
||||
// if (mOpenIdConnections.contains(key)) mOpenIdConnections[key]->deleteLater();
|
||||
auto oidcModel = new OIDCModel(authInfo, this);
|
||||
mOpenIdConnections[key] = oidcModel;
|
||||
connect(oidcModel, &OIDCModel::timeoutTimerStarted, this, [this] {
|
||||
|
|
@ -425,6 +429,16 @@ void CoreModel::onAuthenticationRequested(const std::shared_ptr<linphone::Core>
|
|||
emit timeoutTimerStarted();
|
||||
qDebug() << "start refresh timer";
|
||||
});
|
||||
connect(oidcModel, &OIDCModel::requestFailed, this, [this, oidcModel](const QString &error) {
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
lWarning() << log().arg("Request failed") << error;
|
||||
emit oidcRequestFailed(error);
|
||||
oidcModel->forceTimeout();
|
||||
});
|
||||
connect(oidcModel, &OIDCModel::finished, this, [this, oidcModel] {
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
lInfo() << log().arg("Request finished");
|
||||
});
|
||||
if (oidcModel->isTimerRunning()) {
|
||||
emit timeoutTimerStarted();
|
||||
}
|
||||
|
|
@ -660,4 +674,4 @@ void CoreModel::onAudioDevicesListUpdated(const std::shared_ptr<linphone::Core>
|
|||
void CoreModel::onAudioDeviceChanged(const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::AudioDevice> &device) {
|
||||
emit audioDeviceChanged(core, device);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ signals:
|
|||
void forceOidcTimeout();
|
||||
void timeoutTimerStarted();
|
||||
void timeoutTimerStopped();
|
||||
void oidcRequestFailed(QString error);
|
||||
|
||||
private:
|
||||
QString mConfigPath;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue