From 442146a5d6eedab8db18b07847d78d79fdf5c4f4 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Tue, 7 Apr 2026 16:30:02 +0200 Subject: [PATCH 1/3] add jwt submodule --- .gitmodules | 3 +++ external/jwt-cpp | 1 + 2 files changed, 4 insertions(+) create mode 160000 external/jwt-cpp diff --git a/.gitmodules b/.gitmodules index a4d6dacd3..91c80c685 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ path = external/linphone-sdk [submodule "external/google/chromium-depot-tools"] path = external/google/chromium-depot-tools url = https://gitlab.linphone.org/BC/public/external/chromium-depot-tools.git +[submodule "external/jwt-cpp"] + path = external/jwt-cpp + url = https://github.com/Thalhammer/jwt-cpp.git diff --git a/external/jwt-cpp b/external/jwt-cpp new file mode 160000 index 000000000..0a503e750 --- /dev/null +++ b/external/jwt-cpp @@ -0,0 +1 @@ +Subproject commit 0a503e75084cfdb48cc2186e6b961444eb819007 From 9cbd28bbf728962d9a6c938b0098597e4b106126 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Tue, 7 Apr 2026 16:52:10 +0200 Subject: [PATCH 2/3] add username in bearer auth info when authenticated (fix #LINQT-2488) --- .gitlab-ci.yml | 1 - Linphone/model/auth/OIDCModel.cpp | 16 ++++++++++++++++ Linphone/tool/Utils.cpp | 16 ++++++++++++++++ Linphone/tool/Utils.hpp | 2 ++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0c3ab8f64..f827c8337 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -49,7 +49,6 @@ include: - '.gitlab-ci-files/windows-desktop.yml' - '.gitlab-ci-files/macosx-desktop.yml' - stages: - build - package diff --git a/Linphone/model/auth/OIDCModel.cpp b/Linphone/model/auth/OIDCModel.cpp index 48b0c23aa..4e818b984 100644 --- a/Linphone/model/auth/OIDCModel.cpp +++ b/Linphone/model/auth/OIDCModel.cpp @@ -26,6 +26,11 @@ #include "model/core/CoreModel.hpp" #include "tool/Utils.hpp" +#include +#include +#include +#include + // ============================================================================= static constexpr char OIDCScope[] = "offline_access"; @@ -351,6 +356,17 @@ void OIDCModel::setBearers() { auto accessBearer = linphone::Factory::get()->createBearerToken(Utils::appStringToCoreString(idToken()), timeT); mAuthInfo->setAccessToken(accessBearer); + auto decoded = Utils::decodeJwtPayload(Utils::coreStringToAppString(accessBearer->getToken())); + auto username = decoded["preferred_username"].toString(); + if (username.isEmpty()) { + auto username = decoded["username"].toString(); + } + if (!username.isEmpty()) { + qDebug() << "Username found in bearer access token, set in authInfo" << username; + mAuthInfo->setUsername(Utils::appStringToCoreString(username)); + } else { + lWarning() << "Username not found in bearer access token, account removal could failed"; + } if (mOidc.refreshToken() != nullptr) { diff --git a/Linphone/tool/Utils.cpp b/Linphone/tool/Utils.cpp index 75cc26de4..0960c6b00 100644 --- a/Linphone/tool/Utils.cpp +++ b/Linphone/tool/Utils.cpp @@ -2335,3 +2335,19 @@ void Utils::forceCrash() { lInfo() << "throwing segmentation fault for debug"; raise(SIGSEGV); } + +QJsonObject Utils::decodeJwtPayload(const QString &token) { + QStringList parts = token.split('.'); + if (parts.size() < 2) return {}; + + // Le payload est la 2ème partie, en base64url + QString payload = parts[1]; + // base64url -> base64 standard + payload.replace('-', '+').replace('_', '/'); + // Padding + while (payload.size() % 4 != 0) + payload += '='; + + QByteArray decoded = QByteArray::fromBase64(payload.toUtf8()); + return QJsonDocument::fromJson(decoded).object(); +} \ No newline at end of file diff --git a/Linphone/tool/Utils.hpp b/Linphone/tool/Utils.hpp index f8f933f63..392639566 100644 --- a/Linphone/tool/Utils.hpp +++ b/Linphone/tool/Utils.hpp @@ -199,6 +199,8 @@ public: // Debug Q_INVOKABLE static void forceCrash(); + static QJsonObject decodeJwtPayload(const QString &token); + // QDir findDirectoryByName(QString startPath, QString name); static QString getApplicationProduct(); From 6463c31d724776a3d2801be0a0bec72c4432355b Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Wed, 8 Apr 2026 12:13:23 +0200 Subject: [PATCH 3/3] remove jwt --- .gitmodules | 3 --- external/jwt-cpp | 1 - 2 files changed, 4 deletions(-) delete mode 160000 external/jwt-cpp diff --git a/.gitmodules b/.gitmodules index 91c80c685..a4d6dacd3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,6 +10,3 @@ path = external/linphone-sdk [submodule "external/google/chromium-depot-tools"] path = external/google/chromium-depot-tools url = https://gitlab.linphone.org/BC/public/external/chromium-depot-tools.git -[submodule "external/jwt-cpp"] - path = external/jwt-cpp - url = https://github.com/Thalhammer/jwt-cpp.git diff --git a/external/jwt-cpp b/external/jwt-cpp deleted file mode 160000 index 0a503e750..000000000 --- a/external/jwt-cpp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0a503e75084cfdb48cc2186e6b961444eb819007