[SCM] ktp-auth-handler packaging branch, master, updated. debian/0.7.0-1-78-g049f635
Maximiliano Curia
maxy at moszumanska.debian.org
Wed Jan 27 19:56:05 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-auth-handler.git;a=commitdiff;h=9833a6d
The following commit has been merged in the master branch:
commit 9833a6d9fc98d874a705a8a850f2b2a0758fe311
Author: Diane Trout <diane at ghic.org>
Date: Sun Aug 9 14:29:52 2015 -0700
Imported Upstream version 15.07.90
---
CMakeLists.txt | 7 ++-
sasl-auth-op.cpp | 39 ++++++------
sasl-auth-op.h | 3 +-
x-telepathy-password-auth-operation.cpp | 25 +++-----
x-telepathy-password-auth-operation.h | 3 +-
x-telepathy-sso-facebook-operation.cpp | 102 --------------------------------
x-telepathy-sso-facebook-operation.h | 56 ------------------
x-telepathy-sso-google-operation.cpp | 14 ++++-
x-telepathy-sso-google-operation.h | 4 +-
9 files changed, 50 insertions(+), 203 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e73218a..412f795 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,10 @@
project(ktp-auth-handler)
-set(KTP_AUTH_HANDLER_VERSION "15.04.2")
+# KDE Application Version, managed by release script
+set(KDE_APPLICATIONS_VERSION_MAJOR "15")
+set(KDE_APPLICATIONS_VERSION_MINOR "07")
+set(KDE_APPLICATIONS_VERSION_MICRO "90")
+set(KTP_AUTH_HANDLER_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}")
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
@@ -62,7 +66,6 @@ set(ktp_auth_handler_SRCS
types.cpp
x-telepathy-password-auth-operation.cpp
x-telepathy-password-prompt.cpp
- x-telepathy-sso-facebook-operation.cpp
x-telepathy-sso-google-operation.cpp
conference-auth-op.cpp
conference-auth-observer.cpp
diff --git a/sasl-auth-op.cpp b/sasl-auth-op.cpp
index dd42daa..7b465a8 100644
--- a/sasl-auth-op.cpp
+++ b/sasl-auth-op.cpp
@@ -21,7 +21,6 @@
#include "sasl-auth-op.h"
#include "x-telepathy-password-auth-operation.h"
-#include "x-telepathy-sso-facebook-operation.h"
#include "x-telepathy-sso-google-operation.h"
#include <QtCore/QScopedPointer>
@@ -38,11 +37,13 @@ SaslAuthOp::SaslAuthOp(const Tp::AccountPtr &account,
m_channel(channel),
m_saslIface(channel->interface<Tp::Client::ChannelInterfaceSASLAuthenticationInterface>())
{
- KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("kaccounts-ktprc"));
- KConfigGroup ktpKaccountsGroup = config->group(QStringLiteral("ktp-kaccounts"));
- m_kaccountsId = ktpKaccountsGroup.readEntry(account->objectPath()).toUInt();
+ //Check if the account has any StorageIdentifier, in which case we will
+ //prioritize those mechanism related with KDE Accounts integration
+ QScopedPointer<Tp::Client::AccountInterfaceStorageInterface> accountStorageInterface(
+ new Tp::Client::AccountInterfaceStorageInterface(m_account->busName(), m_account->objectPath()));
- setReady();
+ Tp::PendingVariantMap *pendingMap = accountStorageInterface->requestAllProperties();
+ connect(pendingMap, SIGNAL(finished(Tp::PendingOperation*)), SLOT(onGetAccountStorageFetched(Tp::PendingOperation*)));
}
SaslAuthOp::~SaslAuthOp()
@@ -67,17 +68,9 @@ void SaslAuthOp::gotProperties(Tp::PendingOperation *op)
QString error = qdbus_cast<QString>(props.value(QLatin1String("SASLError")));
QVariantMap errorDetails = qdbus_cast<QVariantMap>(props.value(QLatin1String("SASLErrorDetails")));
- if (mechanisms.contains(QLatin1String("X-FACEBOOK-PLATFORM")) && m_kaccountsId != 0) {
- qDebug() << "Starting Facebook OAuth auth";
- XTelepathySSOFacebookOperation *authop = new XTelepathySSOFacebookOperation(m_account, m_kaccountsId, m_saslIface);
- connect(authop,
- SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(onAuthOperationFinished(Tp::PendingOperation*)));
-
- authop->onSASLStatusChanged(status, error, errorDetails);
- } else if (mechanisms.contains(QLatin1String("X-OAUTH2")) && m_kaccountsId != 0) {
+ if (mechanisms.contains(QLatin1String("X-OAUTH2"))) {
qDebug() << "Starting X-OAuth2 auth";
- XTelepathySSOGoogleOperation *authop = new XTelepathySSOGoogleOperation(m_account, m_kaccountsId, m_saslIface);
+ XTelepathySSOGoogleOperation *authop = new XTelepathySSOGoogleOperation(m_account, m_accountStorageId, m_saslIface);
connect(authop,
SIGNAL(finished(Tp::PendingOperation*)),
SLOT(onAuthOperationFinished(Tp::PendingOperation*)));
@@ -86,17 +79,17 @@ void SaslAuthOp::gotProperties(Tp::PendingOperation *op)
} else if (mechanisms.contains(QLatin1String("X-TELEPATHY-PASSWORD"))) {
qDebug() << "Starting Password auth";
Q_EMIT ready(this);
- XTelepathyPasswordAuthOperation *authop = new XTelepathyPasswordAuthOperation(m_account, m_saslIface, qdbus_cast<bool>(props.value(QLatin1String("CanTryAgain"))));
+ XTelepathyPasswordAuthOperation *authop = new XTelepathyPasswordAuthOperation(m_account, m_accountStorageId, m_saslIface, qdbus_cast<bool>(props.value(QLatin1String("CanTryAgain"))));
connect(authop,
SIGNAL(finished(Tp::PendingOperation*)),
SLOT(onAuthOperationFinished(Tp::PendingOperation*)));
authop->onSASLStatusChanged(status, error, errorDetails);
} else {
- qWarning() << "X-TELEPATHY-PASSWORD, X-OAUTH2, X-FACEBOOK_PLATFORM are the only supported SASL mechanism and are not available:" << mechanisms;
+ qWarning() << "X-TELEPATHY-PASSWORD, X-OAUTH2 are the only supported SASL mechanism and are not available:" << mechanisms;
m_channel->requestClose();
setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED,
- QLatin1String("X-TELEPATHY-PASSWORD, X-OAUTH2, X-FACEBOOK_PLATFORM are the only supported SASL mechanism and are not available:"));
+ QLatin1String("X-TELEPATHY-PASSWORD, X-OAUTH2 are the only supported SASL mechanism and are not available:"));
return;
}
}
@@ -117,3 +110,13 @@ void SaslAuthOp::setReady()
SIGNAL(finished(Tp::PendingOperation*)),
SLOT(gotProperties(Tp::PendingOperation*)));
}
+
+void SaslAuthOp::onGetAccountStorageFetched(Tp::PendingOperation* op)
+{
+ Tp::PendingVariantMap *pendingMap = qobject_cast<Tp::PendingVariantMap*>(op);
+
+ m_accountStorageId = pendingMap->result()["StorageIdentifier"].value<QDBusVariant>().variant().toInt();
+ qDebug() << m_accountStorageId;
+
+ setReady();
+}
diff --git a/sasl-auth-op.h b/sasl-auth-op.h
index 182fe04..0e88465 100644
--- a/sasl-auth-op.h
+++ b/sasl-auth-op.h
@@ -44,6 +44,7 @@ Q_SIGNALS:
private Q_SLOTS:
void gotProperties(Tp::PendingOperation *op);
void onAuthOperationFinished(Tp::PendingOperation *op);
+ void onGetAccountStorageFetched(Tp::PendingOperation *op);
private:
void setReady();
@@ -51,7 +52,7 @@ private:
Tp::AccountPtr m_account;
Tp::ChannelPtr m_channel;
Tp::Client::ChannelInterfaceSASLAuthenticationInterface *m_saslIface;
- quint32 m_kaccountsId;
+ int m_accountStorageId;
};
#endif // SASL_AUTH_OP_H
diff --git a/x-telepathy-password-auth-operation.cpp b/x-telepathy-password-auth-operation.cpp
index 0d58578..be0ed99 100644
--- a/x-telepathy-password-auth-operation.cpp
+++ b/x-telepathy-password-auth-operation.cpp
@@ -39,13 +39,15 @@
XTelepathyPasswordAuthOperation::XTelepathyPasswordAuthOperation(
const Tp::AccountPtr &account,
+ int accountStorageId,
Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface,
bool canTryAgain) :
Tp::PendingOperation(account),
m_account(account),
m_saslIface(saslIface),
m_canTryAgain(canTryAgain),
- m_canFinish(false)
+ m_canFinish(false),
+ m_accountStorageId(accountStorageId)
{
connect(m_saslIface,
SIGNAL(SASLStatusChanged(uint,QString,QVariantMap)),
@@ -53,9 +55,6 @@ XTelepathyPasswordAuthOperation::XTelepathyPasswordAuthOperation(
m_config = KSharedConfig::openConfig(QStringLiteral("kaccounts-ktprc"));
m_lastLoginFailedConfig = m_config->group(QStringLiteral("lastLoginFailed"));
-
- KConfigGroup kaccountsGroup = m_config->group(QStringLiteral("ktp-kaccounts"));
- m_kaccountsId = kaccountsGroup.readEntry(m_account->objectPath(), 0);
}
XTelepathyPasswordAuthOperation::~XTelepathyPasswordAuthOperation()
@@ -70,8 +69,8 @@ void XTelepathyPasswordAuthOperation::onSASLStatusChanged(uint status, const QSt
// if we have non-null id AND if the last attempt didn't fail,
// proceed with the credentials receieved from the SSO;
// otherwise prompt the user
- if (m_kaccountsId != 0 && !m_lastLoginFailedConfig.hasKey(m_account->objectPath())) {
- GetCredentialsJob *credentialsJob = new GetCredentialsJob(m_kaccountsId, this);
+ if (!m_lastLoginFailedConfig.hasKey(m_account->objectPath())) {
+ GetCredentialsJob *credentialsJob = new GetCredentialsJob(m_accountStorageId, QStringLiteral("password"), QStringLiteral("password"), this);
connect(credentialsJob, &GetCredentialsJob::finished, [this](KJob *job){
if (job->error()) {
qWarning() << "Credentials job error:" << job->errorText();
@@ -170,7 +169,7 @@ void XTelepathyPasswordAuthOperation::storeCredentials(const QString &secret)
{
QString username = m_account->parameters().value(QStringLiteral("account")).toString();
Accounts::Manager *manager = KAccounts::accountsManager();
- Accounts::Account *account = manager->account(m_kaccountsId);
+ Accounts::Account *account = manager->account(m_accountStorageId);
SignOn::Identity *identity;
if (account) {
@@ -220,17 +219,7 @@ void XTelepathyPasswordAuthOperation::storeCredentials(const QString &secret)
account->sync();
connect(account, &Accounts::Account::synced, [=]() {
- m_kaccountsId = account->id();
-
- QString uid = m_account->objectPath();
-
- KSharedConfigPtr kaccountsConfig = KSharedConfig::openConfig(QStringLiteral("kaccounts-ktprc"));
- KConfigGroup ktpKaccountsGroup = kaccountsConfig->group(QStringLiteral("ktp-kaccounts"));
- ktpKaccountsGroup.writeEntry(uid, account->id());
-
- KConfigGroup kaccountsKtpGroup = kaccountsConfig->group(QStringLiteral("kaccounts-ktp"));
- kaccountsKtpGroup.writeEntry(QString::number(account->id()), uid);
- kaccountsConfig->sync();
+ m_accountStorageId = account->id();
qDebug() << "Account credentials synchronisation finished";
diff --git a/x-telepathy-password-auth-operation.h b/x-telepathy-password-auth-operation.h
index 52a44d6..5760de2 100644
--- a/x-telepathy-password-auth-operation.h
+++ b/x-telepathy-password-auth-operation.h
@@ -34,6 +34,7 @@ class XTelepathyPasswordAuthOperation : public Tp::PendingOperation
public:
explicit XTelepathyPasswordAuthOperation(
const Tp::AccountPtr &account,
+ int accountStorageId,
Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface,
bool canTryAgain);
~XTelepathyPasswordAuthOperation();
@@ -50,7 +51,7 @@ private:
Tp::Client::ChannelInterfaceSASLAuthenticationInterface *m_saslIface;
KSharedConfigPtr m_config;
KConfigGroup m_lastLoginFailedConfig;
- quint32 m_kaccountsId;
+ int m_accountStorageId;
bool m_canTryAgain;
bool m_canFinish;
QPointer<XTelepathyPasswordPrompt> m_dialog;
diff --git a/x-telepathy-sso-facebook-operation.cpp b/x-telepathy-sso-facebook-operation.cpp
deleted file mode 100644
index 5b9bf57..0000000
--- a/x-telepathy-sso-facebook-operation.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- Copyright (C) 2013 David Edmundson <kde at davidedmundson.co.uk>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "x-telepathy-sso-facebook-operation.h"
-
-#include <TelepathyQt/Account>
-#include <TelepathyQt/ChannelInterfaceSASLAuthenticationInterface>
-#include <TelepathyQt/AccountInterfaceStorageInterface>
-
-#include <TelepathyQt/PendingVariantMap>
-
-#include <Accounts/Account>
-#include <KAccounts/getcredentialsjob.h>
-
-#include <QDebug>
-#include <QUrlQuery>
-#include <QUrl>
-
-
-XTelepathySSOFacebookOperation::XTelepathySSOFacebookOperation(const Tp::AccountPtr &account, quint32 kaccountsId, Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface)
- : PendingOperation(account),
- m_account(account),
- m_saslIface(saslIface),
- m_kaccountsId(kaccountsId)
-{
- Q_ASSERT(kaccountsId);
- connect(m_saslIface, SIGNAL(SASLStatusChanged(uint,QString,QVariantMap)), SLOT(onSASLStatusChanged(uint,QString,QVariantMap)));
- connect(m_saslIface, SIGNAL(NewChallenge(QByteArray)), SLOT(onNewChallenge(QByteArray)));
-}
-
-
-void XTelepathySSOFacebookOperation::onSASLStatusChanged(uint status, const QString &reason, const QVariantMap &details)
-{
- qDebug() << "New status is: " << status;
- qDebug() << "Details: " << details;
- qDebug() << "Reason: " << reason;
-
- switch (status){
- case Tp::SASLStatusNotStarted:
- {
- qDebug() << "starting credentials job";
- m_saslIface->StartMechanism(QLatin1String("X-FACEBOOK-PLATFORM"));
- break;
- }
-
- case Tp::SASLStatusServerSucceeded:
- qDebug() << "Authentication handshake";
- m_saslIface->AcceptSASL();
- break;
-
- case Tp::SASLStatusSucceeded:
- qDebug() << "Authentication succeeded";
- setFinished();
- break;
- }
-}
-
-void XTelepathySSOFacebookOperation::onNewChallenge(const QByteArray& challengeData)
-{
- m_challengeData = challengeData;
-
- GetCredentialsJob *job = new GetCredentialsJob(m_kaccountsId, this);
- connect(job, SIGNAL(finished(KJob*)), SLOT(gotCredentials(KJob *)));
- job->start();
-}
-
-void XTelepathySSOFacebookOperation::gotCredentials(KJob *kJob)
-{
- qDebug();
- QUrl fbRequestUrl;
-
- fbRequestUrl.setQuery(m_challengeData);
- QUrlQuery fbRequestQuery(fbRequestUrl);
- QUrlQuery fbResponseQuery;
-
- qDebug() << fbRequestQuery.queryItemValue("version");
-
- GetCredentialsJob *job = qobject_cast< GetCredentialsJob* >(kJob);
- QVariantMap credentialsData = job->credentialsData();
- fbResponseQuery.addQueryItem("method", fbRequestQuery.queryItemValue("method"));
- fbResponseQuery.addQueryItem("nonce", fbRequestQuery.queryItemValue("nonce"));
- fbResponseQuery.addQueryItem("access_token", credentialsData["AccessToken"].toString());
- fbResponseQuery.addQueryItem("api_key", credentialsData["ClientId"].toString());
- fbResponseQuery.addQueryItem("call_id", "0");
- fbResponseQuery.addQueryItem("v", "1.0");
-
- m_saslIface->Respond(fbResponseQuery.query().toUtf8());
-}
diff --git a/x-telepathy-sso-facebook-operation.h b/x-telepathy-sso-facebook-operation.h
deleted file mode 100644
index e924d4a..0000000
--- a/x-telepathy-sso-facebook-operation.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 2013 David Edmundson <kde at davidedmundson.co.uk>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-
-#ifndef X_TELEPATHY_SSO_OPERATION_H
-#define X_TELEPATHY_SSO_OPERATION_H
-
-#include <TelepathyQt/PendingOperation>
-#include <TelepathyQt/Types>
-#include <TelepathyQt/Channel>
-#include <TelepathyQt/Account>
-
-class KJob;
-
-class XTelepathySSOFacebookOperation : public Tp::PendingOperation
-{
- Q_OBJECT
- Q_DISABLE_COPY(XTelepathySSOFacebookOperation)
-
-public:
- explicit XTelepathySSOFacebookOperation(
- const Tp::AccountPtr &account,
- quint32 kaccountsId,
- Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface);
-
-private Q_SLOTS:
- void onSASLStatusChanged(uint status, const QString &reason, const QVariantMap &details);
- void onNewChallenge(const QByteArray &challengeData);
- void gotCredentials(KJob *kjob);
-
-private:
- Tp::AccountPtr m_account;
- Tp::Client::ChannelInterfaceSASLAuthenticationInterface *m_saslIface;
-
- quint32 m_kaccountsId;
- QByteArray m_challengeData;
-
- friend class SaslAuthOp;
-};
-
-#endif // X_TELEPATHY_SSO_OPERATION_H
diff --git a/x-telepathy-sso-google-operation.cpp b/x-telepathy-sso-google-operation.cpp
index 5656c07..2821659 100644
--- a/x-telepathy-sso-google-operation.cpp
+++ b/x-telepathy-sso-google-operation.cpp
@@ -24,11 +24,12 @@
#include <KSharedConfig>
#include <KConfigGroup>
+#include <KLocalizedString>
-XTelepathySSOGoogleOperation::XTelepathySSOGoogleOperation(const Tp::AccountPtr &account, quint32 kaccountsId, Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface)
+XTelepathySSOGoogleOperation::XTelepathySSOGoogleOperation(const Tp::AccountPtr &account, int accountStorageId, Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface)
: PendingOperation(account)
, m_saslIface(saslIface)
- , m_kaccountsId(kaccountsId)
+ , m_accountStorageId(accountStorageId)
{
connect(m_saslIface, SIGNAL(SASLStatusChanged(uint,QString,QVariantMap)), SLOT(onSASLStatusChanged(uint,QString,QVariantMap)));
}
@@ -39,7 +40,7 @@ void XTelepathySSOGoogleOperation::onSASLStatusChanged(uint status, const QStrin
case Tp::SASLStatusNotStarted:
{
qDebug() << "Status Not started";
- GetCredentialsJob *job = new GetCredentialsJob(m_kaccountsId, this);
+ GetCredentialsJob *job = new GetCredentialsJob(m_accountStorageId, QStringLiteral("oauth2"), QStringLiteral("web_server"), this);
connect(job, SIGNAL(finished(KJob*)), SLOT(gotCredentials(KJob*)));
job->start();
break;
@@ -53,6 +54,13 @@ void XTelepathySSOGoogleOperation::onSASLStatusChanged(uint status, const QStrin
qDebug() << "Authentication succeeded";
setFinished();
break;
+ case Tp::SASLStatusServerFailed:
+ qDebug() << "Auth failed";
+ QString errorMessage = details[QLatin1String("server-message")].toString();
+ if (errorMessage.isEmpty()) {
+ errorMessage = details[QLatin1String("debug-message")].toString();
+ }
+ setFinishedWithError(reason, errorMessage.isEmpty() ? i18n("Authentication error") : errorMessage);
}
}
diff --git a/x-telepathy-sso-google-operation.h b/x-telepathy-sso-google-operation.h
index 1fad244..dcfa71b 100644
--- a/x-telepathy-sso-google-operation.h
+++ b/x-telepathy-sso-google-operation.h
@@ -35,7 +35,7 @@ class XTelepathySSOGoogleOperation : public Tp::PendingOperation
public:
explicit XTelepathySSOGoogleOperation(
const Tp::AccountPtr &account,
- quint32 kaccountsId,
+ int accountStorageId,
Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface);
private Q_SLOTS:
@@ -46,7 +46,7 @@ private:
Tp::AccountPtr m_account;
Tp::Client::ChannelInterfaceSASLAuthenticationInterface *m_saslIface;
- quint32 m_kaccountsId;
+ int m_accountStorageId;
QByteArray m_challengeData;
friend class SaslAuthOp;
--
ktp-auth-handler packaging
More information about the pkg-kde-commits
mailing list