Skip to content

Commit

Permalink
Allow defining url domains to be used with specific credentials.
Browse files Browse the repository at this point in the history
[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 <marko.saukko@jolla.com>
  • Loading branch information
saukko committed Sep 17, 2015
1 parent 53a40e2 commit beef0d9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libssu/ssu.cpp
Expand Up @@ -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,
Expand All @@ -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<QString, QString> secureDomainAuth;
SsuVariables::variableSection(&repoSettings, "secure-domain-auth", &secureDomainAuth);
QHashIterator<QString, QString> 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);
}

Expand Down

0 comments on commit beef0d9

Please sign in to comment.