zorn-v / nextcloud-social-login

GNU Affero General Public License v3.0
198 stars 137 forks source link

fix(login): take custom webroot into account when redirecting #350

Closed alixinne closed 2 years ago

alixinne commented 2 years ago

Hello,

This PR fixes an issue I have been encountering on my Nextcloud deployment.

The issue is as follows:

Nextcloud is configured with the following options:

'overwritewebroot' => 'nextcloud',
'overwriteprotocol' => 'https',
'overwritehost' => 'my.domain'

When trying to reach a restricted page (for example, trying to reach the calendar at https://my.domain/nextcloud/apps/calendar/), the following happens

This can be fixed by redirecting to \OC::$WEBROOT . $redirect_url, where \OC::$WEBROOT is the Nextcloud variable holding the web root.

I have tested this fix on my instance, it does solve the issue.

zorn-v commented 2 years ago

It will break login flow in desktop/mobile apps. https://github.com/zorn-v/nextcloud-social-login/issues/35

alixinne commented 2 years ago

That's a problem indeed, maybe there's a way to detect which login flow we are currently executing? I'll look into it but don't hesitate if you have any pointers on where to look!

zorn-v commented 2 years ago

Well, you can check that redirect url starts with slash.

alixinne commented 2 years ago

Right, the login flow for mobile/desktop redirects to an absolute URL somewhere on localhost or something?

zorn-v commented 2 years ago

It redirect to something like nc://login?

alixinne commented 2 years ago

This new version should work with both flows