OAuth support for Ruqola
AbandonedPublic

Authored by mlaurent on Jan 28 2018, 6:42 AM.

Details

Reviewers
velurimithun
Summary

https://developers.google.com/identity/protocols/OAuth2InstalledApp here a detailed description on
how the OAuth2 work flow should happen is given and we follow this.

https://rocket.chat/docs/developer-guides/realtime-api/method-calls/login/ here a method for OAuth login is
present.

Test Plan

Step 1: Get permission from user with a Google prompt

Step 2: After user give response Google redirects you to specific redirect_url(http://127.0.0.1/8888/) wit
h an authorization code in it

Step 3: Handle the OAuth2.0 server response i.e., get the authorization code present in redirect_url

Step 4: Exchange this Authorization code with access token from Google API

Step 5: Use this access token and client_secret which we got at the time of creating a project in Google developers console. This will be done by rocket.chat server, for that we need to send method to the server.

Diff Detail

Repository
R865 Ruqola
Branch
o2OAuth
Lint
No Linters Available
Unit
No Unit Test Coverage
There are a very large number of changes, so older changes are hidden. Show Older Changes
velurimithun edited the test plan for this revision. (Show Details)Feb 4 2018, 8:46 PM

"Libraries at github.com/pipcas/o2 are used

Done without using widgets or WebView :)
Still, code for refreshing the token is needed :)
Currently, it is working fine but unable to get channelList from open.rocket.chat :|

    Is it enough if add this one file**(https://github.com/pipacs/o2/blob/master/LICENSE) in src_o2 dir as license ?
A Button in Login page is needed for Google OAuth, Shall we ask Martin(Kirigami)..?

"

"Libraries at github.com/pipcas/o2 are used" so we don't copy lib in source directly we need to create a dependancy => you need to create a cmake search file.

"Done without using widgets or WebView :)" so good it's possible. So perhaps we can do it without to add this dependancy if you understand how they do. => it's not possible to use this new lib.

"A Button in Login page is needed for Google OAuth, Shall we ask Martin(Kirigami)..?" Why ask to kirigami guy ? why you don't do it by yourself ? it's just a button.

  • Add button in login.qml for OAuth

I'm getting error like TypeError: Property 'setLoginType' of object [object Object] is not a function :( in login.qml file...!

and cmakeLists.txt although it is present in src_o2 dir it is not showing.....! I'm unable to do "Run cmake"

You need to verify that server support google auth.
We can disable it in server.
So we need to know if it's possinle to use it.

src/ddpapi/ddpclient.cpp
553

seems that it's duplicate with line 565 => merge it

src/google.cpp
41

coding style => new line before :

58

new connect api

74

qCWarning(...)

97

qCDebug...

116

qCWarning

126

new connect api

151

same

152

const'ref

153

same

163

same

src/google.h
39

move to private

59

nullptr

65

use prefix member m_

src/qml/Login.qml
152

use RocketChatAccount for it

src/src_o2/CMakeLists.txt
1 ↗(On Diff #26672)

remove it or use a external lib

velurimithun marked 13 inline comments as done.
  • Modify the code according to comments in Revision and now 'Login with Google' button is working perfectly
  • Try to add o2 as external lib
velurimithun added a comment.EditedFeb 8 2018, 6:05 AM

when I try to build Qt5::Keychain doesn't link properly and I'm getting errors...!

is everything alright with src_o2/cmakeLists.txt ??

About server... currently I'm able to login and I can see some msg received from server in console >> that method in real-time API is working

but we are not getting channelLists and rooms

src/ddpapi/ddpclient.cpp
553

No, I think we need it in both the cases i.e., where ever login() there we should use if-else statement to determine which method(login(), loginGoogle()) to use.

src/google.h
39

no, we can't we are using it in DDPClient!

mlaurent added inline comments.Feb 8 2018, 8:17 AM
CMakeLists.txt
74

External is external !
so I don't want o2 source code in ruqola !
I want to search lib in system.
I don't want to have o2 source code here as we can't maintain it, we will not upgrade it etc.

So I don't want a option.
I want that we search on system if we have lib.

src/ddpapi/ddpclient.h
98

why invokable ?

src/google.cpp
65

new connect api

102

new line after )

120

new line

122

qCWarning... remove ()

133

qCDebug... remove ()

136

coding style in all source file please

145

same

157

same...

159

s...

169

...

182

const

src/qml/Login.qml
33

?????
we have "property QtObject rcAccount" no ?

"About server... currently I'm able to login and I can see some msg received from server in console >> that method in real-time API is working

but we are not getting channelLists and rooms"

As explain previously, support about google can be disable on server

> we need to check if server support it.

> we need to look at serverconfig info for it.

velurimithun marked 12 inline comments as done.
  • Modify the code (D10154)
  • Take o2 as external lib
velurimithun added a comment.EditedFeb 8 2018, 6:28 PM

/usr/bin/ld: cannot find -lQt5::Keychain

collect2: error: ld returned 1 exit status

src/CMakeFiles/libruqolacore.dir/build.make:1290: recipe for target 'src/libruqolacore.so.0.6.2' failed

CMakeFiles/Makefile2:153: recipe for target 'src/CMakeFiles/libruqolacore.dir/all' failed

Makefile:138: recipe for target 'all' failed

make[2]: *** [src/libruqolacore.so.0.6.2] Error 1

make[1]: *** [src/CMakeFiles/libruqolacore.dir/all] Error 2

make: *** [all] Error 2

04:42:52: The process "/usr/bin/cmake" exited with code 2.

Error while building/deploying project Ruqola (kit: Desktop)

When executing step "CMake Build"


I'm getting above errors , is there any mistake in cmakeLists.txt ???

Although I installed qt5Keychain and it was running perfectly before when source code of o2/ is present in Ruqola


You can make install them from https://github.com/pipacs/o2.git and test this patch

src/qml/Login.qml
33

getting function not initialized error with that...!

velurimithun updated this revision to Diff 26888.EditedFeb 10 2018, 6:35 PM
  • Add 'o2' static library path as Item

OAuth working perfectly with system library...

you can test the patch by make install lib from https://github.com/pipacs/o2.git

and you need to install Qt5 Keychain also, you can use 'sudo apt-get install qt5keychain-dev'

velurimithun added inline comments.Feb 10 2018, 7:13 PM
src/CMakeLists.txt
99

I could just keep o2 but, we are getting some linking errors with Qt5::Keychain shared libraries..

That is why path to static library of o2 is given as item for the target libruqolacore.

mlaurent added inline comments.Feb 10 2018, 8:09 PM
CMakeLists.txt
34

why keychain ?
We do'nt use it it's o2 lib which uses it or you uses it in code but I never see it

src/CMakeLists.txt
99

You need to create a cmake file for searching o2 as by default no all user as libo2 in this patch.
See other Find*.cmake file in kde

src/ddpapi/ddpclient.cpp
553

It's the same code => create a method for avoiding duplicate code

src/google.cpp
44

coding style

151

verify it as you use qobject_cast<...> so it can be nullptr

src/qml/Login.qml
33

so for sure you have an error in your code as I use it all the time.

velurimithun marked 5 inline comments as done.
  • Modify code acrdg to comments
velurimithun added inline comments.Feb 10 2018, 9:08 PM
src/CMakeLists.txt
99

problem is with Qt5::Keychain . It is installed as qt5keychain (libqt5keychain.so)

when I keep o2 as item in target_link_libraries(..) our cmake was unable to find the shared library (qt5keychain.so) instead it is searching for Qt5::Keychain when is not present in system.

I think FindXXX.cmake will also try to find the same thing finally resulting "cannot find -lQt5::Keychain" error

src/qml/Login.qml
33

Sry, rcAccount was working :|

Idk how I got error previously:)

  • Create Findo2.cmake file
