[GH-ISSUE #2688] [Feature] enable admins to see user mailbox #1680

Open
opened 2026-02-27 11:18:31 +03:00 by kerem · 7 comments
Owner

Originally created by @dakolta on GitHub (Nov 11, 2022).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/2688

Impacted versions

  • OS Type: Debian/Ubuntu
  • OS Version: 4.19.260-1
  • Database Type: PostgreSQL
  • Database version: 11.18 (Debian 11.18-0+deb10u1)
  • Modoboa: 2.0.2
  • installer used: Yes
  • Webserver: Nginx

Create new user and check "Allow mailbox access", set email address. Try login in using format of "user@foo.com*mailboxadmin@foo.com" and the password for mailboxadmin@foo.com.

When logging in web interface returns the error "Your username and password didn't match. Please try again."

Being able to log into the web interface as the master user to view a users mailbox. I have been able to do this using other web mail servers, i.e. iRedMail, Roundcube, SoGo, etc.

Screen Shot 2022-11-11 at 12 58 12 PM
Originally created by @dakolta on GitHub (Nov 11, 2022). Original GitHub issue: https://github.com/modoboa/modoboa/issues/2688 # Impacted versions * OS Type: Debian/Ubuntu * OS Version: 4.19.260-1 * Database Type: PostgreSQL * Database version: 11.18 (Debian 11.18-0+deb10u1) * Modoboa: 2.0.2 * installer used: Yes * Webserver: Nginx # Create new user and check "Allow mailbox access", set email address. Try login in using format of "user@foo.com*mailboxadmin@foo.com" and the password for mailboxadmin@foo.com. # When logging in web interface returns the error "Your username and password didn't match. Please try again." <!-- I can login as the user via command line or another map client. root:~# doveadm auth login admin@foo.net*mbadmin@foo.net xxxxxxxxxxxxxx passdb: admin@foo.net*mbadmin@foo.net auth succeeded extra fields: user=admin@foo.net original_user=mbadmin@foo.net auth_user=mbadmin@foo.net userdb extra fields: admin@hladmc.net home=/srv/vmail/hladmc.net/admin uid=1004 gid=1004 quota_rule=*:bytes=0M master_user=mbadmin@foo.net auth_user=mbadmin@foo.net root:~# root@:~# telnet localhost 143 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot (Debian) ready. 1 login admin@foo.net*mbadmin@foo.net xxxxxxxxxxxxxx 1 OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY LITERAL+ NOTIFY SPECIAL-USE QUOTA] Logged in 1 logout * BYE Logging out 1 OK Logout completed (0.001 + 0.000 secs). Connection closed by foreign host. root@:~# But when logging via web interface you get the error "Your username and password didn't match. Please try again." --> # Being able to log into the web interface as the master user to view a users mailbox. I have been able to do this using other web mail servers, i.e. iRedMail, Roundcube, SoGo, etc. # <img width="440" alt="Screen Shot 2022-11-11 at 12 58 12 PM" src="https://user-images.githubusercontent.com/18648939/201423503-e91de432-6663-4853-a2cf-5ecb4d4f57e9.png">
Author
Owner

@Spitfireap commented on GitHub (Nov 11, 2022):

Hi, there is an issue with this installer, could you edit /etc/dovecot/conf.d/10-ssl.conf : replace !include_try = /etc/dovecot/conf.d/10-ssl-keys.try by !include_try /etc/dovecot/conf.d/10-ssl-keys.try. then type sudo service dovecot restart.

<!-- gh-comment-id:1312170801 --> @Spitfireap commented on GitHub (Nov 11, 2022): Hi, there is an issue with this installer, could you edit ``/etc/dovecot/conf.d/10-ssl.conf`` : replace ``!include_try = /etc/dovecot/conf.d/10-ssl-keys.try`` by ``!include_try /etc/dovecot/conf.d/10-ssl-keys.try``. then type ``sudo service dovecot restart``.
Author
Owner

@dakolta commented on GitHub (Nov 11, 2022):

I do not have that line in that file and I do not see the /etc/dovecot/conf.d/10-ssl-keys.try file in the directory.
This is the contents of the /etc/dovecot/conf.d directory:
image

<!-- gh-comment-id:1312236149 --> @dakolta commented on GitHub (Nov 11, 2022): I do not have that line in that file and I do not see the /etc/dovecot/conf.d/10-ssl-keys.try file in the directory. This is the contents of the /etc/dovecot/conf.d directory: <img width="1441" alt="image" src="https://user-images.githubusercontent.com/18648939/201433090-de187a36-636b-4b38-b730-8a729c5cc245.png">
Author
Owner

@Spitfireap commented on GitHub (Nov 13, 2022):

okay sorry I misunderstood. The feature is not yet implemented in modoboa.

<!-- gh-comment-id:1312848816 --> @Spitfireap commented on GitHub (Nov 13, 2022): okay sorry I misunderstood. The feature is not yet implemented in modoboa.
Author
Owner

@tomas-kucera commented on GitHub (Jan 8, 2023):

Hi there, there are two parts into using master account:

  • ability to use Modoboa Webadmin to "peak" into users' mailboxes - this one I personally do not miss 😉

  • ability to connect (for example using Python's imaplib) to the users' mailboxes using master account for example for bulk mailboxes migrations:

    • this one is actually perfectly possible
    • it requires to have enabled Allow Mailboxes Access on the SuperAdmin identity
    • if the SuperAdmin does not have email (which normally does not have), the login is not possible as the search is using the login name / username as email, which for standard users it is usually identical, but for the SuperAdmins it is empty and thus the record is never found and thus not authenticated
    • there are two way to get around it: you can manually update the core_user DB record for the SuperAdmin(s) filling the usernames into the emails (tested and it si working, but I do not like this one though) or
    • in /etc/dovecot/dovecot-sql-master.conf.ext configuration file within the line password_query = SELECT email AS user, password FROM core_user WHERE email='%u' and is_active and master_user replace the email (twice) with username and restart dovecot (maybe reload is enough too)
    • now it is possible to do for example this using the imaplib:
import imaplib

# for non-SSL conenctions
mailbox = imaplib.IMAP4(host='mail.domain.tld', port=143)

# for SSL connections
mailbox = imaplib.IMAP4_SSL(host='mail.domain.tld', port=993)
typ, data = mailbox.login('first.last@domain.tld*admin', 'password')

print(mailbox.list())

mailbox.close()
mailbox.logout()

The password_query could also be more sophisticated, such as:

password_query = SELECT username AS user, password FROM core_user \
  WHERE (username='%u' or email='%u') and is_active and master_user

BTW Should @Spitfireap be OK with this (I have not found any issues after this change), I would create a PR for this. 😉

<!-- gh-comment-id:1374816445 --> @tomas-kucera commented on GitHub (Jan 8, 2023): Hi there, there are two parts into using master account: - ability to use Modoboa Webadmin to "peak" into users' mailboxes - this one I personally do not miss 😉 - ability to connect (for example using Python's imaplib) to the users' mailboxes using master account for example for bulk mailboxes migrations: - this one is actually perfectly possible - it requires to have enabled Allow Mailboxes Access on the SuperAdmin identity - if the SuperAdmin does not have email (which normally does not have), the login is not possible as the search is using the login name / username as email, which for standard users it is usually identical, but for the SuperAdmins it is empty and thus the record is never found and thus not authenticated - there are two way to get around it: you can manually update the core_user DB record for the SuperAdmin(s) filling the usernames into the emails (tested and it si working, but I do not like this one though) or - in `/etc/dovecot/dovecot-sql-master.conf.ext` configuration file within the line `password_query = SELECT email AS user, password FROM core_user WHERE email='%u' and is_active and master_user` replace the email (twice) with username and restart dovecot (maybe reload is enough too) - now it is possible to do for example this using the imaplib: ```python import imaplib # for non-SSL conenctions mailbox = imaplib.IMAP4(host='mail.domain.tld', port=143) # for SSL connections mailbox = imaplib.IMAP4_SSL(host='mail.domain.tld', port=993) typ, data = mailbox.login('first.last@domain.tld*admin', 'password') print(mailbox.list()) mailbox.close() mailbox.logout() ``` The `password_query` could also be more sophisticated, such as: ```sql password_query = SELECT username AS user, password FROM core_user \ WHERE (username='%u' or email='%u') and is_active and master_user ``` BTW Should @Spitfireap be OK with this (I have not found any issues after this change), I would create a PR for this. 😉
Author
Owner

@Spitfireap commented on GitHub (Jan 8, 2023):

Feel free to open a PR. Neither me or @tonioo have worked on this I belive. Just that from my pov. If you are SuperAdmin then you should be able to access the server and simply rsync the whole dovecot folder of your domain...

<!-- gh-comment-id:1374863198 --> @Spitfireap commented on GitHub (Jan 8, 2023): Feel free to open a PR. Neither me or @tonioo have worked on this I belive. Just that from my pov. If you are SuperAdmin then you should be able to access the server and simply rsync the whole dovecot folder of your domain...
Author
Owner

@tonioo commented on GitHub (Jan 13, 2023):

That's a feature we could indeed implement in the webmail and I think updating the query is fine for master users.

<!-- gh-comment-id:1381668592 --> @tonioo commented on GitHub (Jan 13, 2023): That's a feature we could indeed implement in the webmail and I think updating the query is fine for master users.
Author
Owner

@hazho commented on GitHub (May 28, 2024):

I highly advice not to load any email (from any inbox) on web interface, while the currently authenticated user is master, there are plenty of security vulnerabilities for such action, however, to list the emails and open the email content in a sandboxed interface could be fine (although lot of tests needed), that been said, the master user should always be able to do any programmatical operations over anything (including the mailboxes) but not loading the contents of any email on web)

<!-- gh-comment-id:2136076792 --> @hazho commented on GitHub (May 28, 2024): I highly advice not to load any email (from any inbox) on web interface, while the currently authenticated user is master, there are plenty of security vulnerabilities for such action, however, to list the emails and open the email content in a sandboxed interface could be fine (although lot of tests needed), that been said, the master user should always be able to do any programmatical operations over anything (including the mailboxes) but not loading the contents of any email on web)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#1680
No description provided.