[SCM] ktp-auth-handler packaging branch, master, updated. debian/15.12.1-2-282-g080758e
Maximiliano Curia
maxy at moszumanska.debian.org
Fri May 27 23:59:03 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-auth-handler.git;a=commitdiff;h=f87441c
The following commit has been merged in the master branch:
commit f87441ce28237f5e24177c212e37b8b665bd3af4
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Fri Apr 5 01:28:51 2013 +0200
Initial start of SSO SASL handling
---
CMakeLists.txt | 8 +++
cmake/modules/FindAccountsQt.cmake | 25 ++++++++++
cmake/modules/FindSignOnQt.cmake | 25 ++++++++++
getcredentialsjob.cpp | 99 ++++++++++++++++++++++++++++++++++++++
getcredentialsjob.h | 65 +++++++++++++++++++++++++
sasl-auth-op.cpp | 17 ++++++-
x-telepathy-sso-operation.cpp | 83 ++++++++++++++++++++++++++++++++
x-telepathy-sso-operation.h | 53 ++++++++++++++++++++
8 files changed, 373 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0fce7d8..e1e34f8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,6 +15,8 @@ find_package (TelepathyQt4 0.8.9 REQUIRED)
find_package (KTp REQUIRED)
find_package (QJSON REQUIRED)
find_package (QCA2 REQUIRED)
+find_package(AccountsQt REQUIRED)
+find_package(SignOnQt REQUIRED)
include (KDE4Defaults)
include (MacroLibrary)
@@ -26,16 +28,20 @@ include_directories (${KDE4_INCLUDES}
${KTP_INCLUDE_DIR}
${QJSON_INCLUDE_DIR}
${QCA2_INCLUDE_DIR}
+ ${ACCOUNTSQT_INCLUDE_DIRS}
+ ${SIGNONQT_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/kssl
)
set(ktp_auth_handler_SRCS
+ getcredentialsjob.cpp
main.cpp
sasl-handler.cpp
sasl-auth-op.cpp
tls-cert-verifier-op.cpp
tls-handler.cpp
types.cpp
+ x-telepathy-sso-operation.cpp
x-telepathy-password-auth-operation.cpp
x-telepathy-password-prompt.cpp
x-messenger-oauth2-auth-operation.cpp
@@ -60,6 +66,8 @@ target_link_libraries(ktp-auth-handler
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KDEWEBKIT_LIBS}
+ ${ACCOUNTSQT_LIBRARIES}
+ ${SIGNONQT_LIBRARIES}
${QJSON_LIBRARIES}
${QCA2_LIBRARIES}
)
diff --git a/cmake/modules/FindAccountsQt.cmake b/cmake/modules/FindAccountsQt.cmake
new file mode 100644
index 0000000..7e37273
--- /dev/null
+++ b/cmake/modules/FindAccountsQt.cmake
@@ -0,0 +1,25 @@
+# - Try to find AccountsQt
+# Once done this will define
+# ACCOUNTSQT_FOUND - System has libaccounts-qt
+# ACCOUNTSQT_INCLUDE_DIRS - The libaccounts-qt include directories
+# ACCOUNTSQT_LIBRARIES - The libraries needed to use libaccounts-qt
+
+find_package(PkgConfig)
+
+find_path(ACCOUNTSQT_INCLUDE_DIR Accounts/Account
+ HINTS ${ACCOUNTSQT_INCLUDEDIR} ${ACCOUNTSQT_INCLUDE_DIRS} ${CMAKE_INSTALL_PREFIX}/include
+ PATH_SUFFIXES accounts-qt )
+
+find_library(ACCOUNTSQT_LIBRARY NAMES accounts-qt libaccounts-qt
+ HINTS ${ACCOUNTSQT_LIBDIR} ${ACCOUNTSQT_LIBRARY_DIRS} ${CMAKE_INSTALL_PREFIX}/lib64)
+
+set(ACCOUNTSQT_LIBRARIES ${ACCOUNTSQT_LIBRARY} )
+set(ACCOUNTSQT_INCLUDE_DIRS ${ACCOUNTSQT_INCLUDE_DIR} )
+
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set ACCOUNTSQT_FOUND to TRUE
+# if all listed variables are TRUE
+find_package_handle_standard_args(libaccounts-qt DEFAULT_MSG
+ ACCOUNTSQT_LIBRARY ACCOUNTSQT_INCLUDE_DIR)
+
+mark_as_advanced(ACCOUNTSQT_INCLUDE_DIR ACCOUNTSQT_LIBRARY )
\ No newline at end of file
diff --git a/cmake/modules/FindSignOnQt.cmake b/cmake/modules/FindSignOnQt.cmake
new file mode 100644
index 0000000..dad55f3
--- /dev/null
+++ b/cmake/modules/FindSignOnQt.cmake
@@ -0,0 +1,25 @@
+# - Try to find SignOnQt
+# Once done this will define
+# SIGNONQT_FOUND - System has libsignon-qt
+# SIGNONQT_INCLUDE_DIRS - The libsignon-qt include directories
+# SIGNONQT_LIBRARIES - The libraries needed to use libsignon-qt
+
+find_package(PkgConfig)
+
+find_path(SIGNONQT_INCLUDE_DIR SignOn/AuthService
+ HINTS ${SIGNONQT_INCLUDEDIR} ${SIGNONQT_INCLUDE_DIRS}
+ PATH_SUFFIXES signon-qt )
+
+find_library(SIGNONQT_LIBRARY NAMES signon-qt libsignon-qt
+ HINTS ${SIGNONQT_LIBDIR} ${SIGNONQT_LIBRARY_DIRS} )
+
+set(SIGNONQT_LIBRARIES ${SIGNONQT_LIBRARY} )
+set(SIGNONQT_INCLUDE_DIRS ${SIGNONQT_INCLUDE_DIR} )
+
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set SIGNONQT_FOUND to TRUE
+# if all listed variables are TRUE
+find_package_handle_standard_args(libsignon-qt DEFAULT_MSG
+ SIGNONQT_LIBRARY SIGNONQT_INCLUDE_DIR)
+
+mark_as_advanced(SIGNONQT_INCLUDE_DIR SIGNONQT_LIBRARY )
\ No newline at end of file
diff --git a/getcredentialsjob.cpp b/getcredentialsjob.cpp
new file mode 100644
index 0000000..5ef5c6a
--- /dev/null
+++ b/getcredentialsjob.cpp
@@ -0,0 +1,99 @@
+/*************************************************************************************
+ * Copyright (C) 2013 by Alejandro Fiestas Olivares <afiestas at kde.org> *
+ * *
+ * 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 2 *
+ * 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, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
+ *************************************************************************************/
+
+#include "getcredentialsjob.h"
+
+#include <QtCore/QDebug>
+
+#include <Accounts/Manager>
+#include <Accounts/Account>
+#include <Accounts/AccountService>
+
+#include <SignOn/Identity>
+
+GetCredentialsJob::GetCredentialsJob(const Accounts::AccountId& id, QObject* parent)
+: KJob(parent)
+, m_id(id)
+, m_manager(new Accounts::Manager())
+{
+
+}
+
+void GetCredentialsJob::start()
+{
+ QMetaObject::invokeMethod(this, "getCredentials", Qt::QueuedConnection);
+}
+
+void GetCredentialsJob::setServiceType(const QString& serviceType)
+{
+ m_serviceType = serviceType;
+}
+
+void GetCredentialsJob::getCredentials()
+{
+ Accounts::Account* acc = m_manager->account(m_id);
+ Accounts::AccountService *service = new Accounts::AccountService(acc, m_manager->service(m_serviceType), this);
+
+ Accounts::AuthData authData = service->authData();
+ m_authData = authData.parameters();
+ SignOn::Identity* identity = SignOn::Identity::existingIdentity(acc->credentialsId(), this);
+
+ if (!identity) {
+ setError(-1);
+ setErrorText("Could not find credentials");
+ emitResult();
+ return;
+ }
+
+ QPointer<SignOn::AuthSession> authSession = identity->createSession(authData.method());
+
+ connect(authSession, SIGNAL(response(SignOn::SessionData)),
+ SLOT(sessionResponse(SignOn::SessionData)));
+ connect(authSession, SIGNAL(error(SignOn::Error)),
+ SLOT(sessionError(SignOn::Error)));
+
+ qDebug() << authData.parameters();
+ qDebug() << authData.mechanism();
+ authSession->process(authData.parameters(), authData.mechanism());
+}
+
+void GetCredentialsJob::info(const SignOn::IdentityInfo& info)
+{
+}
+
+void GetCredentialsJob::sessionResponse(const SignOn::SessionData& data)
+{
+ qDebug() << data.toMap();
+ m_sessionData = data;
+ emitResult();
+}
+
+void GetCredentialsJob::sessionError(const SignOn::Error& error)
+{
+ qDebug() << error.message();
+}
+
+Accounts::AccountId GetCredentialsJob::accountId() const
+{
+ return m_id;
+}
+
+QVariantMap GetCredentialsJob::credentialsData() const
+{
+ return m_sessionData.toMap().unite(m_authData);
+}
diff --git a/getcredentialsjob.h b/getcredentialsjob.h
new file mode 100644
index 0000000..30b2178
--- /dev/null
+++ b/getcredentialsjob.h
@@ -0,0 +1,65 @@
+/*************************************************************************************
+ * Copyright (C) 2013 by Alejandro Fiestas Olivares <afiestas at kde.org> *
+ * *
+ * 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 2 *
+ * 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, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
+ *************************************************************************************/
+
+#ifndef GET_CREDENTIALS_JOB_H
+#define GET_CREDENTIALS_JOB_H
+
+#include <kjob.h>
+
+#include <Accounts/Account>
+#include <Accounts/AuthData>
+#include <SignOn/SessionData>
+
+namespace Accounts {
+ class Manager;
+};
+namespace SignOn {
+ class Error;
+ class IdentityInfo;
+};
+
+class GetCredentialsJob : public KJob
+{
+ Q_OBJECT
+public:
+ explicit GetCredentialsJob(const Accounts::AccountId &id, QObject* parent = 0);
+ virtual void start();
+
+ void setServiceType(const QString &serviceType);
+
+ QVariantMap credentialsData() const;
+ Accounts::AccountId accountId() const;
+
+Q_SIGNALS:
+ void gotCredentials(const SignOn::SessionData& data);
+
+private Q_SLOTS:
+ void getCredentials();
+ void info(const SignOn::IdentityInfo &info);
+ void sessionResponse(const SignOn::SessionData &data);
+ void sessionError(const SignOn::Error &error);
+
+private:
+ QString m_serviceType;
+ Accounts::AccountId m_id;
+ QVariantMap m_authData;
+ Accounts::Manager *m_manager;
+ SignOn::SessionData m_sessionData;
+};
+
+#endif //GET_CREDENTIALS_JOB_H
diff --git a/sasl-auth-op.cpp b/sasl-auth-op.cpp
index b745234..210e321 100644
--- a/sasl-auth-op.cpp
+++ b/sasl-auth-op.cpp
@@ -19,8 +19,10 @@
*/
#include "sasl-auth-op.h"
+
#include "x-telepathy-password-auth-operation.h"
#include "x-messenger-oauth2-auth-operation.h"
+#include "x-telepathy-sso-operation.h"
#include <TelepathyQt/PendingVariantMap>
@@ -58,8 +60,19 @@ void SaslAuthOp::gotProperties(Tp::PendingOperation *op)
QVariantMap props = qdbus_cast<QVariantMap>(pvm->result());
QStringList mechanisms = qdbus_cast<QStringList>(props.value(QLatin1String("AvailableMechanisms")));
kDebug() << mechanisms;
-
- if (mechanisms.contains(QLatin1String("X-TELEPATHY-PASSWORD"))) {
+
+ if (mechanisms.contains(QLatin1String("X-FACEBOOK-PLATFORM"))) {
+ XTelepathySSOOperation *authop = new XTelepathySSOOperation(m_account, m_saslIface);
+ connect(authop,
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(onAuthOperationFinished(Tp::PendingOperation*)));
+
+ //FIXME this is repeated code...move it outside the if???
+ uint status = qdbus_cast<uint>(props.value(QLatin1String("SASLStatus")));
+ QString error = qdbus_cast<QString>(props.value(QLatin1String("SASLError")));
+ QVariantMap errorDetails = qdbus_cast<QVariantMap>(props.value(QLatin1String("SASLErrorDetails")));
+ authop->onSASLStatusChanged(status, error, errorDetails);
+ } else if (mechanisms.contains(QLatin1String("X-TELEPATHY-PASSWORD"))) {
// everything ok, we can return from handleChannels now
Q_EMIT ready(this);
XTelepathyPasswordAuthOperation *authop = new XTelepathyPasswordAuthOperation(m_account, m_saslIface, m_walletInterface, qdbus_cast<bool>(props.value(QLatin1String("CanTryAgain"))));
diff --git a/x-telepathy-sso-operation.cpp b/x-telepathy-sso-operation.cpp
new file mode 100644
index 0000000..a57812c
--- /dev/null
+++ b/x-telepathy-sso-operation.cpp
@@ -0,0 +1,83 @@
+/*
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 2013 David Edmundson <D.Edmundson at lboro.ac.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 <TelepathyQt/Account>
+#include <TelepathyQt/ChannelInterfaceSASLAuthenticationInterface>
+
+#include <Accounts/Account>
+
+#include <KDebug>
+#include <KUrl>
+
+#include "x-telepathy-sso-operation.h"
+#include "getcredentialsjob.h"
+
+XTelepathySSOOperation::XTelepathySSOOperation(const Tp::AccountPtr& account, Tp::Client::ChannelInterfaceSASLAuthenticationInterface* saslIface) :
+ PendingOperation(account),
+ m_account(account),
+ m_saslIface(saslIface)
+{
+ connect(m_saslIface, SIGNAL(SASLStatusChanged(uint,QString,QVariantMap)), SLOT(onSASLStatusChanged(uint,QString,QVariantMap)));
+ connect(m_saslIface, SIGNAL(NewChallenge(QByteArray)), SLOT(onNewChallenge(QByteArray)));
+}
+
+
+void XTelepathySSOOperation::onSASLStatusChanged(uint status, const QString &reason, const QVariantMap &details)
+{
+ qDebug() << "new status is " << status;
+ qDebug() << "details" << details;
+ switch (status){
+ case Tp::SASLStatusNotStarted:
+ kDebug() << "starting credentials job";
+ m_saslIface->StartMechanism(QLatin1String("X-FACEBOOK-PLATFORM"));
+ case Tp::SASLStatusServerSucceeded:
+ kDebug() << "Authentication handshake";
+ m_saslIface->AcceptSASL();
+ break;
+ }
+}
+
+void XTelepathySSOOperation::onNewChallenge(const QByteArray& array)
+{
+ kDebug() << "new challenge" << array;
+ kDebug() << "responding again";
+
+ GetCredentialsJob *job = new GetCredentialsJob(11, this);
+ kDebug() << "made new credentials job..starting";
+ job->exec();
+
+ KUrl fbRequestUrl;
+ KUrl fbResponseUrl;
+
+ fbRequestUrl.setQuery(array);
+ kDebug() << fbRequestUrl.queryItemValue("version");
+
+ fbResponseUrl.addQueryItem("method", fbRequestUrl.queryItemValue("method"));
+ fbResponseUrl.addQueryItem("nonce", fbRequestUrl.queryItemValue("nonce"));
+ fbResponseUrl.addQueryItem("access_token", job->credentialsData()["AccessToken"].toString());
+ fbResponseUrl.addQueryItem("api_key", job->credentialsData()["ClientId"].toString());
+ fbResponseUrl.addQueryItem("call_id", "0");
+ fbResponseUrl.addQueryItem("v", "1.0");
+
+ //.mid(1) trims leading '?' char
+ kDebug() << fbResponseUrl.query().mid(1);
+ m_saslIface->Respond(fbResponseUrl.query().mid(1).toUtf8());
+}
+
+
+
diff --git a/x-telepathy-sso-operation.h b/x-telepathy-sso-operation.h
new file mode 100644
index 0000000..f1dfaba
--- /dev/null
+++ b/x-telepathy-sso-operation.h
@@ -0,0 +1,53 @@
+/*
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 2013 David Edmundson <D.Edmundson at lboro.ac.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 GetCredentialsJob;
+
+class XTelepathySSOOperation : public Tp::PendingOperation
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(XTelepathySSOOperation)
+
+public:
+ explicit XTelepathySSOOperation(
+ const Tp::AccountPtr &account,
+ Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface);
+// ~XTelepathySSOOperation();
+
+private Q_SLOTS:
+ void onSASLStatusChanged(uint status, const QString &reason, const QVariantMap &details);
+ void onNewChallenge(const QByteArray &array);
+
+private:
+ Tp::AccountPtr m_account;
+ Tp::Client::ChannelInterfaceSASLAuthenticationInterface *m_saslIface;
+
+ friend class SaslAuthOp;
+};
+
+#endif // X_TELEPATHY_SSO_OPERATION_H
--
ktp-auth-handler packaging
More information about the pkg-kde-commits
mailing list