435f369
From e9bb20a403828d1917033c7594df2d74aa84f027 Mon Sep 17 00:00:00 2001
8721104
From: Giuseppe Castagno <giuseppe.castagno@acca-esse.eu>
8721104
Date: Tue, 15 Mar 2016 17:33:29 +0100
8721104
Subject: [PATCH] Related tdf#98416 Libcmis: add a patch to fix Google Drive
8721104
 login
8721104
8721104
The new Google login sequence uses two html pages: one for user email
8721104
the other for password.
8721104
8721104
The older sequence used only one page for both user email and
8721104
user password.
8721104
8721104
Change-Id: If875ba3ec9680d7e8c700a269873e427ac037a8e
8721104
Reviewed-on: https://gerrit.libreoffice.org/24513
8721104
Tested-by: Jenkins <ci@libreoffice.org>
8721104
Reviewed-by: David Tardon <dtardon@redhat.com>
8721104
---
8721104
 external/libcmis/UnpackedTarball_cmis.mk        |   1 +
8721104
 external/libcmis/libcmis-fix-google-drive.patch | 106 ++++++++++++++++++++++++
8721104
 2 files changed, 107 insertions(+)
8721104
 create mode 100644 external/libcmis/libcmis-fix-google-drive.patch
8721104
8721104
diff --git a/external/libcmis/UnpackedTarball_cmis.mk b/external/libcmis/UnpackedTarball_cmis.mk
435f369
index 16d4400..24bbda5 100644
8721104
--- a/external/libcmis/UnpackedTarball_cmis.mk
8721104
+++ b/external/libcmis/UnpackedTarball_cmis.mk
307bdb4
@@ -15,6 +15,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,cmis,0))
8721104
 
8721104
 $(eval $(call gb_UnpackedTarball_add_patches,cmis, \
8721104
 						external/libcmis/libcmis-libxml2_compatibility.patch \
435f369
+						external/libcmis/libcmis-fix-google-drive.patch \
8721104
 ))
8721104
 
8721104
 ifeq ($(OS)$(COM),WNTMSC)
