Merge lp://staging/~gary-wzl77/account-plugins/mcloud-plugin-lp1587282 into lp://staging/account-plugins

Proposed by Gary.Wang
Status: Merged
Merged at revision: 171
Proposed branch: lp://staging/~gary-wzl77/account-plugins/mcloud-plugin-lp1587282
Merge into: lp://staging/account-plugins
Prerequisite: lp://staging/~mardy/account-plugins/owncloud-1570986
Diff against target: 594 lines (+493/-0)
11 files modified
.bzrignore (+1/-0)
Makefile.am (+2/-0)
configure.ac (+15/-0)
data/providers/mcloud.provider.in.in (+29/-0)
debian/account-plugin-mcloud.install (+4/-0)
debian/control (+8/-0)
debian/rules (+2/-0)
qml/mcloud/ErrorItem.qml (+48/-0)
qml/mcloud/Main.qml (+7/-0)
qml/mcloud/OAuth.qml (+283/-0)
qml/mcloud/WebView.qml (+94/-0)
To merge this branch: bzr merge lp://staging/~gary-wzl77/account-plugins/mcloud-plugin-lp1587282
Reviewer Review Type Date Requested Status
Alberto Mardegan (community) Needs Information
Review via email: mp+296088@code.staging.launchpad.net

This proposal supersedes a proposal from 2016-05-31.

Commit message

Add mcloud plugin.

Description of the change

Add mcloud plugin

Testing instructions:
1) manually install the account-plugin-mcloud package
2) download and install mcloud scope package from
   https://drive.google.com/open?id=0B2H9ECPSSfqIcGtmUEdZNHpVNVU
3) launch mcloud scope and click "Login to MCloud"

To post a comment you must log in.
Revision history for this message
Alberto Mardegan (mardy) wrote :

Hi Gary, thanks for this plugin!
Do you have a link to the OAuth documentation for mccloud? Better if in English :-)

I don't believe that mccould OAuth implementation is special; what you have coded as WORKAROUND 1 & 2 seem to be the normal web flow. I think you can remove those two workarounds, and just change the .provider file by replacing "user_agent" with "web_server", then add your ClientSecret in there too, and it should work.

Once you get it to work, can you also try removing the "DisableStateParameter" option, and see if it continues working? It's preferable not to use that option, because it disables a security feature.

As for the user agent, could you please file a bug against https://launchpad.net/ubuntu/+source/webbrowser-app and ask for a user-agent override to be added in Ubuntu.WebView?

If we manage to get all the above done, then we won't need any workarounds in the plugin, and we can avoid duplicating the code here. :-)

review: Needs Information
Revision history for this message
Gary.Wang (gary-wzl77) wrote :

Thanks for your hints. mandy
 You can find the mcloud OAuth doc here,
 http://caiyun.feixin.10086.cn/Mcloud/dev/
 sorry it's written in Chinese. I guess google translate can help on this :)

  Also I tried to modify the provider file according to your tips
  1. web_server mechanism (with DisableStateParameter removed )
       server popups error page

       however If we specify DisableStateParameter in provider
       log:
       browser-request.cpp 123 ~BrowserRequestPrivate
       browser-request.cpp 323 closeView
       qml: Authentication error, code 1
       qml: Removing credentials...

       AccountService.NoAccountError. That's because session data returned from server doesn't contains user account information.

   2. user_agent mechanism
      log:
       bowser-request.cpp 123 ~BrowserRequestPrivate
       browser-request.cpp 323 closeView
       qml: Authentication error, code 3
       qml: Removing credentials...
       qml: ====== PLUGIN FINISHED ======

     Root cause is the url format that cmcc server give us back is not correct when it navigates to our redirect url with authorized code.
     http://developer.ubuntu.com/en/?code=7598B08A870A5.....
     The correct one should be like as following
     http://developer.ubuntu.com/en/#code=7598B08A870A5.....

     Error occurs when authentication flow runs here
     https://gitlab.com/accounts-sso/signon-plugin-oauth2/blob/master/src/oauth2plugin.cpp#L355

     That's why I apply workaround1 & 2 in this mechanism to create fake "access token".
     Actually, we can check if url contains '?' in this step.
     But to be honest, I don't like this "fix" since redirection url format is incompliant with OAuth2.0 specs.

    I create a test scope to reproduce above issues, Please take a look.
    https://code.launchpad.net/~gary-wzl77/+junk/maccount

   Thanks.

Revision history for this message
Alberto Mardegan (mardy) wrote :

On 01/06/2016 14:48, Gary.Wang wrote:
> Also I tried to modify the provider file according to your tips
> 1. web_server mechanism (with DisableStateParameter removed )
> server popups error page
>
> however If we specify DisableStateParameter in provider
> log:
> browser-request.cpp 123 ~BrowserRequestPrivate
> browser-request.cpp 323 closeView
> qml: Authentication error, code 1
> qml: Removing credentials...
>
> AccountService.NoAccountError. That's because session data returned from server doesn't contains user account information.

Can you please run the following command

  echo "LoggingLevel=2" > ~/.config/signond.conf

and then try again with the web_server method, and show me the contents
of the syslog? (in a pastebin)

I pushed my changes at lp:~mardy/account-plugins/mcloud-plugin-lp1587282
but I'm unable to test them because I don't know how to login. :-(
I managed to create an account in cmpassport.com, but I don't know what
I should enter in the login screen here. Can you help me?

Revision history for this message
Gary.Wang (gary-wzl77) wrote :

Sorry, I think I would give your the test account in advance. I sent you via email. Please have a check.

I attach the link for syslog in pastebin
https://pastebin.canonical.com/157865/

Here is the log after running online-accounts-service
https://pastebin.canonical.com/157864/

Please let me know if there is anything I can do for you.
Thanks.

Revision history for this message
Alberto Mardegan (mardy) wrote :

Hi Gary, good news! :-)

Thanks to your help with the account, after some attempts I got the plugin working. My code is in lp:~mardy/account-plugins/mcloud-plugin-lp1587282 (I'll prepare a merge proposal of my branch into yours).
Unfortunately it requires a little change in the signon-plugin-oauth (https://gitlab.com/accounts-sso/signon-plugin-oauth2/commit/e812eb3e76a1221074e3cf27208aacced5091e42) but I'll take care of landing that one.

I didn't have any problem because of the UserAgent, but I was testing on my desktop, so maybe on the phone it's different.

Revision history for this message
Gary.Wang (gary-wzl77) wrote :

Hi mandy
     That's great. Please have a check if it works on the phone.
     Thanks so much for your help on this. :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches