Admin Web UI automatically logout after several hours of inactivity

Your question

Hi,

I’m running Stalwart Mail Server v0.16.24 using Docker Compose.

When I log in to the admin interface at /admin using my username and password, I get automatically logged out after leaving the page idle for several hours.

Expected behavior:
The admin session should remain active for a configurable period, or there should be a way to configure the session timeout.

Actual behavior:
After several hours of inactivity, I have to log in again to access the admin interface.

Environment:

Stalwart version: v0.16.24

Deployment: Docker Compose

Interface: Admin Web UI (/admin)

Authentication: Direct username and password login (no external identity provider)

Questions:

Is this behavior expected?

Is there a configuration option to control the admin session timeout or keep the session active for longer?

If this is not configurable, would it be possible to add such an option?

Thanks for your work on Stalwart!

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

This gives me what I need. The admin WebUI login uses Stalwart’s own OAuth server, so session length is governed by refreshTokenExpiry (default 30 days), with access tokens refreshed automatically via accessTokenExpiry (default 1h) as long as the refresh token stays valid. So being logged out after a few hours sounds more like refresh tokens not being renewed/persisted, or encryption key changes, rather than an unconfigurable hard timeout.

I have enough to answer: point to the OidcProvider token expiry settings, explain refreshTokenExpiry controls how long until re-login is required, and it’s configurable.

The admin UI session length is governed by the OAuth token settings on the OidcProvider object, not a separate “session timeout” setting. Access tokens are short lived (accessTokenExpiry, default 1h), but the WebUI should silently refresh them using the refresh token as long as it’s valid (refreshTokenExpiry, default 30d), so under normal operation you shouldn’t need to log in again for a month of inactivity.

If you’re seeing forced logout after just a few hours, it’s worth checking:

  • refreshTokenExpiry and accessTokenExpiry on the OidcProvider singleton — you can raise accessTokenExpiry or confirm refreshTokenExpiry is still at its 30-day default, not shortened.
  • Whether anything changed the OAuth encryptionKey recently, since that immediately invalidates all outstanding tokens (including refresh tokens), which would produce exactly this symptom after a restart or config reload.

These are set as JSON on the OidcProvider object, e.g.:

{
  "accessTokenExpiry": "1h",
  "refreshTokenExpiry": "30d",
  "refreshTokenRenewal": "4d"
}

found in the WebUI under Settings › Authentication › OIDC Provider.

Docs: Tokens | Stalwart

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

During this time, I switched to other tab pages. Is it the browser’s hibernation mechanism that prevents the token from refreshing automatically?

It isn’t intended. The server has no idle timeout for the admin UI: the access token lasts an hour and gets renewed with a refresh token that’s valid for 30 days, both set on the OIDC provider (token expiry).

The background tab is part of it. After a few hours away the access token has expired, so the first request when you come back triggers a refresh, and the current web UI logs you out if that single refresh fails for any reason, a network hiccup as the tab or laptop wakes up included. The new web UI that ships with 1.0 (end of this month or early November) only ends the session when the server rejects the refresh token itself.

Closing the tab or the browser will still log you out, since the session lives in that tab’s session storage. Until 1.0, raising accessTokenExpiry to a few hours makes refreshes, and with them these logouts, much rarer.