Larvatus has no server of its own, so everything it does goes through your Stalwart server. It works out of the box, but this page covers a few settings you can optimize for this app.
Where to find Stalwart
If you don't use it already, Stalwart is a free, open-source mail server made by Stalwart Labs. You can download it and read its documentation at stalw.art. Larvatus needs version 1.0.3 or later.
Once it's running, Stalwart has two web interfaces at the same address:
- The web admin at
https://mail.example.org/admin, where you change server settings and manage accounts. The menu paths on this page are all in the web admin. - The Account Manager at
https://mail.example.org/account, where each person manages their own account. Their masked addresses are under Masked Addresses, and the apps they've signed in to are under Credentials › Connected Applications.
Out of the box
On a current Stalwart install with an HTTPS address, Larvatus will work without any changes:
- Stalwart's sign-in (OAuth) server is on by default, and it generates its keys at install.
- Larvatus registers itself the first time someone signs in, using Stalwart's anonymous client registration. You don't need to add it as an OAuth Client.
- The built-in User role already has the five masked address permissions:
sysMaskedEmailGet,sysMaskedEmailQuery,sysMaskedEmailCreate,sysMaskedEmailUpdate, andsysMaskedEmailDestroy. If you made your own roles, they need these too.
Larvatus asks for one scope, urn:stalwart:oauth:scope:settings. It covers a person's account settings, which is where Stalwart keeps masked addresses. It doesn't reach their mail, contacts, calendars, or password, or anything in the web admin. This is shown on the consent screen.
Because Larvatus registers itself anonymously, Stalwart's consent screen marks it as unverified. Every app that registers this way gets that label, if you have other people using your server you might want to warn them.
Set the public address
Stalwart builds the addresses in its sign-in metadata from its public HTTPS address. Larvatus takes the server address a person types, reads that metadata, and expects sign-in and JMAP (the protocol it uses to manage addresses) to be at that same address. If Stalwart thinks its public address is something else, sign-in fails.
- Set
defaultHostnameunder Settings › Network › General to the name people use, such asmail.example.org. TheSTALWART_PUBLIC_URLenvironment variable overrides it, so check that too. - Have people enter that exact address in Larvatus. It can't follow redirects, so an address like
https://example.orgthat redirects tohttps://mail.example.orgwon't work. - If you're behind a reverse proxy, make sure
/.well-known/,/login,/auth/, and/jmapare passed through on that hostname. - Also behind a proxy, tell Stalwart where the real client address is: set
clientIpSourcein the HTTP settings toxForwardedFororforwarded, or list the proxy inproxyTrustedNetworksif it speaks the PROXY protocol. Stalwart rate-limits anonymous requests like client registration and sign-out, and without the real address all of them look like they come from your proxy.
Raise the address limit
Stalwart lets each person have 5 masked addresses by default. That runs out fast when people give every site its own address, which is the whole idea.
- For everyone: change
maxMaskedAddressesunder Settings › Email › Defaults. - For one account: add
maxMaskedAddressesto that account's quotas under Management › Directory › Accounts. It overrides the default for that account.
Switched-off addresses still count toward the limit, only deleting one frees up room. Larvatus can't read the limit, so people find out when they reach it and Larvatus shows Stalwart's "You have exceeded your account quota" message.
Keep people signed in
Token lifetimes are under Settings › Authentication › OIDC Provider. Values are in milliseconds, and changes take effect after you reload settings.
refreshTokenExpiry(default 30 days) is an idle timeout. The clock restarts every time Larvatus refreshes its sign-in, so people only have to sign in again if they don't use Larvatus for 30 days.accessTokenExpiry(default 1 hour) can stay as it is. Larvatus refreshes it on its own.
Two things sign people out of Larvatus:
- Changing the OIDC provider's
encryptionKey. Stalwart derives the ID of every self-registered app from this key, so changing it signs out every copy of Larvatus at once. In a cluster, every node needs the same key. - Changing an account's password. This revokes every app signed in to that account. Turning on two-factor authentication or adding an app password doesn't.
People can remove Larvatus under Connected Applications in the Account Manager, and choosing Disconnect in Larvatus revokes its sign-in on the server too.
Domains
Stalwart always uses the domain of the person's primary account name. Larvatus can't change it, so an account named sam@example.org gets addresses like harbor.p3w8zt@example.org.
If something goes wrong
- Sign-in fails right away: check the public address, that the server is reachable over HTTPS, and the proxy paths above.
- Larvatus says the account needs the JMAP management capability: the account's role is missing the masked address permissions. If you upgraded from an earlier version of Stalwart, built-in roles don't get new permissions automatically. Start Stalwart once with
STALWART_UPDATE_ROLE_PERMISSIONS=true(read their documentation to find out what else this may change), then remove the variable. - People keep getting signed out: check
refreshTokenExpiry, and that theencryptionKeyisn't changing between restarts or differing between nodes.
Stalwart's own documentation on masked addresses and OAuth has the full details. To report another bug, you are welcome to contact support.