Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[needs-docs] Allow users to set tokens for connections to ArcGIS Feat…
…ure/Map servers Without this it can be impossible to connect to authenticated/private servers. Tokens are set by creating an "ESRI token based authentication" method from the standard QGIS Authentication settings and associating with the connection.
- Loading branch information
1 parent
ffdf39e
commit ac0a188
Showing
20 changed files
with
567 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
SET(AUTH_ESRI_TOKEN_SRCS | ||
qgsauthesritokenmethod.cpp | ||
qgsauthesritokenedit.cpp | ||
) | ||
|
||
SET(AUTH_ESRI_TOKEN_HDRS | ||
qgsauthesritokenmethod.h | ||
qgsauthesritokenedit.h | ||
) | ||
|
||
SET(AUTH_ESRI_TOKEN_MOC_HDRS | ||
qgsauthesritokenmethod.h | ||
qgsauthesritokenedit.h | ||
) | ||
|
||
SET(AUTH_ESRI_TOKEN_UIS qgsauthesritokenedit.ui) | ||
|
||
INCLUDE_DIRECTORIES ( | ||
../../core | ||
../../core/auth | ||
../../core/geometry | ||
../../core/metadata | ||
${CMAKE_BINARY_DIR}/src/core | ||
${CMAKE_BINARY_DIR}/src/gui | ||
) | ||
INCLUDE_DIRECTORIES (SYSTEM | ||
${QCA_INCLUDE_DIR} | ||
${QTKEYCHAIN_INCLUDE_DIR} | ||
) | ||
INCLUDE_DIRECTORIES ( | ||
../../gui | ||
../../gui/auth | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
) | ||
|
||
QT5_WRAP_UI (AUTH_ESRI_TOKEN_UIS_H ${AUTH_ESRI_TOKEN_UIS}) | ||
|
||
QT5_WRAP_CPP(AUTH_ESRI_TOKEN_MOC_SRCS ${AUTH_ESRI_TOKEN_MOC_HDRS}) | ||
|
||
ADD_LIBRARY (esritokenauthmethod MODULE ${AUTH_ESRI_TOKEN_SRCS} ${AUTH_ESRI_TOKEN_HDRS} ${AUTH_ESRI_TOKEN_MOC_SRCS} ${AUTH_ESRI_TOKEN_UIS_H}) | ||
|
||
TARGET_LINK_LIBRARIES (esritokenauthmethod | ||
qgis_core | ||
qgis_gui | ||
) | ||
|
||
INSTALL(TARGETS esritokenauthmethod | ||
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR} | ||
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/*************************************************************************** | ||
qgsauthesritokenedit.cpp | ||
------------------------ | ||
begin : October 2018 | ||
copyright : (C) 2018 by Nyall Dawson | ||
author : Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsauthesritokenedit.h" | ||
#include "ui_qgsauthesritokenedit.h" | ||
|
||
|
||
QgsAuthEsriTokenEdit::QgsAuthEsriTokenEdit( QWidget *parent ) | ||
: QgsAuthMethodEdit( parent ) | ||
{ | ||
setupUi( this ); | ||
connect( mTokenEdit, &QPlainTextEdit::textChanged, this, &QgsAuthEsriTokenEdit::tokenChanged ); | ||
} | ||
|
||
bool QgsAuthEsriTokenEdit::validateConfig() | ||
{ | ||
bool curvalid = !mTokenEdit->toPlainText().isEmpty(); | ||
if ( mValid != curvalid ) | ||
{ | ||
mValid = curvalid; | ||
emit validityChanged( curvalid ); | ||
} | ||
return curvalid; | ||
} | ||
|
||
QgsStringMap QgsAuthEsriTokenEdit::configMap() const | ||
{ | ||
QgsStringMap config; | ||
config.insert( QStringLiteral( "token" ), mTokenEdit->toPlainText() ); | ||
|
||
return config; | ||
} | ||
|
||
void QgsAuthEsriTokenEdit::loadConfig( const QgsStringMap &configmap ) | ||
{ | ||
clearConfig(); | ||
|
||
mConfigMap = configmap; | ||
mTokenEdit->setPlainText( configmap.value( QStringLiteral( "token" ) ) ); | ||
|
||
validateConfig(); | ||
} | ||
|
||
void QgsAuthEsriTokenEdit::resetConfig() | ||
{ | ||
loadConfig( mConfigMap ); | ||
} | ||
|
||
void QgsAuthEsriTokenEdit::clearConfig() | ||
{ | ||
mTokenEdit->clear(); | ||
} | ||
|
||
void QgsAuthEsriTokenEdit::tokenChanged() | ||
{ | ||
validateConfig(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*************************************************************************** | ||
qgsauthesritokenedit.h | ||
--------------------- | ||
begin : October 2018 | ||
copyright : (C) 2018 by Nyall Dawson | ||
author : Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSAUTHESRITOKENEDIT_H | ||
#define QGSAUTHESRITOKENEDIT_H | ||
|
||
#include <QWidget> | ||
#include "qgsauthmethodedit.h" | ||
#include "ui_qgsauthesritokenedit.h" | ||
|
||
#include "qgsauthconfig.h" | ||
|
||
|
||
class QgsAuthEsriTokenEdit : public QgsAuthMethodEdit, private Ui::QgsAuthEsriTokenEdit | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit QgsAuthEsriTokenEdit( QWidget *parent = nullptr ); | ||
|
||
bool validateConfig() override; | ||
|
||
QgsStringMap configMap() const override; | ||
|
||
public slots: | ||
void loadConfig( const QgsStringMap &configmap ) override; | ||
|
||
void resetConfig() override; | ||
|
||
void clearConfig() override; | ||
|
||
private slots: | ||
void tokenChanged(); | ||
|
||
private: | ||
QgsStringMap mConfigMap; | ||
bool mValid = false; | ||
}; | ||
|
||
#endif // QGSAUTHESRITOKENEDIT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>QgsAuthEsriTokenEdit</class> | ||
<widget class="QWidget" name="QgsAuthEsriTokenEdit"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>300</height> | ||
</rect> | ||
</property> | ||
<layout class="QGridLayout" name="gridLayout"> | ||
<property name="leftMargin"> | ||
<number>6</number> | ||
</property> | ||
<property name="topMargin"> | ||
<number>6</number> | ||
</property> | ||
<property name="rightMargin"> | ||
<number>6</number> | ||
</property> | ||
<property name="bottomMargin"> | ||
<number>6</number> | ||
</property> | ||
<item row="1" column="0"> | ||
<widget class="QLabel" name="lblToken"> | ||
<property name="text"> | ||
<string>Token</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="2" column="0"> | ||
<spacer name="verticalSpacer_2"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>173</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item row="1" column="1" rowspan="2"> | ||
<widget class="QPlainTextEdit" name="mTokenEdit"> | ||
<property name="placeholderText"> | ||
<string>Required</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
Oops, something went wrong.