Skip to content
Permalink
Browse files
allow to build auth methods statically (#43866)
* allow to build auth methods statically

* enable static build of all auth methods

* follow-up

* fix static auths

* fix dynamic

* fix bindings

* fix core only

* fix dox

* fix dox again

* fix bindings again

* fix test and more

* some cleanup

* fix test

* add missing gui edits

* O2_DLL

* fix bindings with core only

* fix SIP feature

* fix SIP condition

* disable feature earlier

* fix auth manager bindings without gui

* put back virtual methods
  • Loading branch information
3nids committed Jun 24, 2021
2 parents cb2fb67 + 8915a07 commit 6cdbced8746eb42d7ef53df2b67507f8275667b4
Showing with 781 additions and 730 deletions.
  1. +5 −0 CMakeLists.txt
  2. +2 −0 cmake_templates/qgsconfig.h.in
  3. +4 −0 python/CMakeLists.txt
  4. +4 −0 python/core/auto_generated/auth/qgsauthmanager.sip.in
  5. +11 −1 python/core/auto_generated/auth/qgsauthmethod.sip.in
  6. +1 −0 python/core/core.sip.in
  7. +0 −1 src/auth/CMakeLists.txt
  8. +42 −16 src/auth/basic/CMakeLists.txt
  9. +20 −36 src/auth/basic/core/qgsauthbasicmethod.cpp
  10. +23 −0 src/auth/basic/core/qgsauthbasicmethod.h
  11. +0 −25 src/auth/basic/gui/qgsauthbasicmethodgui.cpp
  12. +39 −16 src/auth/esritoken/CMakeLists.txt
  13. +19 −39 src/auth/esritoken/core/qgsauthesritokenmethod.cpp
  14. +21 −0 src/auth/esritoken/core/qgsauthesritokenmethod.h
  15. +0 −27 src/auth/esritoken/gui/qgsauthesritokenmethodgui.cpp
  16. +40 −20 src/auth/identcert/CMakeLists.txt
  17. +22 −43 src/auth/identcert/core/qgsauthidentcertmethod.cpp
  18. +21 −0 src/auth/identcert/core/qgsauthidentcertmethod.h
  19. +0 −27 src/auth/identcert/gui/qgsauthidentcertmethodgui.cpp
  20. +58 −28 src/auth/oauth2/CMakeLists.txt
  21. +17 −39 src/auth/oauth2/core/qgsauthoauth2method.cpp
  22. +21 −1 src/auth/oauth2/core/qgsauthoauth2method.h
  23. +0 −25 src/auth/oauth2/gui/qgsauthoauth2methodgui.cpp
  24. +40 −21 src/auth/pkipaths/CMakeLists.txt
  25. +23 −45 src/auth/pkipaths/core/qgsauthpkipathsmethod.cpp
  26. +22 −0 src/auth/pkipaths/core/qgsauthpkipathsmethod.h
  27. +0 −27 src/auth/pkipaths/gui/qgsauthpkipathsmethodgui.cpp
  28. +40 −21 src/auth/pkipkcs12/CMakeLists.txt
  29. +17 −40 src/auth/pkipkcs12/core/qgsauthpkcs12method.cpp
  30. +21 −0 src/auth/pkipkcs12/core/qgsauthpkcs12method.h
  31. +0 −27 src/auth/pkipkcs12/gui/qgsauthpkcs12methodgui.cpp
  32. +13 −0 src/core/CMakeLists.txt
  33. +20 −2 src/core/auth/qgsauthmanager.cpp
  34. +13 −0 src/core/auth/qgsauthmanager.h
  35. +8 −0 src/core/auth/qgsauthmethod.cpp
  36. +14 −1 src/core/auth/qgsauthmethod.h
  37. +11 −10 src/core/auth/qgsauthmethodmetadata.cpp
  38. +25 −7 src/core/auth/qgsauthmethodmetadata.h
  39. +98 −147 src/core/auth/qgsauthmethodregistry.cpp
  40. +11 −17 src/core/auth/qgsauthmethodregistry.h
  41. +5 −0 src/gui/CMakeLists.txt
  42. +6 −5 src/gui/auth/qgsauthconfigedit.cpp
  43. +5 −3 src/gui/auth/qgsauthconfigselect.cpp
  44. +13 −7 src/gui/auth/qgsautheditorwidgets.cpp
  45. +1 −1 tests/src/auth/CMakeLists.txt
  46. +5 −5 tests/src/core/testqgsauthmanager.cpp
@@ -138,6 +138,11 @@ if(WITH_CORE)

set (WITH_GUI TRUE CACHE BOOL "Determines whether QGIS GUI library (and everything built on top of it) should be built")

set (WITH_OAUTH2_PLUGIN TRUE CACHE BOOL "Build OAuth2 authentication method plugin")
if(WITH_OAUTH2_PLUGIN)
set(HAVE_OAUTH2_PLUGIN TRUE)
endif()

set (WITH_AUTH TRUE CACHE BOOL "Determines whether QGIS authentication methods should be built")

set (WITH_ANALYSIS TRUE CACHE BOOL "Determines whether QGIS analysis library should be built")
@@ -69,6 +69,8 @@

#cmakedefine HAVE_SERVER_PYTHON_PLUGINS

#cmakedefine HAVE_OAUTH2_PLUGIN

#cmakedefine HAVE_OPENCL
#cmakedefine OPENCL_USE_NEW_HEADER

@@ -151,6 +151,10 @@ if((${PYQT5_VERSION_STR} VERSION_EQUAL 5.15) OR (${PYQT5_VERSION_STR} VERSION_GR
set(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} VECTOR_MAPPED_TYPE)
endif()

if(NOT WITH_GUI)
set(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_GUI)
endif()

GENERATE_SIP_PYTHON_MODULE_CODE(qgis._core core/core.sip "${sip_files_core}" cpp_files)
BUILD_SIP_PYTHON_MODULE(qgis._core core/core.sip ${cpp_files} "" qgis_core)
set(SIP_CORE_CPP_FILES ${cpp_files})
@@ -218,12 +218,16 @@ Gets authentication method from the config/provider cache via its key
%End



%If (HAVE_GUI)

QWidget *authMethodEditWidget( const QString &authMethodKey, QWidget *parent );
%Docstring
Gets authentication method edit widget via its key

:param authMethodKey: Authentication method key
:param parent: Parent widget
%End
%End

QgsAuthMethod::Expansions supportedAuthMethodExpansions( const QString &authcfg );
@@ -10,7 +10,6 @@




class QgsAuthMethod : QObject
{
%Docstring(signature="appended")
@@ -55,6 +54,17 @@ Translatable display version of the ':py:func:`~QgsAuthMethod.description`'
Increment this if method is significantly updated, allow updater code to be written for previously stored authcfg
%End


%If (HAVE_GUI)

virtual QWidget *editWidget( QWidget *parent ) const;
%Docstring
Constructs the configuration for the authentication method

.. versionadded:: 3.22
%End
%End

QgsAuthMethod::Expansions supportedExpansions() const;
%Docstring
Flags that represent the update points (where authentication configurations are expanded)
@@ -99,6 +99,7 @@ done:
%Import QtWidgets/QtWidgetsmod.sip
%Import QtPositioning/QtPositioningmod.sip

%Feature HAVE_GUI
%Feature ANDROID
%Feature VECTOR_MAPPED_TYPE

@@ -18,7 +18,6 @@ add_subdirectory(identcert)
add_subdirectory(pkipaths)
add_subdirectory(pkipkcs12)

set(WITH_OAUTH2_PLUGIN TRUE CACHE BOOL "Build OAuth2 authentication method plugin")
if (WITH_OAUTH2_PLUGIN)
add_subdirectory(oauth2)
endif()
@@ -10,7 +10,6 @@ set(AUTH_BASIC_UIS_H "")

if (WITH_GUI)
set(AUTH_BASIC_SRCS ${AUTH_BASIC_SRCS}
gui/qgsauthbasicmethodgui.cpp
gui/qgsauthbasicedit.cpp
)
set(AUTH_BASIC_HDRS ${AUTH_BASIC_HDRS}
@@ -20,28 +19,55 @@ if (WITH_GUI)
QT5_WRAP_UI(AUTH_BASIC_UIS_H ${AUTH_BASIC_UIS})
endif()

add_library(authmethod_basic MODULE ${AUTH_BASIC_SRCS} ${AUTH_BASIC_HDRS} ${AUTH_BASIC_UIS_H})

target_include_directories(authmethod_basic PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/core
)
# static library
add_library(authmethod_basic_a STATIC ${AUTH_BASIC_SRCS} ${AUTH_BASIC_HDRS} ${AUTH_BASIC_UIS_H})

target_include_directories(authmethod_basic_a PUBLIC ${CMAKE_SOURCE_DIR}/src/auth/basic/core)

# require c++17
target_compile_features(authmethod_basic PRIVATE cxx_std_17)
target_compile_features(authmethod_basic_a PRIVATE cxx_std_17)

target_link_libraries(authmethod_basic qgis_core)
target_link_libraries(authmethod_basic_a qgis_core)

if (WITH_GUI)
target_include_directories(authmethod_basic PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/gui
${CMAKE_CURRENT_BINARY_DIR}
target_include_directories(authmethod_basic_a PRIVATE
${CMAKE_SOURCE_DIR}/src/auth/basic/gui
${CMAKE_BINARY_DIR}/src/auth/basic
)
target_link_libraries(authmethod_basic qgis_gui)

target_link_libraries (authmethod_basic_a qgis_gui)
endif()

target_compile_definitions(authmethod_basic PRIVATE "-DQT_NO_FOREACH")
target_compile_definitions(authmethod_basic_a PRIVATE "-DQT_NO_FOREACH")

install(TARGETS authmethod_basic
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}
)


if (FORCE_STATIC_LIBS)
# for (external) mobile apps to be able to pick up provider for linking
install (TARGETS authmethod_basic_a ARCHIVE DESTINATION ${QGIS_PLUGIN_DIR})
else()
# dynamically loaded module
add_library(authmethod_basic MODULE ${AUTH_BASIC_SRCS} ${AUTH_BASIC_HDRS} ${AUTH_BASIC_UIS_H})

# require c++17
target_compile_features(authmethod_basic PRIVATE cxx_std_17)

target_link_libraries(authmethod_basic qgis_core)

if (WITH_GUI)
target_include_directories(authmethod_basic PRIVATE
${CMAKE_SOURCE_DIR}/src/auth/basic/gui
${CMAKE_BINARY_DIR}/src/auth/basic
)
target_link_libraries (authmethod_basic qgis_gui)
add_dependencies(authmethod_basic ui)
endif()

target_compile_definitions(authmethod_basic PRIVATE "-DQT_NO_FOREACH")

install (TARGETS authmethod_basic
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}
)
endif()
@@ -20,12 +20,17 @@
#include "qgslogger.h"
#include "qgsapplication.h"

#ifdef HAVE_GUI
#include "qgsauthbasicedit.h"
#endif

#include <QNetworkProxy>
#include <QMutexLocker>
#include <QUuid>

static const QString AUTH_METHOD_KEY = QStringLiteral( "Basic" );
static const QString AUTH_METHOD_DESCRIPTION = QStringLiteral( "Basic authentication" );
const QString QgsAuthBasicMethod::AUTH_METHOD_KEY = QStringLiteral( "Basic" );
const QString QgsAuthBasicMethod::AUTH_METHOD_DESCRIPTION = QStringLiteral( "Basic authentication" );
const QString QgsAuthBasicMethod::AUTH_METHOD_DISPLAY_DESCRIPTION = tr( "Basic authentication" );

QMap<QString, QgsAuthMethodConfig> QgsAuthBasicMethod::sAuthConfigCache = QMap<QString, QgsAuthMethodConfig>();

@@ -60,9 +65,10 @@ QString QgsAuthBasicMethod::description() const

QString QgsAuthBasicMethod::displayDescription() const
{
return tr( "Basic authentication" );
return AUTH_METHOD_DISPLAY_DESCRIPTION;
}


bool QgsAuthBasicMethod::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg,
const QString &dataprovider )
{
@@ -313,6 +319,13 @@ void QgsAuthBasicMethod::updateMethodConfig( QgsAuthMethodConfig &mconfig )
// TODO: add updates as method version() increases due to config storage changes
}

#ifdef HAVE_GUI
QWidget *QgsAuthBasicMethod::editWidget( QWidget *parent ) const
{
return new QgsAuthBasicEdit( parent );
}
#endif

void QgsAuthBasicMethod::clearCachedConfig( const QString &authcfg )
{
removeMethodConfig( authcfg );
@@ -375,42 +388,13 @@ QString QgsAuthBasicMethod::escapeUserPass( const QString &val, QChar delim ) co
// Plugin externals
//////////////////////////////////////////////

/**
* Required class factory to return a pointer to a newly created object
*/
QGISEXTERN QgsAuthBasicMethod *classFactory()
{
return new QgsAuthBasicMethod();
}

/**
* Required key function (used to map the plugin to a data store type)
*/
QGISEXTERN QString authMethodKey()
#ifndef HAVE_STATIC_PROVIDERS
QGISEXTERN QgsAuthMethodMetadata *authMethodMetadataFactory()
{
return AUTH_METHOD_KEY;
return new QgsAuthBasicMethodMetadata();
}
#endif

/**
* Required description function
*/
QGISEXTERN QString description()
{
return AUTH_METHOD_DESCRIPTION;
}

/**
* Required isAuthMethod function. Used to determine if this shared library
* is an authentication method plugin
*/
QGISEXTERN bool isAuthMethod()
{
return true;
}

/**
* Required cleanup function
*/
QGISEXTERN void cleanupAuthMethod() // pass QgsAuthMethod *method, then delete method ?
{
}
@@ -22,13 +22,20 @@

#include "qgsauthconfig.h"
#include "qgsauthmethod.h"
#include "qgsauthmethodmetadata.h"

class QWidget;

class QgsAuthBasicMethod : public QgsAuthMethod
{
Q_OBJECT

public:

static const QString AUTH_METHOD_KEY;
static const QString AUTH_METHOD_DESCRIPTION;
static const QString AUTH_METHOD_DISPLAY_DESCRIPTION;

explicit QgsAuthBasicMethod();

// QgsAuthMethod interface
@@ -52,6 +59,10 @@ class QgsAuthBasicMethod : public QgsAuthMethod

void updateMethodConfig( QgsAuthMethodConfig &mconfig ) override;

#ifdef HAVE_GUI
QWidget *editWidget( QWidget *parent )const override;
#endif

private:
QgsAuthMethodConfig getMethodConfig( const QString &authcfg, bool fullconfig = true );

@@ -62,7 +73,19 @@ class QgsAuthBasicMethod : public QgsAuthMethod
QString escapeUserPass( const QString &val, QChar delim = '\'' ) const;

static QMap<QString, QgsAuthMethodConfig> sAuthConfigCache;
};

class QgsAuthBasicMethodMetadata : public QgsAuthMethodMetadata
{
public:
QgsAuthBasicMethodMetadata()
: QgsAuthMethodMetadata( QgsAuthBasicMethod::AUTH_METHOD_KEY, QgsAuthBasicMethod::AUTH_METHOD_DESCRIPTION )
{}
QgsAuthBasicMethod *createAuthMethod() const override {return new QgsAuthBasicMethod;}
//QStringList supportedDataProviders() const override;
};




#endif // QGSAUTHBASICMETHOD_H

This file was deleted.

0 comments on commit 6cdbced

Please sign in to comment.