the-djmaze / snappymail

Simple, modern & fast web-based email client
https://snappymail.eu
GNU Affero General Public License v3.0
998 stars 121 forks source link

Proxy Auth plugin compatible with SnappyMail inside Nextcloud ? #1581

Closed schmitz-ens closed 4 months ago

schmitz-ens commented 4 months ago

Hello, I'm running Nextcloud 27 with SnappyMail 2.36.1, and everything works fine if I let the user enter their IMAP login/password directly into SnappyMail. However, I want to utilize Dovecot's Master Password feature to avoid password entry. I'm trying to get the Proxy Auth plugin to work following the documentation at https://www.mundhenk.org/SnappyMail_SSO/, but I'm encountering difficulties.

On one hand, Nextcloud doesn't pass the "remote user" properly, but I managed to work around this issue via our SSO. On the other hand, I'm consistently redirected to the Nextcloud homepage when trying to log in.

When I go through the ?ProxyAuth URL, I get the following in the logs:

[5a354770] [NOTICE]: TypeError: RainLoop\Actions::LoginProcess(): Argument #2 ($oPassword) must be of type SnappyMail\SensitiveString, string given, called in /var/www/nextcloud/data/appdata_snappymail/_data_/_default_/plugins/proxy-auth/index.php on line 126 and defined in /var/www/nextcloud/apps/snappymail/app/snappymail/v/2.36.1/app/libraries/RainLoop/Actions/UserAuth.php:131

Has anyone managed to make this plugin work with SnappyMail in Nextcloud?

Thank you in advance.

PhilippMundhenk commented 4 months ago

@schmitz-ens Could you please help me test the fix? This should allow running the plugin if SnappyMail is in a subdirectory

schmitz-ens commented 4 months ago

Hello @PhilippMundhenk Thanks ! I confirm it works now :-)

Last thing, I was not able to get the RemoteUser with $sRemoteUser = $this->Manager()->Actions()->Http()->GetHeader($sHeaderName);. It seems that Nextcloud doesn't expose any header with the username.. After mutiples hours looking for this, I finally used :

$ocUser = \OC::$server->getUserSession()->getUser();
$sRemoteUser = $ocUser->getUID();

So I get the remoteuser directly from Nextcloud without using a header.

Thanks for this great plugin !