update oidc client secret auth

This commit is contained in:
Jehan Monnier 2025-05-26 13:07:02 +02:00 committed by jehan
parent e08d5e0377
commit e18a1f78e8
2 changed files with 23 additions and 5 deletions

View file

@ -75,10 +75,19 @@ OIDCModel::OIDCModel(const std::shared_ptr<linphone::AuthInfo> &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<linphone::AuthInfo> 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<QByteArray> scopeTokens = {OIDCScope};
@ -202,7 +211,8 @@ OIDCModel::OIDCModel(const std::shared_ptr<linphone::AuthInfo> &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

@ -1 +1 @@
Subproject commit cd9aa90ec1b9cf2b121b6b1607ef03984177fc07
Subproject commit af9f320e144e19042983fa5eb36708a9d32601fb