8721104
diff --git a/external/libcmis/libcmis-fix-google-drive.patch b/external/libcmis/libcmis-fix-google-drive.patch
8721104
new file mode 100644
435f369
index 0000000..07bb4f3
8721104
--- /dev/null
307bdb4
+++ b/external/libcmis/libcmis-fix-google-drive.patch
8721104
@@ -0,0 +1,106 @@
435f369
+diff -aru src/libcmis/oauth2-providers.cxx src/libcmis/oauth2-providers.cxx
435f369
+--- src/libcmis/oauth2-providers.cxx	2016-03-01 17:14:26.000000000 +0100
435f369
++++ src/libcmis/oauth2-providers.cxx	2016-04-28 11:28:25.233803971 +0200
8721104
+@@ -37,11 +37,28 @@
8721104
+ string OAuth2Providers::OAuth2Gdrive( HttpSession* session, const string& authUrl,
8721104
+                                       const string& username, const string& password )
8721104
+ {
8721104
++    /* This member function implements 'Google OAuth 2.0'
8721104
++     *
8721104
++     * The interaction is carried out by libcmis, with no web browser involved.
8721104
++     *
8721104
++     * Normal sequence (without 2FA) is:
8721104
++     * 1) a get to activate login page
8721104
++     *    receive first login page, html format
8721104
++     * 2) subsequent post to sent email
8721104
++     *    receive html page for password input
8721104
++     * 3) subsequent post to send password
8721104
++     *    receive html page for application consent
8721104
++     * 4) subsequent post to send a consent for the application
8721104
++     *    receive a single-use authorization code
8721104
++     *    this code is returned as a string
8721104
++     */
8721104
++
8721104
+     static const string CONTENT_TYPE( "application/x-www-form-urlencoded" );
8721104
+     // STEP 1: Log in
8721104
+     string res;
8721104
+     try
8721104
+     {
8721104
++        // send the first get, receive the html login page
8721104
+         res = session->httpGetRequest( authUrl )->getStream( )->str( );
8721104
+     }
8721104
+     catch ( const CurlException& e )
8721104
+@@ -49,20 +66,39 @@
8721104
+         return string( );
8721104
+     }
8721104
+ 
8721104
+-    string loginPost, loginLink; 
8721104
+-    if ( !parseResponse( res.c_str( ), loginPost, loginLink ) ) 
8721104
++    string loginEmailPost, loginEmailLink;
8721104
++    if ( !parseResponse( res.c_str( ), loginEmailPost, loginEmailLink ) )
8721104
++        return string( );
8721104
++
8721104
++    loginEmailPost += "Email=";
8721104
++    loginEmailPost += string( username );
8721104
++
8721104
++    istringstream loginEmailIs( loginEmailPost );
8721104
++    string loginEmailRes;
8721104
++    try
8721104
++    {
8721104
++        // send a post with user email, receive the html page for password input
8721104
++        loginEmailRes = session->httpPostRequest ( loginEmailLink, loginEmailIs, CONTENT_TYPE )
8721104
++                        ->getStream( )->str( );
8721104
++    }
8721104
++    catch ( const CurlException& e )
8721104
++    {
8721104
++        return string( );
8721104
++    }
8721104
++
8721104
++    string loginPasswdPost, loginPasswdLink;
8721104
++    if ( !parseResponse( loginEmailRes.c_str( ), loginPasswdPost, loginPasswdLink ) )
8721104
+         return string( );
8721104
+-    
8721104
+-    loginPost += "Email=";  
8721104
+-    loginPost += string( username );
8721104
+-    loginPost += "&Passwd=";
8721104
+-    loginPost += string( password );
8721104
+-    
8721104
+-    istringstream loginIs( loginPost );
8721104
+-    string loginRes;
8721104
+-    try 
8721104
++
8721104
++    loginPasswdPost += "&Passwd=";
8721104
++    loginPasswdPost += string( password );
8721104
++
8721104
++    istringstream loginPasswdIs( loginPasswdPost );
8721104
++    string loginPasswdRes;
8721104
++    try
8721104
+     {
8721104
+-        loginRes = session->httpPostRequest ( loginLink, loginIs, CONTENT_TYPE )
8721104
++        // send a post with user password, receive the application consent page
8721104
++        loginPasswdRes = session->httpPostRequest ( loginPasswdLink, loginPasswdIs, CONTENT_TYPE )
8721104
+                         ->getStream( )->str( );
8721104
+     }
8721104
+     catch ( const CurlException& e )
8721104
+@@ -71,8 +107,8 @@
8721104
+     }
8721104
+ 
8721104
+     // STEP 2: allow libcmis to access google drive
8721104
+-    string approvalPost, approvalLink; 
8721104
+-    if ( !parseResponse( loginRes. c_str( ), approvalPost, approvalLink) )
8721104
++    string approvalPost, approvalLink;
8721104
++    if ( !parseResponse( loginPasswdRes. c_str( ), approvalPost, approvalLink) )
8721104
+         return string( );
8721104
+     approvalPost += "submit_access=true";
8721104
+ 
8721104
+@@ -80,7 +116,8 @@
8721104
+     string approvalRes;
8721104
+     try
8721104
+     {
8721104
+-        approvalRes = session->httpPostRequest ( approvalLink, approvalIs, 
8721104
++        // send a post with application consent
8721104
++        approvalRes = session->httpPostRequest ( approvalLink, approvalIs,
8721104
+                             CONTENT_TYPE) ->getStream( )->str( );
8721104
+     }
8721104
+     catch ( const CurlException& e )
8721104
+Only in new-src/src/libcmis: oauth2-providers.cxx~
8721104
-- 
307bdb4
2.7.3
8721104