the-djmaze / snappymail

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

SOME users AUTHENTICATIONFAILED after version update #969

Closed joergmschulz closed 1 year ago

joergmschulz commented 1 year ago

this is hard to reproduce as snappymail works for most users. For others, authentication does not work and the log throws (see below):

The same user can authenticate from another nextcloud instance using the same parameters. Another nextcloud can authenticate from the failing nextcloud using another nextcloud account and the same mail account settings. 2FA has been disabled, that's not the reason. nextcloud redis cache and snappymail data/cache have been cleared. all browser cookies and data for the sessions have been cleared, another browser has been used.

Might content security policy be a reason - but why only for this user?

2023-02-15 10:17:57.023][8c4996c8] IMAP[WARNING]: MailSo\Imap\Exceptions\NegativeResponseException: AUTHENTICATIONFAILED Authentication failed. in /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/MailSo/Imap/ResponseCollection.php:46
Stack trace:
#0 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/MailSo/Imap/ImapClient.php(538): MailSo\Imap\ResponseCollection->validate()
#1 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/MailSo/Imap/ImapClient.php(461): MailSo\Imap\ImapClient->getResponse()
#2 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/MailSo/Imap/ImapClient.php(181): MailSo\Imap\ImapClient->SendRequestGetResponse('AUTHENTICATE', Array)
#3 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/RainLoop/Model/Account.php(297): MailSo\Imap\ImapClient->Login(Object(MailSo\Imap\Settings))
#4 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/RainLoop/Model/Account.php(238): RainLoop\Model\Account->netClientLogin(Object(MailSo\Imap\ImapClient), Object(RainLoop\Plugins\Manager), Object(MailSo\Imap\Settings))
#5 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/RainLoop/Actions/UserAuth.php(426): RainLoop\Model\Account->ImapConnectAndLogin(Object(RainLoop\Plugins\Manager), Object(MailSo\Imap\ImapClient), Object(RainLoop\Config\Application))
#6 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/RainLoop/Actions/UserAuth.php(143): RainLoop\Actions->imapConnect(Object(RainLoop\Model\MainAccount), true)
#7 /data/apps/snappymail/lib/Util/SnappyMailHelper.php(77): RainLoop\Actions->LoginProcess('**@xxxxx....', '*******', false)
#8 /data/apps/snappymail/lib/Controller/PageController.php(114): OCA\SnappyMail\Util\SnappyMailHelper::startApp(true)
#9 /www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(225): OCA\SnappyMail\Controller\PageController->indexPost()
#10 /www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(133): OC\AppFramework\Http\Dispatcher->executeController(Object(OCA\SnappyMail\Controller\PageController), 'indexPost')
#11 /www/nextcloud/lib/private/AppFramework/App.php(172): OC\AppFramework\Http\Dispatcher->dispatch(Object(OCA\SnappyMail\Controller\PageController), 'indexPost')
#12 /www/nextcloud/lib/private/Route/Router.php(298): OC\AppFramework\App::main('PageController', 'indexPost', Object(OC\AppFramework\DependencyInjection\DIContainer), Array)
#13 /www/nextcloud/lib/base.php(1047): OC\Route\Router->match('/apps/snappymai...')
#14 /www/nextcloud/index.php(36): OC::handleRequest()
#15 {main}
[2023-02-15 10:17:59.894][8c4996c8] IMAP[ERROR]: MailSo\Net\Exceptions\SocketAlreadyConnectedException in /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/MailSo/Net/NetClient.php:95
Stack trace:
#0 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/MailSo/Imap/ImapClient.php(81): MailSo\Net\NetClient->Connect(Object(MailSo\Imap\Settings))
#1 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/RainLoop/Model/Account.php(234): MailSo\Imap\ImapClient->Connect(Object(MailSo\Imap\Settings))
#2 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/RainLoop/Actions/UserAuth.php(426): RainLoop\Model\Account->ImapConnectAndLogin(Object(RainLoop\Plugins\Manager), Object(MailSo\Imap\ImapClient), Object(RainLoop\Config\Application))
#3 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/RainLoop/Actions/UserAuth.php(143): RainLoop\Actions->imapConnect(Object(RainLoop\Model\MainAccount), true)
#4 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/RainLoop/Actions/User.php(43): RainLoop\Actions->LoginProcess('**@xxxx.de', '*******', true)
#5 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/RainLoop/ServiceActions.php(140): RainLoop\Actions->DoLogin()
#6 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/RainLoop/Service.php(112): RainLoop\ServiceActions->ServiceJson('')
#7 /data/apps/snappymail/app/snappymail/v/2.26.1/app/libraries/RainLoop/Service.php(14): RainLoop\Service::RunResult()
#8 /data/apps/snappymail/lib/Util/SnappyMailHelper.php(90): RainLoop\Service::Handle()
#9 /data/apps/snappymail/lib/Controller/PageController.php(114): OCA\SnappyMail\Util\SnappyMailHelper::startApp(true)
#10 /www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(225): OCA\SnappyMail\Controller\PageController->indexPost()
#11 /www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(133): OC\AppFramework\Http\Dispatcher->executeController(Object(OCA\SnappyMail\Controller\PageController), 'indexPost')
#12 /www/nextcloud/lib/private/AppFramework/App.php(172): OC\AppFramework\Http\Dispatcher->dispatch(Object(OCA\SnappyMail\Controller\PageController), 'indexPost')
#13 /www/nextcloud/lib/private/Route/Router.php(298): OC\AppFramework\App::main('PageController', 'indexPost', Object(OC\AppFramework\DependencyInjection\DIContainer), Array)
#14 /www/nextcloud/lib/base.php(1047): OC\Route\Router->match('/apps/snappymai...')
#15 /www/nextcloud/index.php(36): OC::handleRequest()
#16 {main}
the-djmaze commented 1 year ago

I've analyzed the problem and see what is going on.

  1. Nextcloud -> Settings -> Additional the user set invalid login name + password
  2. SnappyMail does Login attempt and fails
  3. SnappyMail shows login screen
  4. User logs in
  5. Step 1 & 2 happen on each request, and so on login
  6. Login fails due to step 5 connected

I will solve the bug and as workaround the user either removes the invalid settings of step 1 or sets the right credentials.

joergmschulz commented 1 year ago

My god, root cause has been user's fault to correct the password in the additional settings. Sorry for that one - but thank you for resolving the bug. Additionally: using the login override plugin overcomes the issue as well. Will you close the bug when you made the fix - or shall I do it because of your good answer?

the-djmaze commented 1 year ago

I will close the bug when the fix lands in the commits.

joergmschulz commented 1 year ago

Confirm - the current release fixes the issue. Thank you very much.