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);
|
mEventCountNotifier = new EventCountNotifier(this);
|
||||||
mDateUpdateTimer.start();
|
mDateUpdateTimer.start();
|
||||||
|
|
||||||
|
mOIDCRefreshTimer.setInterval(1000);
|
||||||
|
mOIDCRefreshTimer.setSingleShot(false);
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
exportDesktopFile();
|
exportDesktopFile();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -305,8 +305,16 @@ void OIDCModel::stopTimeoutTimer() {
|
||||||
|
|
||||||
void OIDCModel::openIdConfigReceived() {
|
void OIDCModel::openIdConfigReceived() {
|
||||||
auto reply = dynamic_cast<QNetworkReply *>(sender());
|
auto reply = dynamic_cast<QNetworkReply *>(sender());
|
||||||
auto document = QJsonDocument::fromJson(reply->readAll());
|
auto replyArray = reply->readAll();
|
||||||
if (document.isNull()) return;
|
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();
|
auto rootArray = document.toVariant().toMap();
|
||||||
if (rootArray.contains("authorization_endpoint")) {
|
if (rootArray.contains("authorization_endpoint")) {
|
||||||
mOidc.setAuthorizationUrl(QUrl(rootArray["authorization_endpoint"].toString()));
|
mOidc.setAuthorizationUrl(QUrl(rootArray["authorization_endpoint"].toString()));
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,10 @@ CoreModel::CoreModel(const QString &configPath, QThread *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreModel::~CoreModel() {
|
CoreModel::~CoreModel() {
|
||||||
|
for (auto &oidc : mOpenIdConnections) {
|
||||||
|
oidc->deleteLater();
|
||||||
|
}
|
||||||
|
mOpenIdConnections.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<CoreModel> CoreModel::create(const QString &configPath, QThread *parent) {
|
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 << "@"
|
qDebug() << "onAuthenticationRequested for Bearer. Initialize OpenID connection for " << username << "@"
|
||||||
<< realm << " at " << serverUrl;
|
<< realm << " at " << serverUrl;
|
||||||
QString key = username + '@' + realm + ' ' + 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);
|
auto oidcModel = new OIDCModel(authInfo, this);
|
||||||
mOpenIdConnections[key] = oidcModel;
|
mOpenIdConnections[key] = oidcModel;
|
||||||
connect(oidcModel, &OIDCModel::timeoutTimerStarted, this, [this] {
|
connect(oidcModel, &OIDCModel::timeoutTimerStarted, this, [this] {
|
||||||
|
|
@ -425,6 +429,16 @@ void CoreModel::onAuthenticationRequested(const std::shared_ptr<linphone::Core>
|
||||||
emit timeoutTimerStarted();
|
emit timeoutTimerStarted();
|
||||||
qDebug() << "start refresh timer";
|
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()) {
|
if (oidcModel->isTimerRunning()) {
|
||||||
emit timeoutTimerStarted();
|
emit timeoutTimerStarted();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ signals:
|
||||||
void forceOidcTimeout();
|
void forceOidcTimeout();
|
||||||
void timeoutTimerStarted();
|
void timeoutTimerStarted();
|
||||||
void timeoutTimerStopped();
|
void timeoutTimerStopped();
|
||||||
|
void oidcRequestFailed(QString error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mConfigPath;
|
QString mConfigPath;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue