Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5bc1e59
Added initial draft for the auth db sync
gabriel-bolbotina Dec 8, 2025
50354d6
Modified authsync
gabriel-bolbotina Dec 9, 2025
c251edd
Formatted code
gabriel-bolbotina Dec 9, 2025
0caf555
Simplified class
gabriel-bolbotina Dec 9, 2025
5d5f9ad
Formatted code
gabriel-bolbotina Dec 9, 2025
9d1cc77
Qca-workaround
gabriel-bolbotina Dec 10, 2025
651b714
Modified auth db sync
gabriel-bolbotina Dec 12, 2025
34e5521
Formatted cmake file
gabriel-bolbotina Dec 12, 2025
e0ca6f2
Implemented code review findings
gabriel-bolbotina Dec 12, 2025
6c424a1
Removed authSync class + header
gabriel-bolbotina Dec 12, 2025
f05ee2f
Modified mock cfg file, corrected test auth import
gabriel-bolbotina Dec 12, 2025
bdf48b4
Revert "Modified mock cfg file, corrected test auth import"
gabriel-bolbotina Dec 15, 2025
7eb22b2
Implemented code review findings
gabriel-bolbotina Dec 15, 2025
05ebb9b
Implemented code findings
gabriel-bolbotina Dec 18, 2025
83470ec
Updated unit test
gabriel-bolbotina Jan 21, 2026
962ad45
Modified cmake for windows qca
gabriel-bolbotina Jan 21, 2026
1fdd8f3
Used windows dll
gabriel-bolbotina Jan 21, 2026
e1a2031
Fix QCA for windows build
Withalion Jan 22, 2026
5608f8f
Excluded opensslPlugin from the windows build
gabriel-bolbotina Jan 22, 2026
fe5119e
Modified active project
gabriel-bolbotina Jan 23, 2026
f0b9dec
Updated comments
gabriel-bolbotina Jan 30, 2026
f848d4a
Implemented code findings
gabriel-bolbotina Feb 2, 2026
d71664f
Fixed authentication database logic
gabriel-bolbotina Feb 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ endif ()
if (WIN)
add_compile_definitions(_HAS_AUTO_PTR_ETC=1)
add_compile_definitions(_USE_MATH_DEFINES)
# On windows the compiler instead of using standard min & max functions expands them to
# min & max macros in every file that includes windows header file
add_compile_definitions(NOMINMAX)
endif ()

if (IOS OR ANDROID)
Expand Down
23 changes: 23 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ set(MM_HDRS
mmstyle.h
)

if (NOT WIN32)
set(MM_SRCS ${MM_SRCS} static_plugins.cpp)
endif ()

if (HAVE_BLUETOOTH)
set(MM_SRCS ${MM_SRCS} position/providers/bluetoothpositionprovider.cpp)

Expand Down Expand Up @@ -506,6 +510,21 @@ if (LNX)
target_link_libraries(MerginMaps PUBLIC QGIS::Core)
endif ()

if (NOT WIN32)
# for every other platform except windows
find_library(
QCA_OSSL_PLUGIN_LIB
NAMES qca-ossl libqca-ossl
PATH_SUFFIXES lib/Qca/crypto
)

if (QCA_OSSL_PLUGIN_LIB)
message(STATUS "Found QCA OpenSSL Plugin: ${QCA_OSSL_PLUGIN_LIB}")
else ()
message(WARNING "Could not find 'qca-ossl'. Authentication might fail.")
endif ()
endif ()

target_link_libraries(
MerginMaps
PUBLIC Qt6Keychain::Qt6Keychain
Expand All @@ -515,6 +534,10 @@ target_link_libraries(
Spatialite::Spatialite
)

if (NOT WIN32)
target_link_libraries(MerginMaps PUBLIC ${QCA_OSSL_PLUGIN_LIB})
endif ()

target_link_libraries(
MerginMaps
PUBLIC Spatialindex::Spatialindex
Expand Down
17 changes: 17 additions & 0 deletions app/activeproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "qgslayertreelayer.h"
#include "qgslayertreegroup.h"
#include "qgsmapthemecollection.h"
#include "qgsauthmanager.h"
#include "qgsapplication.h"

#include "activeproject.h"
#include "coreutils.h"
Expand All @@ -25,6 +27,8 @@
#include "position/tracking/androidtrackingbroadcast.h"
#endif

const QString AUTH_CONFIG_FILENAME = QStringLiteral( "qgis_cfg.xml" );

const QString ActiveProject::LOADING_FLAG_FILE_PATH = QString( "%1/.input_loading_project" ).arg( QStandardPaths::standardLocations( QStandardPaths::TempLocation ).first() );
const int ActiveProject::LOADING_FLAG_FILE_EXPIRATION_MS = 5000;

Expand Down Expand Up @@ -155,6 +159,18 @@ bool ActiveProject::forceLoad( const QString &filePath, bool force )
emit projectWillBeReloaded();
mActiveLayer.resetActiveLayer();

// path to the authentication configuration file
const QDir projectDir = QFileInfo( filePath ).dir();
const QFileInfo cfgFile( projectDir.filePath( AUTH_CONFIG_FILENAME ) );
if ( cfgFile.exists() && cfgFile.isFile() )
{
// import the new configuration, if it exists.
QgsAuthManager *authManager = QgsApplication::authManager();
const QString projectId = MerginProjectMetadata::fromCachedJson( CoreUtils::getProjectMetadataPath( projectDir.path() ) ).projectId;
const bool ok = authManager->importAuthenticationConfigsFromXml( cfgFile.filePath(), projectId, true );
CoreUtils::log( "Authentication database", QStringLiteral( "QGIS auth imported: %1" ).arg( ok ? "success" : "failure" ) );
}

res = mQgsProject->read( filePath );
if ( !res )
{
Expand Down Expand Up @@ -186,6 +202,7 @@ bool ActiveProject::forceLoad( const QString &filePath, bool force )
QString role = MerginProjectMetadata::fromCachedJson( CoreUtils::getProjectMetadataPath( mLocalProject.projectDir ) ).role;
setProjectRole( role );


updateMapTheme();
updateActiveLayer();
updateMapSettingsLayers();
Expand Down
9 changes: 9 additions & 0 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "test/inputtests.h"
#endif
#include <qqml.h>
#include "qgsauthmanager.h"
#include <qgsmessagelog.h>
#include "qgsconfig.h"
#include "qgsproviderregistry.h"
Expand Down Expand Up @@ -543,6 +544,14 @@ int main( int argc, char *argv[] )
LayerTreeFlatModelPixmapProvider *layerTreeFlatModelPixmapProvider( new LayerTreeFlatModelPixmapProvider );
LayerDetailLegendImageProvider *layerDetailLegendImageProvider( new LayerDetailLegendImageProvider );

QgsAuthManager *authManager = QgsApplication::authManager();
// remove existing authentication database when opening the app
authManager->removeAllAuthenticationConfigs();
// set up the master password for authentication database retrieval
authManager->setPasswordHelperEnabled( false );
authManager->setMasterPassword( QStringLiteral( "merginMaps" ), true );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of verify=true does not seem to do much as we do not read the return value. Still ok though..



// build position kit, save active provider to QSettings and load previously active provider
PositionKit pk;
QObject::connect( &pk, &PositionKit::positionProviderChanged, as, [as]( AbstractPositionProvider * provider )
Expand Down
3 changes: 3 additions & 0 deletions app/static_plugins.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <QtPlugin>
// Required for QGIS authentication manager API on static builds (Linux/macOS/iOS/android)
Q_IMPORT_PLUGIN( opensslPlugin )
52 changes: 42 additions & 10 deletions app/test/testactiveproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void TestActiveProject::testProjectValidations()
QString projectFilename = "bad_layer.qgz";

AppSettings as;
ActiveLayer al;
ActiveProject activeProject( as, al, mApi->localProjectsManager() );
ActiveLayer activeLayer;
ActiveProject activeProject( as, activeLayer, mApi->localProjectsManager() );

QSignalSpy spyReportIssues( &activeProject, &ActiveProject::reportIssue );
QSignalSpy spyErrorsFound( &activeProject, &ActiveProject::loadingErrorFound );
Expand All @@ -61,8 +61,8 @@ void TestActiveProject::testProjectLoadFailure()
InputUtils::cpDir( TestUtils::testDataDir() + "/load_failure", projectdir );

AppSettings as;
ActiveLayer al;
ActiveProject activeProject( as, al, mApi->localProjectsManager() );
ActiveLayer activeLayer;
ActiveProject activeProject( as, activeLayer, mApi->localProjectsManager() );

mApi->localProjectsManager().addLocalProject( projectdir, projectname );

Expand All @@ -81,8 +81,8 @@ void TestActiveProject::testPositionTrackingFlag()
// the position tracking availability is correctly set

AppSettings as;
ActiveLayer al;
ActiveProject activeProject( as, al, mApi->localProjectsManager() );
ActiveLayer activeLayer;
ActiveProject activeProject( as, activeLayer, mApi->localProjectsManager() );

// project "planes" - tracking not enabled
QString projectDir = TestUtils::testDataDir() + "/planes/";
Expand Down Expand Up @@ -121,8 +121,8 @@ void TestActiveProject::testRecordingAllowed()
QString projectFilename = "tracking-project.qgz";

AppSettings as;
ActiveLayer al;
ActiveProject activeProject( as, al, mApi->localProjectsManager() );
ActiveLayer activeLayer;
ActiveProject activeProject( as, activeLayer, mApi->localProjectsManager() );

mApi->localProjectsManager().addLocalProject( projectDir, projectFilename );
QVERIFY( activeProject.load( projectDir + "/" + projectFilename ) );
Expand Down Expand Up @@ -169,8 +169,8 @@ void TestActiveProject::testRecordingAllowed()
void TestActiveProject::testLoadingFlagFileExpiration()
{
AppSettings as;
ActiveLayer al;
ActiveProject activeProject( as, al, mApi->localProjectsManager() );
ActiveLayer activeLayer;
ActiveProject activeProject( as, activeLayer, mApi->localProjectsManager() );

// project "planes" - tracking not enabled
QString projectDir = TestUtils::testDataDir() + "/planes/";
Expand All @@ -191,3 +191,35 @@ void TestActiveProject::testLoadingFlagFileExpiration()

QVERIFY( !flagFile.exists() );
}

void TestActiveProject::testLoadingAuthFileFromConfiguration()
{
AppSettings appSettings;
ActiveLayer activeLayer;
ActiveProject activeProject( appSettings, activeLayer, mApi->localProjectsManager() );
QString projectDir = TestUtils::testDataDir() + QStringLiteral( "/project_auth_file/" );
QString projectName = QStringLiteral( "auth-test.qgz" );
QString authFile = QDir( projectDir ).filePath( AUTH_CONFIG_FILENAME );

QgsAuthManager *authManager = QgsApplication::authManager();

mApi->localProjectsManager().addLocalProject( projectDir, projectName );
activeProject.load( projectDir + projectName );

QSignalSpy spyLoadingStarted( &activeProject, &ActiveProject::loadingStarted );

// we expect the configuration import to fail
int count = authManager->configIds().count();
QCOMPARE( count, 0 );

QFileInfo cfgFileInfo( authFile );
if ( cfgFileInfo.exists() && cfgFileInfo.isFile() )
{
// we still check that the configuration can be imported
bool ok = authManager->importAuthenticationConfigsFromXml( authFile, AUTH_CONFIG_PASSWORD, true );

QCOMPARE( ok, true );
count = authManager->configIds().count();
QCOMPARE( count, 1 );
}
}
6 changes: 6 additions & 0 deletions app/test/testactiveproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

#include <QObject>
#include <merginapi.h>
#include <qgsapplication.h>
#include <qgsauthmanager.h>

const QString AUTH_CONFIG_FILENAME = QStringLiteral( "qgis_cfg.xml" );
const QString AUTH_CONFIG_PASSWORD = QStringLiteral( "1234" );

class TestActiveProject : public QObject
{
Expand All @@ -29,6 +34,7 @@ class TestActiveProject : public QObject
void testPositionTrackingFlag();
void testRecordingAllowed();
void testLoadingFlagFileExpiration();
void testLoadingAuthFileFromConfiguration();

private:
MerginApi *mApi;
Expand Down
Binary file not shown.
Binary file added test/test_data/project_auth_file/auth-test.qgz
Binary file not shown.
2 changes: 2 additions & 0 deletions test/test_data/project_auth_file/qgis_cfg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE qgis_authentication>
<qgis_authentication civ="fce8ce72133e5d85b5af66d3046e5c78411f20bb3ebb47eb851d469350922773" salt="0bd55a8f76c40cdef3bc8897714175fa" hash="dfe957824c402c5853a7a0f1d0feaa58">21ce1cf53ab351eb229b3ae83f7384b76578dd93d76e3515904213a79dddd46b0ed3e05f5f906fa681e7714af0d0d9dd551735a31bae5ea96333cc9ebe2debc003eebf44e42c1ec5cd9c7214d8a7399dedfd2f89819661615013ec79fb3bce642138f593be11c64f4f1374b274e1b5c887f229190521e7d0a340f97f1a27c78d70f1e3ac28d9b605d0ae07a9832c03ea2778c0629cbbc8e932d5b36b941f6d4eabe0b4d734d10ce41464064da7e2ee14204064a1ddfa7ca9427ad3aa4fd0cc467bab98b12235a867ddc6542935db835b</qgis_authentication>
2 changes: 1 addition & 1 deletion vcpkg/ports/qca/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ vcpkg_from_github(
REF
"v${VERSION}"
SHA512
956d36058db61498c492fc9b5345b45ca75a5e8214fcbf358273dfacdd5980c1394394652536d9332df05f29fc912d0781338bcca403d98de1285bb8b1216402
21bbc483f78d8c6b99bf2a4375db6a1bcc8a1a16df01e2295dc6a5b43fa27ccbef39114ee33d456071f712a00aca0ab3bc1bf767df82333c2f98ea35f7d35b45
PATCHES
0001-fix-path-for-vcpkg.patch
0002-fix-build-error.patch
Expand Down
2 changes: 1 addition & 1 deletion vcpkg/ports/qca/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qca",
"version": "2.3.9",
"version": "2.3.10",
"description": "Qt Cryptographic Architecture (QCA).",
"homepage": "https://userbase.kde.org/QCA",
"dependencies": [
Expand Down
Loading