Comment 1 for bug 1237869

Revision history for this message
Wu Shu (superwushu) wrote :

Forgot to mention, this issue also affects Twitter online account. I can only get a blank page when I chose to add the Twitter account, without no any prompt/warnings.

My Analysis
----------------
1. I change loglevel of signond.conf and see the following from log:

Oct 10 10:46:01 kitt signonpluginprocess: plugin.cpp 126 userActionFinished :
Oct 10 10:46:01 kitt signonpluginprocess: oauth2plugin.cpp 310 userActionFinished :
Oct 10 10:46:01 kitt signonpluginprocess: oauth2plugin.cpp 323 userActionFinished : "https://wiki.ubuntu.com/?code=4/PMaxsE1yzBrszLJyMbF0gyYhX_Sx.ouuTe7vG4m0XEnp6UAPFm0EAeYdAgwI"
Oct 10 10:46:01 kitt signonpluginprocess: oauth2plugin.cpp 566 sendOAuth2PostRequest :
Oct 10 10:46:01 kitt signonpluginprocess: oauth2plugin.cpp 575 sendOAuth2PostRequest : Query string = "grant_type=authorization_code&client_id=759250720802-4sii0me9963n9fdqdmi7cepn6ub8luoh.apps.googleusercontent.com&client_secret=juFngKUcuhB7IRQqHtSLavqJ&code=4/PMaxsE1yzBrszLJyMbF0gyYhX_Sx.ouuTe7vG4m0XEnp6UAPFm0EAeYdAgwI&redirect_uri=https://wiki.ubuntu.com/"
Oct 10 10:46:01 kitt signonpluginprocess: ../../../../src/remotepluginprocess/remotepluginprocess.cpp 496 startTask operation is completed

After quite a whie:

Oct 10 10:51:06 kitt signonpluginprocess: base-plugin.cpp 151 handleNetworkError : error signal received: 99
Oct 10 10:51:06 kitt signonpluginprocess: ../../../../src/remotepluginprocess/remotepluginprocess.cpp 425 disableCancelThread Before the isFinished loop
Oct 10 10:51:06 kitt signonpluginprocess: ../../../../src/remotepluginprocess/remotepluginprocess.cpp 430 disableCancelThread Internal iteration 0
Oct 10 10:51:06 kitt signonpluginprocess: ../../../../src/remotepluginprocess/remotepluginprocess.cpp 249 error error is sent 307 "Connection to proxy closed prematurely"
Oct 10 10:51:06 kitt signonpluginprocess: base-plugin.cpp 133 onPostFinished : Finished signal received

So it appears the proxy isn't correctly used. But I did set the proxy correctly and the previous steps can go on well. Also I can succeed in adding Facebook account.

2. I added some logging in plugin.cpp and oauth2plugin.cpp and found the proxy in the QNetworkAccessManager is correctly:
proxy.foobar.com:3128. So it's really strange the connection cannot reach when proxy is correctly set. I tried to use Wireshark to see what happened but it's HTTPS so it's difficulty to do.

3. Then I accidentally commented the line in plugin.cpp:
void Plugin::process(const SignOn::SessionData &inData, ...)
{
    ...
    //m_networkAccessManager->setProxy(networkProxy);
    impl->setNetworkAccessManager(m_networkAccessManager);
    ...
}
And found it worked! Both Google account and Twitter account are added.

4. From my experiences, I believe it's due to HTTPS over HTTP proxy. In my company HTTPS should go to HTTPS proxy (https://proxy.foobar.com:3128).

From the code in Plugin::process, the proxy is set to QNetworkProxy::applicationProxy():

    QNetworkProxy networkProxy = QNetworkProxy::applicationProxy();
    m_networkAccessManager->setProxy(networkProxy);
    impl->setNetworkAccessManager(m_networkAccessManager);

applicationProxy() will only return the HTTP proxy when the system proxy has multiple proxy settings.

But why it worked if I don't set the proxy? I found in remotepluginprocess.cpp (the signond package):

bool RemotePluginProcess::setupProxySettings()
{
    ...
    MyNetworkProxyFactory *proxyFactory = new MyNetworkProxyFactory();
    QNetworkProxyFactory::setApplicationProxyFactory(proxyFactory);
    ...
    return true;
}

The signonpluginprocess has application proxy set, and it's a proxy factory. This means the HTTPS proxy will be selected if you make an HTTPS request.

5. My Fix

So I propose a fix for this issue. I'd like to set the proxy in plugin to the default proxy, which will pick up the application proxy factory, instead of selecting a steady HTTP proxy. I still keep the proxy override for parameters. Can you help to verify and merge it if necessary?

Thanks,
Shu