Also see the dedicated surgemail.com website with knowledge base and ticketing system
SurgeMail's web admin interface (the "manager", /cgi/admin.cgi on the admin port) has a new login system. Admins log in with a form, get a session that times out, can log out, and can protect their login with multifactor authentication (MFA) using an authenticator app. Pages and links carry a security token, so another web site, email or chat message can't make the manager do things on an admin's behalf.
Both the older frames layout and the modern layout work the same way.
| Old login | New login | |
|---|---|---|
| Logging in | The browser's password prompt (HTTP Basic). | Always a login form. The browser password prompt is no longer accepted, except for scripts from addresses you list. |
| Staying logged in | The browser kept sending the password with every request until it was closed. | A session that ends after 30 minutes without activity, or 12 hours at most. |
| Logging out | Not possible, short of closing the browser. | A Logout button. |
| MFA | Not available for the manager. | Optional per admin, or compulsory for all admins. |
| Scripts using admin.cgi | Worked from any address with a username and password. | Work from the addresses listed in g_admin_relax_ip. |
If a site really can't change straight away, the old behaviour can be brought back (see Going back to the old login), but that isn't recommended.
Open the manager as usual. You get a login page asking for an admin username and password (the same admin accounts as before). After logging in you land on the manager front page.
To log out, use the Logout button:
A session ends by itself after a period without activity, or after a fixed maximum time, whichever comes first. It is also tied to the IP address you logged in from, so a stolen session cookie can't be used elsewhere. Sessions are kept in memory, so restarting SurgeMail logs everyone out. In a cluster each server has its own sessions.
| g_admin_session_time | Minutes without activity before the session ends (default 30). |
| g_admin_session_life | Maximum session length in hours, however active (default 12). |
| g_admin_session_ip_relax | Don't tie sessions to the login IP address. Only needed if admins' addresses change while they work, e.g. on mobile networks or behind several proxies. |
MFA adds a second step after the password: a 6 digit code from an authenticator app on the admin's phone (e.g. Google Authenticator, Microsoft Authenticator or Authy). Even if the password is guessed or stolen, nobody can log in without the phone.
Until an admin has MFA, the manager front page shows a red line "Multifactor authentication (MFA) is not set up for your admin login" with two links:
The same setup page is in the Manage menu (modern layout) and under Value added features (frames layout) as MFA setup. From there an admin can also set MFA up again with a new phone, or turn it off by entering a current code.
From then on, every login asks for a code after the password. Ticking Trust this browser for 30 days skips the code on that browser for 30 days; the password is still needed every time. Setting MFA up again, turning it off or resetting it forgets all browsers that admin trusted.
Set g_admin_mfa_require (Security settings, Management section, or the Config Checker's recommendation). Admins who already have MFA notice no change. An admin without MFA is taken to the setup page right after the password at their next login and can't get in until it is done, so nobody is locked out by turning it on. While it is set, admins can't turn their own MFA off.
Reset the admin's MFA from the server:
tellmail admin_mfa_reset adminuser
The admin can then log in with just the password and set MFA up again (straight away if g_admin_mfa_require is set). The code page shows this command after a few wrong codes, as a reminder.
Admin MFA is separate from user MFA: users set up their own in SurgeWeb or the user self management pages, controlled by the g_pass_twofactor and g_mfa_* settings.
Scripts that call admin.cgi with a username and password (HTTP Basic, e.g. curl -u) keep working only from the addresses listed in g_admin_relax_ip. List just the machines the scripts run on, e.g. 127.0.0.1, and use https where you can. These logins skip the login form and MFA, so keep the list short. A * entry isn't accepted. Each such login is logged for auti trail purposes.
Similar lists exist for other kinds of login. They are separate on purpose, so allowing one doesn't open the others:
| Setting | For | Effect |
|---|---|---|
| g_admin_relax_ip | Scripts using admin.cgi | Password only: no login form, MFA or page token. |
| g_user_relax_ip | Scripts using user.cgi | No MFA code for user.cgi logins; the password is still needed. |
| g_pass_twofactor_bypass | IMAP, POP, SMTP and SurgeWeb | No MFA code for those logins; the password is still needed. |
Every page the manager sends carries a security token that is unique to your session, and the manager only runs a command if the request carries it. The manager's own pages, links and forms always do, so normal use isn't affected.
A link that comes from anywhere else, such as an email, a chat message, a bookmark or another web site, doesn't have the current token. If it would run a command, you get a Please confirm page that names the command instead. Choose Continue only if you meant to do it. Plain pages (the front page, or the manager with no command) open without asking. A form posted from outside the manager is refused.
The manager also refuses commands that the browser reports as coming from another web site. If you run the manager behind a reverse proxy under a different host name, list that name in g_csrf_allow.
g_admin_ip limits which IP addresses can use the manager at all. It now applies to every kind of admin login, form and script alike.
After repeated wrong passwords or MFA codes from one address (7 by default, set with g_admin_guesses), that address is blocked for some hours after its last failed attempt. Restarting SurgeMail clears the block.
g_admin_localhost_unsafe (formerly g_admin_localhost) gives full admin access with no login at all to any connection from the server itself. That includes every program and user on the machine, and anything that forwards connections from it, such as a reverse proxy or SSH tunnel. The old setting no longer works and new installs no longer turn it on. We don't recommend using it.
The login and MFA pages are built into SurgeMail, so they work whatever templates you use. To customise them, the templates are manager_login.htm, manager_mfa.htm, manager_mfa_setup.htm and manager_mfa_done.htm, with shared styling in manager_login_style.htm. They are used only when manager_login.htm contains its version marker line, so an outdated copy can't break logins.
The older admin_login.htm template is only used with g_admin_login_revert.
g_admin_login_revert brings back the old behaviour for the whole manager: the browser password prompt is accepted from any address, without MFA. The settings g_admin_login and g_admin_login_ip then work as they used to, and a site's own admin_login.htm is used if there is one.
This is meant only for a site that is stuck. While it is on, SurgeMail logs a warning at startup and shows one on the manager front page. For scripts, list their addresses in g_admin_relax_ip instead: that keeps the rest of the manager protected.
| To… | Use |
|---|---|
| Require MFA for all admins | g_admin_mfa_require |
| Reset an admin's lost MFA | tellmail admin_mfa_reset adminuser |
| Change session timeouts | g_admin_session_time, g_admin_session_life |
| Allow changing admin IP addresses during a session | g_admin_session_ip_relax |
| Let scripts use admin.cgi | g_admin_relax_ip |
| Let scripts use user.cgi without MFA codes | g_user_relax_ip |
| Limit which addresses can use the manager | g_admin_ip |
| Change the failed login limit | g_admin_guesses |
| Use the manager behind a reverse proxy | g_csrf_allow |
| Go back to the old login (not recommended) | g_admin_login_revert |