Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add variable URLs for credentials files
  • Loading branch information
Bernd Wachter committed Oct 24, 2012
1 parent 268affd commit 77ccda8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions libssu/ssu.cpp
Expand Up @@ -126,6 +126,13 @@ QString Ssu::credentialsScope(QString repoName, bool rndRepo){
return "your-configuration-is-broken-and-does-not-contain-credentials-scope";
}

QString Ssu::credentialsUrl(QString scope){
if (settings->contains("credentials-url-" + scope))
return settings->value("credentials-url-" + scope).toString();
else
return "your-configuration-is-broken-and-does-not-contain-credentials-url-for-" + scope;
}

QString Ssu::deviceFamily(){
QString model = deviceModel();

Expand Down
4 changes: 4 additions & 0 deletions libssu/ssu.h
Expand Up @@ -36,6 +36,10 @@ class Ssu: public QObject {
* @return a string containing the scope; it can be used to look up login credentials using credentials()
*/
QString credentialsScope(QString repoName, bool rndRepo=false);
/**
* Return the URL for which credentials scope is valid
*/
QString credentialsUrl(QString scope);
/**
* Try to find the device family for the system this is running on
*/
Expand Down
1 change: 1 addition & 0 deletions ssu-defaults.ini
Expand Up @@ -14,3 +14,4 @@ credentials-scope=example

[2]
release=latest
credentials-url-example=https://example.com
2 changes: 1 addition & 1 deletion ssuurlresolver/ssuurlresolver.cpp
Expand Up @@ -84,7 +84,7 @@ void SsuUrlResolver::run(){
credentialsFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate);
QTextStream out(&credentialsFile);
QPair<QString, QString> credentials = ssu.credentials(credentialsScope);
out << "[ssu-credentials]\n";
out << "[" << ssu.credentialsUrl(credentialsScope) << "]\n";
out << "username=" << credentials.first << "\n";
out << "password=" << credentials.second << "\n";
out.flush();
Expand Down

0 comments on commit 77ccda8

Please sign in to comment.