LeonardoRM / owncloud-roundcube

OwnCloud app to integrate RoundCube Webmail
GNU Affero General Public License v3.0
6 stars 14 forks source link

Auto-Login failing #10

Closed Plaristote closed 3 years ago

Plaristote commented 3 years ago

Greetings.

I'm using owncloud 10.7.0, and fetched this plugin from git a couple of days ago.

I maanged to get the roundcube instance to open in an iframe, but that's pretty much all that's working.

I know that the extension successfully authenticate to Roundcube: I've checked that the credentials used by BackLogin were correct, and I've also noticed that if I have a session opened with Roundcube on another tab, it expires whenever I start a new session from Owncloud.

The following logs appear when I open the Roundcube app from Owncloud:

{"reqId":"F2BXjHcb888NcFaStJ6Y","level":3,"time":"June 06, 2021 20:04:35","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"POST","url":"\/index.php\/apps\/roundcube\/ajax\/adminSettings.php","message":"Undefined variable: path at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/Controller\/SettingsController.php#75"}
{"reqId":"F2BXjHcb888NcFaStJ6Y","level":3,"time":"June 06, 2021 20:04:35","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"POST","url":"\/index.php\/apps\/roundcube\/ajax\/adminSettings.php","message":"Invalid argument supplied for foreach() at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/Controller\/SettingsController.php#80"}
{"reqId":"F2BXjHcb888NcFaStJ6Y","level":3,"time":"June 06, 2021 20:04:35","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"POST","url":"\/index.php\/apps\/roundcube\/ajax\/adminSettings.php","message":"Invalid argument supplied for foreach() at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/Controller\/SettingsController.php#88"}
{"reqId":"F2BXjHcb888NcFaStJ6Y","level":3,"time":"June 06, 2021 20:04:35","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"POST","url":"\/index.php\/apps\/roundcube\/ajax\/adminSettings.php","message":"count(): Parameter must be an array or an object that implements Countable at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/Controller\/SettingsController.php#101"}
{"reqId":"F2BXjHcb888NcFaStJ6Y","level":3,"time":"June 06, 2021 20:04:35","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"POST","url":"\/index.php\/apps\/roundcube\/ajax\/adminSettings.php","message":"count(): Parameter must be an array or an object that implements Countable at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/Controller\/SettingsController.php#101"}
{"reqId":"F2BXjHcb888NcFaStJ6Y","level":3,"time":"June 06, 2021 20:04:35","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"POST","url":"\/index.php\/apps\/roundcube\/ajax\/adminSettings.php","message":"array_combine() expects parameter 1 to be array, string given at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/Controller\/SettingsController.php#117"}
{"reqId":"F2BXjHcb888NcFaStJ6Y","level":3,"time":"June 06, 2021 20:04:35","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"POST","url":"\/index.php\/apps\/roundcube\/ajax\/adminSettings.php","message":"array_filter() expects parameter 1 to be array, null given at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/Controller\/SettingsController.php#121"}
{"reqId":"CHAe6kjLLMkmG4vtyl5Q","level":3,"time":"June 06, 2021 20:04:39","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"GET","url":"\/index.php\/apps\/roundcube\/","message":"Undefined index: set-cookie at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/BackLogin.php#76"}
{"reqId":"CHAe6kjLLMkmG4vtyl5Q","level":3,"time":"June 06, 2021 20:04:39","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"GET","url":"\/index.php\/apps\/roundcube\/","message":"Undefined index: _token at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/BackLogin.php#83"}
{"reqId":"CHAe6kjLLMkmG4vtyl5Q","level":3,"time":"June 06, 2021 20:04:39","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"GET","url":"\/index.php\/apps\/roundcube\/","message":"Trying to access array offset on value of type null at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/BackLogin.php#83"}
{"reqId":"CHAe6kjLLMkmG4vtyl5Q","level":3,"time":"June 06, 2021 20:04:39","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"GET","url":"\/index.php\/apps\/roundcube\/","message":"Undefined index: _timezone at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/BackLogin.php#86"}
{"reqId":"CHAe6kjLLMkmG4vtyl5Q","level":3,"time":"June 06, 2021 20:04:39","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"GET","url":"\/index.php\/apps\/roundcube\/","message":"Trying to access array offset on value of type null at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/BackLogin.php#86"}
{"reqId":"CHAe6kjLLMkmG4vtyl5Q","level":3,"time":"June 06, 2021 20:04:39","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"GET","url":"\/index.php\/apps\/roundcube\/","message":"Undefined index: _url at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/BackLogin.php#87"}
{"reqId":"CHAe6kjLLMkmG4vtyl5Q","level":3,"time":"June 06, 2021 20:04:39","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"GET","url":"\/index.php\/apps\/roundcube\/","message":"Trying to access array offset on value of type null at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/BackLogin.php#87"}
{"reqId":"CHAe6kjLLMkmG4vtyl5Q","level":3,"time":"June 06, 2021 20:04:39","remoteAddr":"10.0.86.238","user":"plaristote","app":"PHP","method":"GET","url":"\/index.php\/apps\/roundcube\/","message":"Undefined index: set-cookie at \/var\/www\/owncloud\/apps-external\/roundcube\/lib\/BackLogin.php#98"}

Seems like BackLogin is having some issues setting up the cookies.

On that regard, the fact that everything happens behind a proxy might be relevant ?

Anyhow, I'll see what I can do, and try to provide a patch if necessary, but some guidance would be much appreciated !

Plaristote commented 3 years ago

After further inspection, I found out the last issue was caused by roundcube returning 301 to the first login request. I was able to fix the issue by setting CURLOPT_FOLLOWLOCATION to true in BackLogin::sendRequest.

Adding a slash after the rcInternalAddress also fixes the issue, as Roundcube no longer responds with 301 in that case.

I'll be back and edit that post soon, as BackLogin::login still returns false for reasons that I have yet to uncover.

Plaristote commented 3 years ago

Wow... after all the time spent on this, I almost fainted when, at long last, I had my hands on my holy grail. It works !

I've opened PR #11 and #12 to implement the changes that helped me getting this application up and running.

I also have a couple of issues with settings:

For now, it seems that autologin's good to go, so I'm closing this issue.