Skip to content
Permalink
Browse files
Merge pull request #4355 from boundlessgeo/password-helper-authmanager3
[feature][needs-docs] Master Password integration with OS password manager
  • Loading branch information
elpaso committed Apr 12, 2017
2 parents da5c0ed + 090d530 commit c9f0509841c565a3540c06f7665573461eede8c9
@@ -278,6 +278,8 @@ ENDIF (WITH_QTMOBILITY)
# search for QScintilla2 (C++ lib)
FIND_PACKAGE(QScintilla REQUIRED)

# Password helper
FIND_PACKAGE(QtKeychain REQUIRED)
# Master password hash and authentication encryption
FIND_PACKAGE(QCA REQUIRED)
# Check for runtime dependency of qca-ossl plugin
@@ -22,7 +22,7 @@
pushd ${HOME}

# fetching data from github should be just as fast as S3
curl -s -S -L https://github.com/opengisch/osgeo4travis/archive/qt5bin.tar.gz | tar --strip-components=1 -xz -C /home/travis &
curl -s -S -L https://github.com/opengisch/osgeo4travis/archive/qt55bin.tar.gz | tar --strip-components=1 -xz -C /home/travis &
SETUP_OSGEO4W_PID=$!

mkdir /home/travis/osgeo4travis
@@ -0,0 +1,51 @@
# Find QtKeychain
# ~~~~~~~~~~~~~~~
# Copyright (c) 2016, Boundless Spatial
# Author: Larry Shaffer <lshaffer (at) boundlessgeo (dot) com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# CMake module to search for QtKeychain library from:
# https://github.com/frankosterfeld/qtkeychain
#
# If it's found it sets QTKEYCHAIN_FOUND to TRUE
# and following variables are set:
# QTKEYCHAIN_INCLUDE_DIR
# QTKEYCHAIN_LIBRARY

FIND_PATH(QTKEYCHAIN_INCLUDE_DIR keychain.h
PATHS
${LIB_DIR}/include
"$ENV{LIB_DIR}/include"
$ENV{INCLUDE}
/usr/local/include
/usr/include
PATH_SUFFIXES qt5keychain qtkeychain
)

FIND_LIBRARY(QTKEYCHAIN_LIBRARY NAMES qt5keychain qtkeychain
PATHS
${LIB_DIR}
"$ENV{LIB_DIR}"
$ENV{LIB}
/usr/local/lib
/usr/lib
)


IF (QTKEYCHAIN_INCLUDE_DIR AND QTKEYCHAIN_LIBRARY)
SET(QTKEYCHAIN_FOUND TRUE)
ELSE()
SET(QTKEYCHAIN_FOUND FALSE)
ENDIF (QTKEYCHAIN_INCLUDE_DIR AND QTKEYCHAIN_LIBRARY)