velurimithun added inline comments.Feb 12 2018, 5:58 AM
src/CMakeLists.txt
100

Qt5::Keychain is dependency of o2 library, our cmake fails to find that although I've created FindQt5Keychain.cmake file

It fails to link Qt5::Keychain, because those Keychain libraries are installed with a different name from others like (libqt5keychain) while others have (libQt5xxxxx)

What should we do?

mlaurent added inline comments.Feb 12 2018, 7:01 AM
cmake/modules/FindQt5Keychain.cmake
2

We don't need two KeyChain.cmake

> we need to create one cmake file with merging all code.

I don't understand why find_package(Qt5Keychain REQUIRED) is not just enough. And put is as optional.

cmake/modules/Findo2.cmake
2

where do you find this cmake file ?

src/CMakeLists.txt
66

???? we don't have qt5core ???

78

I need to have it optional.

99

Remove it

100

"I've created FindQt5Keychain.cmake" nope you copied it from ownclound.

so you need to verify why it doesn't work.
src/google.cpp
39

not local include

44

coding style. Missing space

78

What we will do it we can't load it ?

86

const

102

???? with add << ... after and not in preview QStringLiteral ?

153

! otr

157

const

src/google.h
28

it's not a local include

31

We need to look at what we can autotest in this class

39

In private member

50

it's still useful to use Q_SLOTS as you use new connect api §?

src/qml/Login.qml
153

it works now ?

velurimithun marked 2 inline comments as done.Feb 12 2018, 8:37 PM
velurimithun added inline comments.
cmake/modules/FindQt5Keychain.cmake
2

problem is not with o2 libraries.

problem is with Qt5::Keychain.

I tried a lot changing the code but, our cmake is unable to find it
we are getting /usr/bin/ld: cannot find -lQt5::Keychain error :(

cmake/modules/Findo2.cmake
2

digikam

it was written by you only for Gphoto2 :)

src/google.cpp
132

I'd like to ask you how to check the log files..? which we give as argument for qCDebug

Since, I don't know that I was using qDebug, instead qCDebug(..)

mlaurent added inline comments.Feb 13 2018, 6:41 AM
cmake/modules/FindQt5Keychain.cmake
2

if cmake file is not able to need to debug it or recreate it from scratch.

cmake/modules/Findo2.cmake
2

So you can add your copyright for sure.

src/google.cpp
132

you never activated debug from the begin of project ????

Ok => kdebugsettings and you activate ruqola.

If it's not installed you need to activate with this command line:
QT_LOGGING_RULES="org.kde.ruqola*.*=true" ruqola

  • Make OAuth as optional
velurimithun added a comment.EditedFeb 13 2018, 6:32 PM

Really there is something wrong with Qt5::Keychain libraries => no need to write (Findo2.cmake)module for finding o2 package, by default, it is able to find it(since o2 libraries are built with cmake only) and our cmake is unable to link qt5Keychain which is dependency of o2

Our cmake is taking Qt5:: as namespace, when I give o2 item for target_link_libraries

Do we any idea how to overcome this ??

I started to implement in ruqola plugin support for authentication.
So I will use you code in the future, but first I need to be sure that your code works.

I started to send some patch to o2 dev.

Regards

Just for info now I have an architecture for using login as plugin.
I will use your code soon. Not all but some part of your code.

I added some patch to o2 lib too. I hope that they will be integrated soon.

But your code will not lose.
Regards

mlaurent resigned from this revision.Mar 21 2018, 8:39 PM
mlaurent commandeered this revision.
mlaurent abandoned this revision.
mlaurent edited reviewers, added: velurimithun; removed: mlaurent.

Reimplemented as plugin in ruqola