Skip to content
Permalink
Browse files

[auth] Allow capital letters in config ID

  • Loading branch information
dakcarto committed Sep 26, 2015
1 parent a72cec0 commit 2f8e6846ab83e4759b4dc37bbd298202880cf6a4
@@ -77,6 +77,10 @@ class QgsAuthManager : QObject

bool configIdUnique( const QString &id ) const;

bool hasConfigId( const QString &txt ) const;

QString configIdRegex() const;

QStringList configIds() const;


@@ -8198,7 +8198,7 @@ QgsVectorLayer* QgisApp::addVectorLayer( QString vectorLayerPath, QString baseNa

// if the layer needs authentication, ensure the master password is set
bool authok = true;
QRegExp rx( "authcfg=([a-z]|[0-9]){7}" );
QRegExp rx( "authcfg=([a-z]|[A-Z]|[0-9]){7}" );
if ( rx.indexIn( vectorLayerPath ) != -1 )
{
authok = false;
@@ -55,6 +55,8 @@ const QString QgsAuthManager::smAuthServersTable = "auth_servers";
const QString QgsAuthManager::smAuthAuthoritiesTable = "auth_authorities";
const QString QgsAuthManager::smAuthTrustTable = "auth_trust";
const QString QgsAuthManager::smAuthManTag = QObject::tr( "Authentication Manager" );
const QString QgsAuthManager::smAuthCfgRegex = "authcfg=([a-z]|[A-Z]|[0-9]){7}";


QgsAuthManager *QgsAuthManager::instance()
{
@@ -750,12 +752,18 @@ bool QgsAuthManager::configIdUnique( const QString& id ) const
return !configids.contains( id );
}

bool QgsAuthManager::hasConfigId( const QString &txt ) const
{
QRegExp rx( smAuthCfgRegex );
return rx.indexIn( txt ) != -1;
}

QgsAuthMethodConfigsMap QgsAuthManager::availableAuthMethodConfigs( const QString &dataprovider )
{
QStringList providerAuthMethodsKeys;
if ( !dataprovider.isEmpty() )
{
providerAuthMethodsKeys = authMethodsKeys( dataprovider );
providerAuthMethodsKeys = authMethodsKeys( dataprovider.toLower() );
}

QgsAuthMethodConfigsMap baseConfigs;
@@ -847,7 +855,7 @@ QString QgsAuthManager::configAuthMethodKey( const QString &authcfg ) const

QStringList QgsAuthManager::authMethodsKeys( const QString &dataprovider )
{
return authMethodsMap( dataprovider ).uniqueKeys();
return authMethodsMap( dataprovider.toLower() ).uniqueKeys();
}

QgsAuthMethod *QgsAuthManager::authMethod( const QString &authMethodKey )
@@ -1294,7 +1302,7 @@ bool QgsAuthManager::updateNetworkRequest( QNetworkRequest &request, const QStri
return false;
}

if ( !authmethod->updateNetworkRequest( request, authcfg, dataprovider ) )
if ( !authmethod->updateNetworkRequest( request, authcfg, dataprovider.toLower() ) )
{
authmethod->clearCachedConfig( authcfg );
return false;
@@ -1320,7 +1328,7 @@ bool QgsAuthManager::updateNetworkReply( QNetworkReply *reply, const QString& au
return false;
}

if ( !authmethod->updateNetworkReply( reply, authcfg, dataprovider ) )
if ( !authmethod->updateNetworkReply( reply, authcfg, dataprovider.toLower() ) )
{
authmethod->clearCachedConfig( authcfg );
return false;
@@ -1346,7 +1354,7 @@ bool QgsAuthManager::updateDataSourceUriItems( QStringList &connectionItems, con
return false;
}

if ( !authmethod->updateDataSourceUriItems( connectionItems, authcfg, dataprovider ) )
if ( !authmethod->updateDataSourceUriItems( connectionItems, authcfg, dataprovider.toLower() ) )
{
authmethod->clearCachedConfig( authcfg );
return false;
@@ -227,6 +227,15 @@ class CORE_EXPORT QgsAuthManager : public QObject
*/
bool configIdUnique( const QString &id ) const;

/**
* Return whether a string includes an authcfg ID token
* @param txt String to check
*/
bool hasConfigId( const QString &txt ) const;

/** Return regular expression for authcfg=.{7} key/value token for authentication ids */
QString configIdRegex() const { return smAuthCfgRegex;}

/** Get list of authentication ids from database */
QStringList configIds() const;

@@ -587,6 +596,7 @@ class CORE_EXPORT QgsAuthManager : public QObject
static const QString smAuthAuthoritiesTable;
static const QString smAuthTrustTable;
static const QString smAuthManTag;
static const QString smAuthCfgRegex;

bool mAuthInit;
QString mAuthDbPath;
@@ -184,7 +184,7 @@ bool QgsMapLayer::readLayerXML( const QDomElement& layerElement )
mDataSource = mne.text();

// if the layer needs authentication, ensure the master password is set
QRegExp rx( "authcfg=([a-z]|[0-9]){7}" );
QRegExp rx( "authcfg=([a-z]|[A-Z]|[0-9]){7}" );
if (( rx.indexIn( mDataSource ) != -1 )
&& !QgsAuthManager::instance()->setMasterPassword( true ) )
{

0 comments on commit 2f8e684

Please sign in to comment.
You can’t perform that action at this time.