IF (QTKEYCHAIN_FOUND)
IF (NOT QTKEYCHAIN_FIND_QUIETLY)
MESSAGE(STATUS "Found QtKeychain: ${QTKEYCHAIN_LIBRARY}")
ENDIF (NOT QTKEYCHAIN_FIND_QUIETLY)
ELSE (QTKEYCHAIN_FOUND)
IF (QTKEYCHAIN_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find QtKeychain")
ENDIF (QTKEYCHAIN_FIND_REQUIRED)
ENDIF (QTKEYCHAIN_FOUND)
@@ -89,6 +89,7 @@ INCLUDE_DIRECTORIES(SYSTEM
${QEXTSERIALPORT_INCLUDE_DIR}
${QSCINTILLA_INCLUDE_DIR}
${QCA_INCLUDE_DIR}
${QTKEYCHAIN_INCLUDE_DIR}
${SQLITE3_INCLUDE_DIR}
)
INCLUDE_DIRECTORIES(
@@ -442,14 +442,36 @@ class QgsAuthManager : QObject
QMutex *mutex();

signals:

/**
* Signals emitted on password helper failure,
* mainly used in the tests to exit main application loop
*/
void passwordHelperFailure();

/**
* Signals emitted on password helper success,
* mainly used in the tests to exit main application loop
*/
void passwordHelperSuccess();

/**
* Custom logging signal to relay to console output and QgsMessageLog
* @see QgsMessageLog
* @param message Message to send
* @param tag Associated tag (title)
* @param level Message log level
*/
void messageOut( const QString& message, const QString& tag, QgsAuthManager::MessageLevel level = INFO ) const;
void messageOut( const QString& message, const QString& tag = QgsAuthManager::AUTH_MAN_TAG, QgsAuthManager::MessageLevel level = INFO ) const;

/**
* Custom logging signal to inform the user about master password <-> password manager interactions
* @see QgsMessageLog
* @param message Message to send
* @param tag Associated tag (title)
* @param level Message log level
*/
void passwordHelperMessageOut( const QString &message, const QString &tag = QgsAuthManager::AUTH_MAN_TAG, QgsAuthManager::MessageLevel level = INFO ) const;

/**
* Emitted when a password has been verify (or not)
@@ -578,6 +578,7 @@ INCLUDE_DIRECTORIES(SYSTEM
${GDAL_INCLUDE_DIR}
${QWTPOLAR_INCLUDE_DIR}
${QCA_INCLUDE_DIR}
${QTKEYCHAIN_INCLUDE_DIR}
)

IF(ENABLE_MODELTEST)
@@ -12254,6 +12254,8 @@ void QgisApp::masterPasswordSetup()
{
connect( QgsAuthManager::instance(), &QgsAuthManager::messageOut,
this, &QgisApp::authMessageOut );
connect( QgsAuthManager::instance(), &QgsAuthManager::passwordHelperMessageOut,
this, &QgisApp::authMessageOut );
connect( QgsAuthManager::instance(), &QgsAuthManager::authDatabaseEraseRequested,
this, &QgisApp::eraseAuthenticationDatabase );
}
@@ -12289,12 +12291,17 @@ void QgisApp::eraseAuthenticationDatabase()

void QgisApp::authMessageOut( const QString &message, const QString &authtag, QgsAuthManager::MessageLevel level )
{
// only if main window is active window
// Use system notifications if the main window is not the active one,
// push message to the message bar if the main window is active
if ( qApp->activeWindow() != this )
return;

int levelint = static_cast< int >( level );
messageBar()->pushMessage( authtag, message, static_cast< QgsMessageBar::MessageLevel >( levelint ), 7 );
{
showSystemNotification( tr( "QGIS Authentication" ), message );
}
else
{
int levelint = static_cast< int >( level );
messageBar()->pushMessage( authtag, message, static_cast< QgsMessageBar::MessageLevel >( levelint ), 7 );
}
}

void QgisApp::completeInitialization()
@@ -24,6 +24,7 @@ INCLUDE_DIRECTORIES (
)
INCLUDE_DIRECTORIES (SYSTEM
${QCA_INCLUDE_DIR}
${QTKEYCHAIN_INCLUDE_DIR}
)
INCLUDE_DIRECTORIES (
../../gui
@@ -24,6 +24,7 @@ INCLUDE_DIRECTORIES (
)
INCLUDE_DIRECTORIES (SYSTEM
${QCA_INCLUDE_DIR}
${QTKEYCHAIN_INCLUDE_DIR}
)
INCLUDE_DIRECTORIES (
../../gui
@@ -24,6 +24,7 @@ INCLUDE_DIRECTORIES (
)
INCLUDE_DIRECTORIES (SYSTEM
${QCA_INCLUDE_DIR}
${QTKEYCHAIN_INCLUDE_DIR}
)
INCLUDE_DIRECTORIES (
../../gui
@@ -24,6 +24,7 @@ INCLUDE_DIRECTORIES (
)
INCLUDE_DIRECTORIES (SYSTEM
${QCA_INCLUDE_DIR}
${QTKEYCHAIN_INCLUDE_DIR}
)
INCLUDE_DIRECTORIES (
../../gui
@@ -982,6 +982,7 @@ INCLUDE_DIRECTORIES(SYSTEM
${SQLITE3_INCLUDE_DIR}
${SPATIALITE_INCLUDE_DIR}
${QCA_INCLUDE_DIR}
${QTKEYCHAIN_INCLUDE_DIR}
)

#for PAL classes
@@ -1073,7 +1074,7 @@ TARGET_LINK_LIBRARIES(qgis_core
${OPTIONAL_QTWEBKIT}
${QT_QTSQL_LIBRARY}
${QCA_LIBRARY}

${QTKEYCHAIN_LIBRARY}
${PROJ_LIBRARY}
${GEOS_LIBRARY}
${GDAL_LIBRARY}
Loading

0 comments on commit c9f0509

Please sign in to comment.