Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[ssu] Use store credentials for repos listed in store-auth-repos
  • Loading branch information
Bernd Wachter committed Nov 8, 2013
1 parent a14084d commit 4b4afe9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
19 changes: 19 additions & 0 deletions libssu/ssu.cpp
Expand Up @@ -79,11 +79,30 @@ QPair<QString, QString> Ssu::credentials(QString scope){

QString Ssu::credentialsScope(QString repoName, bool rndRepo){
SsuCoreConfig *settings = SsuCoreConfig::instance();
SsuSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);

// hardcoded magic for doing special privileges store repositories
if (repoName == "store" || repoName.startsWith("store-c-"))
return "store";

// check if some repos are marked for using store-credentials
// in current domain, checking first for rnd/release specific
// settings, and if not found in generic settings
QString storeAuthReposKey = QString("store-auth-repos-%1")
.arg(rndRepo ? "rnd" : "release");
QStringList storeAuthRepos =
SsuVariables::variable(&repoSettings,
domain() + "-domain",
storeAuthReposKey).toStringList();
if (storeAuthRepos.empty())
storeAuthRepos =
SsuVariables::variable(&repoSettings,
domain() + "-domain",
"store-auth-repos").toStringList();

if (storeAuthRepos.contains(repoName))
return "store";

return settings->credentialsScope(repoName, rndRepo);
}

Expand Down
15 changes: 9 additions & 6 deletions ssuurlresolver/ssuurlresolver.cpp
Expand Up @@ -125,12 +125,6 @@ void SsuUrlResolver::run(){
} else
ssuLog->print(LOG_DEBUG, "Device not registered -- skipping credential update");

if (repo == "store" || repo.startsWith("store-c-")){
ssu.updateStoreCredentials();
if (ssu.error())
error (ssu.lastError());
}

// resolve base url
resolvedUrl = ssu.repoUrl(repo, isRnd, repoParameters);

Expand All @@ -141,6 +135,15 @@ void SsuUrlResolver::run(){
ssuLog->print(LOG_DEBUG, QString("Requesting credentials for '%1' with RND status %2...").arg(repo).arg(isRnd));
QString credentialsScope = ssu.credentialsScope(repo, isRnd);
if (!credentialsScope.isEmpty()){
// personal store repositories as well as the ones listed in the
// store-auth-repos domain setting use store credentials. Refresh
// here, as we only know after checking scope if we need to have
// store credentials at all
if (credentialsScope == "store"){
ssu.updateStoreCredentials();
if (ssu.error())
error (ssu.lastError());
}
headerList.append(QString("credentials=%1").arg(credentialsScope));
writeZyppCredentialsIfNeeded(credentialsScope);
} else
Expand Down

0 comments on commit 4b4afe9

Please sign in to comment.