[Pkg-owncloud-commits] [owncloud-client] 195/333: Token Credentials: Support actual tokens

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Apr 17 23:16:52 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit ff95e233bc62c4eb1d1cffeb2cf7579d26f83206
Author: Markus Goetz <markus at woboq.com>
Date:   Fri Mar 21 17:12:26 2014 +0100

    Token Credentials: Support actual tokens
---
 src/creds/tokencredentials.cpp | 25 ++++++-------------------
 src/creds/tokencredentials.h   |  5 ++++-
 2 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/src/creds/tokencredentials.cpp b/src/creds/tokencredentials.cpp
index 52a891e..fe3cf45 100644
--- a/src/creds/tokencredentials.cpp
+++ b/src/creds/tokencredentials.cpp
@@ -75,6 +75,7 @@ const char userC[] = "user";
 
 class TokenCredentialsAccessManager : public MirallAccessManager {
 public:
+    friend class TokenCredentials;
     TokenCredentialsAccessManager(const TokenCredentials *cred, QObject* parent = 0)
         : MirallAccessManager(parent), _cred(cred) {}
 protected:
@@ -83,6 +84,7 @@ protected:
         QNetworkRequest req(request);
         req.setRawHeader(QByteArray("Authorization"), QByteArray("Basic ") + credHash);
         //qDebug() << "Request for " << req.url() << "with authorization" << QByteArray::fromBase64(credHash);
+        req.setRawHeader(QByteArray("Cookie"), _cred->_token.toLocal8Bit());
         return MirallAccessManager::createRequest(op, req, outgoingData);
     }
 private:
@@ -96,9 +98,10 @@ TokenCredentials::TokenCredentials()
 {
 }
 
-TokenCredentials::TokenCredentials(const QString& user, const QString& password)
+TokenCredentials::TokenCredentials(const QString& user, const QString& password, const QString &token)
     : _user(user),
       _password(password),
+      _token(token),
       _ready(true)
 {
 }
@@ -110,23 +113,7 @@ void TokenCredentials::syncContextPreInit (CSYNC* ctx)
 
 void TokenCredentials::syncContextPreStart (CSYNC* ctx)
 {
-    // TODO: This should not be a part of this method, but we don't have
-    // any way to get "session_key" module property from csync. Had we
-    // have it, then we could remove this code and keep it in
-    // csyncthread code (or folder code, git remembers).
-    QList<QNetworkCookie> cookies(AccountManager::instance()->account()->lastAuthCookies());
-    QString cookiesAsString;
-
-    // Stuff cookies inside csync, then we can avoid the intermediate HTTP 401 reply
-    // when https://github.com/owncloud/core/pull/4042 is merged.
-    foreach(QNetworkCookie c, cookies) {
-        cookiesAsString += c.name();
-        cookiesAsString += '=';
-        cookiesAsString += c.value();
-        cookiesAsString += "; ";
-    }
-
-    csync_set_module_property(ctx, "session_key", cookiesAsString.toLatin1().data());
+    csync_set_module_property(ctx, "session_key", _token.toLocal8Bit().data());
 }
 
 bool TokenCredentials::changed(AbstractCredentials* credentials) const
@@ -142,7 +129,7 @@ bool TokenCredentials::changed(AbstractCredentials* credentials) const
 
 QString TokenCredentials::authType() const
 {
-    return QString::fromLatin1("http");
+    return QString::fromLatin1("token");
 }
 
 QString TokenCredentials::user() const
diff --git a/src/creds/tokencredentials.h b/src/creds/tokencredentials.h
index c2a272f..8b83711 100644
--- a/src/creds/tokencredentials.h
+++ b/src/creds/tokencredentials.h
@@ -30,13 +30,15 @@ class Job;
 namespace Mirall
 {
 
+class TokenCredentialsAccessManager;
 class TokenCredentials : public AbstractCredentials
 {
     Q_OBJECT
 
 public:
+    friend class TokenCredentialsAccessManager;
     TokenCredentials();
-    TokenCredentials(const QString& user, const QString& password);
+    TokenCredentials(const QString& user, const QString& password, const QString &token);
 
     void syncContextPreInit(CSYNC* ctx);
     void syncContextPreStart(CSYNC* ctx);
@@ -59,6 +61,7 @@ private Q_SLOTS:
 private:
     QString _user;
     QString _password;
+    QString _token;
     bool _ready;
 };
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list