From beef0d928aa3093ab5715f5a94059484333d75fc Mon Sep 17 00:00:00 2001 From: Marko Saukko Date: Wed, 16 Sep 2015 20:26:06 +0000 Subject: [PATCH] Allow defining url domains to be used with specific credentials. [ssu] Allow defining url domain to be used with specific credentials. Fixes JB#32346 Previously store-auth-repos could be only defined in repos.ini and each new feature would need to add new line to that variable. This patch allows repos.ini to define url domain,credential pairs that can be used to say which credential is used when certain url domain is used. This removes the need to touch repos.ini when bringing in new feature. Signed-off-by: Marko Saukko --- libssu/ssu.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libssu/ssu.cpp b/libssu/ssu.cpp index 93c7491..cb1ece5 100644 --- a/libssu/ssu.cpp +++ b/libssu/ssu.cpp @@ -98,6 +98,7 @@ QString Ssu::credentialsScope(QString repoName, bool rndRepo){ SsuVariables::variable(&repoSettings, domain() + "-domain", storeAuthReposKey).toStringList(); + if (storeAuthRepos.empty()) storeAuthRepos = SsuVariables::variable(&repoSettings, @@ -107,6 +108,18 @@ QString Ssu::credentialsScope(QString repoName, bool rndRepo){ if (storeAuthRepos.contains(repoName)) return "store"; + // If we defined explicitly what credentials to use with which secure domain + // use those. + QHash secureDomainAuth; + SsuVariables::variableSection(&repoSettings, "secure-domain-auth", &secureDomainAuth); + QHashIterator i(secureDomainAuth); + while (i.hasNext()) { + i.next(); + if (repoUrl(repoName, rndRepo).contains(i.key()) && !i.value().isEmpty()) { + return i.value(); + } + } + return settings->credentialsScope(repoName, rndRepo); }