Skip to content

Commit

Permalink
Adapt to new Azure login
Browse files Browse the repository at this point in the history
  • Loading branch information
syyyr committed Feb 6, 2025
1 parent 3c9b6e2 commit 124db83
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/libshv
Submodule libshv updated 60 files
+3 −0 .clang-tidy
+1 −1 .github/actions/cmake/action.yml
+1 −6 .github/actions/run-linter/action.yml
+5 −0 libshvbroker/CMakeLists.txt
+1 −0 libshvbroker/include/shv/broker/appclioptions.h
+1 −0 libshvbroker/include/shv/broker/azureconfig.h
+3 −4 libshvbroker/include/shv/broker/brokerapp.h
+5 −5 libshvbroker/include/shv/broker/ldap/ldap.h
+1 −0 libshvbroker/src/appclioptions.cpp
+3 −3 libshvbroker/src/brokeraclnode.cpp
+26 −122 libshvbroker/src/brokerapp.cpp
+1 −1 libshvbroker/src/brokerappnode.cpp
+102 −0 libshvbroker/src/dotbrokernode.cpp
+24 −0 libshvbroker/src/dotbrokernode.h
+6 −6 libshvbroker/src/ldap.cpp
+4 −3 libshvbroker/src/rpc/brokertcpserver.cpp
+5 −2 libshvbroker/src/rpc/brokertcpserver.h
+4 −4 libshvbroker/src/rpc/clientconnectiononbroker.cpp
+2 −2 libshvbroker/src/rpc/clientconnectiononbroker.h
+7 −3 libshvbroker/src/rpc/serverconnection.cpp
+5 −3 libshvbroker/src/rpc/serverconnection.h
+2 −2 libshvbroker/src/rpc/tcpserver.cpp
+2 −2 libshvbroker/src/rpc/tcpserver.h
+3 −2 libshvbroker/src/rpc/websocketserver.cpp
+4 −1 libshvbroker/src/rpc/websocketserver.h
+4 −0 libshvbroker/tests/test_aclmanager.cpp
+1 −2 libshvchainpack/include/shv/chainpack/rpcvalue.h
+4 −9 libshvchainpack/src/rpcvalue.cpp
+2 −0 libshvchainpack/tests/test_chainpack.cpp
+2 −1 libshvchainpack/tests/test_cpon.cpp
+2 −1 libshvchainpack/tests/test_rpcmessage.cpp
+3 −2 libshvchainpack/tests/test_rpcvalue.cpp
+2 −2 libshvcore/include/shv/core/utils/shvpath.h
+5 −12 libshvcore/src/utils.cpp
+1 −1 libshvcore/src/utils/getlog.cpp
+3 −5 libshvcore/src/utils/shvfilejournal.cpp
+1 −1 libshvcore/src/utils/shvjournalentry.cpp
+3 −2 libshvcore/src/utils/shvjournalfilewriter.cpp
+3 −2 libshvcore/src/utils/shvpath.cpp
+2 −0 libshvcore/src/utils/shvtypeinfo.cpp
+2 −0 libshvcore/tests/test_clioptions.cpp
+6 −0 libshvcore/tests/test_getlog.cpp
+2 −1 libshvcore/tests/test_shvlog.cpp
+31 −31 libshvcore/tests/test_shvpath.cpp
+4 −2 libshvcore/tests/test_shvtypeinfo.cpp
+2 −0 libshvcore/tests/test_utils.cpp
+8 −18 libshvcoreqt/src/data/valuechange.cpp
+2 −0 libshvcoreqt/tests/test_rpc_variant.cpp
+2 −0 libshvcoreqt/tests/test_utils.cpp
+0 −4 libshviotqt/CMakeLists.txt
+2 −1 libshviotqt/include/shv/iotqt/rpc/clientconnection.h
+1 −1 libshviotqt/src/node/localfsnode.cpp
+34 −16 libshviotqt/src/rpc/clientconnection.cpp
+2 −0 libshviotqt/tests/serialportsocket/test_serialportsocket.cpp
+4 −0 libshviotqt/tests/test_frame_reader.cpp
+0 −15 libshvvisu/src/logview/logsortfilterproxymodel.cpp
+12 −16 libshvvisu/src/timeline/graph.cpp
+3 −6 libshvvisu/src/timeline/graphwidget.cpp
+2 −0 utils/cp2cp/main.cpp
+2 −0 utils/cp2log/main.cpp
44 changes: 23 additions & 21 deletions shvspy/src/servertreemodel/shvbrokernodeitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ const std::string& ShvBrokerNodeItem::shvRoot() const

#if QT_VERSION_MAJOR >= 6 && defined(WITH_AZURE_SUPPORT)
namespace {
const auto AZURE_CLIENT_ID = "f6c73b47-914d-4232-bbe9-70495e48b314";
const auto AZURE_AUTH_URL = QUrl("https://login.microsoftonline.com/common/oauth2/v2.0/authorize");
const auto AZURE_ACCESS_TOKEN_URL = QUrl("https://login.microsoftonline.com/common/oauth2/v2.0/token");
const auto AZURE_SCOPES = "User.Read";
Expand All @@ -167,13 +166,13 @@ const auto AZURE_SCOPES = "User.Read";
#define azureWarning() shvCWarning("azure")
#define azureError() shvCError("azure")

auto do_azure_auth(QObject* parent)
auto do_azure_auth(const QString& client_id, QObject* parent)
{
auto oauth2 = new QOAuth2AuthorizationCodeFlow(parent);
auto replyHandler = new QOAuthHttpServerReplyHandler(oauth2);
replyHandler->setCallbackText("Azure authentication successful. You can now close this window.");
oauth2->setReplyHandler(replyHandler);
oauth2->setClientIdentifier(AZURE_CLIENT_ID);
oauth2->setClientIdentifier(client_id);
oauth2->setAuthorizationUrl(AZURE_AUTH_URL);
oauth2->setAccessTokenUrl(AZURE_ACCESS_TOKEN_URL);
oauth2->setScope(AZURE_SCOPES);
Expand Down Expand Up @@ -291,27 +290,30 @@ void ShvBrokerNodeItem::open()
m_openStatus = OpenStatus::Disconnected;
return;
}
do_azure_auth(this).then([this, cli] (const std::variant<QFuture<QString>, QFuture<QString>>& result_or_error) {
if (result_or_error.index() == 0) {
auto result = std::get<0>(result_or_error);
// This can happen due to a bug: https://bugreports.qt.io/browse/QTBUG-115580
if (!result.isValid()) {
return;

cli->setLoginType(cp::IRpcConnection::LoginType::AzureAccessToken);
cli->setsetAzurePasswordCallback([this] (const auto& client_id, const auto& azure_access_token_cb) {
do_azure_auth(QString::fromStdString(client_id), this).then([this, azure_access_token_cb] (const std::variant<QFuture<QString>, QFuture<QString>>& result_or_error) {
if (result_or_error.index() == 0) {
auto result = std::get<0>(result_or_error);
// This can happen due to a bug: https://bugreports.qt.io/browse/QTBUG-115580
if (!result.isValid()) {
return;
}
azure_access_token_cb(std::get<0>(result_or_error).result().toStdString());
emitDataChanged();
}
cli->setLoginType(shv::iotqt::rpc::ClientConnection::LoginType::AzureAccessToken);
cli->setPassword(std::get<0>(result_or_error).result().toStdString());
cli->open();
emitDataChanged();
}
else {
auto error = std::get<1>(result_or_error);
// This can happen due to a bug: https://bugreports.qt.io/browse/QTBUG-115580
if (!error.isValid()) {
return;
else {
auto error = std::get<1>(result_or_error);
// This can happen due to a bug: https://bugreports.qt.io/browse/QTBUG-115580
if (!error.isValid()) {
return;
}
onBrokerLoginError(std::get<1>(result_or_error).result());
}
onBrokerLoginError(std::get<1>(result_or_error).result());
}
});
});
cli->open();
}
else {
#endif
Expand Down

0 comments on commit 124db83

Please sign in to comment.