From e18a1f78e8843907ced1103d9b13e735be2600d6 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 26 May 2025 13:07:02 +0200 Subject: [PATCH] update oidc client secret auth --- Linphone/model/auth/OIDCModel.cpp | 26 ++++++++++++++++++++++---- external/linphone-sdk | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Linphone/model/auth/OIDCModel.cpp b/Linphone/model/auth/OIDCModel.cpp index de7a18a09..e24d95029 100644 --- a/Linphone/model/auth/OIDCModel.cpp +++ b/Linphone/model/auth/OIDCModel.cpp @@ -75,10 +75,19 @@ OIDCModel::OIDCModel(const std::shared_ptr &authInfo, QObjec qDebug() << "OIDC Client ID set to [" << clientid << "]"; // find an auth info from LinphoneCore where username = clientid - auto clientSecret = CoreModel::getInstance()->getCore()->findAuthInfo("", clientid.toStdString(), ""); + std::shared_ptr clientSecret = nullptr; + // search for auth info for this client id + for (const auto &authInfo : CoreModel::getInstance()->getCore()->getAuthInfoList()) { + if (authInfo->getClientId() == clientid.toStdString()) { + qDebug() << "AuthInfo found for client id [" << clientid << "]"; + clientSecret = authInfo; + break; + } + } + if (clientSecret != nullptr) { qDebug() << "client secret found for client id [" << clientid << "]"; - mOidc.setClientIdentifierSharedKey(clientSecret->getPassword().c_str()); + mOidc.setClientIdentifierSharedKey(clientSecret->getClientSecret().c_str()); } QSet scopeTokens = {OIDCScope}; @@ -202,7 +211,8 @@ OIDCModel::OIDCModel(const std::shared_ptr &authInfo, QObjec // for (auto it = tokens.cbegin(); it != tokens.cend(); ++it) { // qDebug() << "Token key:" << it.key() << ", value:" << it.value().toString(); // } - if (tokens.contains("id_token")) { + if (tokens.contains("id_token") && + CoreModel::getInstance()->getCore()->getConfig()->getBool("app", "oidc_use_id_token", false)) { auto idToken = tokens["id_token"].toString(); qDebug() << "ID Token received:" << idToken.left(3) + "..." + idToken.right(3); mIdToken = idToken; @@ -315,7 +325,15 @@ void OIDCModel::setBearers() { } QString OIDCModel::idToken() const { #if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0) - return mOidc.idToken().isEmpty() ? mOidc.token() : mOidc.idToken(); + if (CoreModel::getInstance()->getCore()->getConfig()->getBool("app", "oidc_use_id_token", false)) { + if (!mOidc.idToken().isEmpty()) { + return mOidc.idToken(); + } else { + return mOidc.token(); + } + } else { + return mOidc.token(); + } #else return mIdToken; #endif diff --git a/external/linphone-sdk b/external/linphone-sdk index cd9aa90ec..af9f320e1 160000 --- a/external/linphone-sdk +++ b/external/linphone-sdk @@ -1 +1 @@ -Subproject commit cd9aa90ec1b9cf2b121b6b1607ef03984177fc07 +Subproject commit af9f320e144e19042983fa5eb36708a9d32601fb