Passing OIDC tokens to Dovecot with XOAUTH2 or OAUTHBEARER

Teams that want OX App Suite users to reach mail without stored mail passwords need to confirm the supported token path to Dovecot before they build it. This page covers the method, prerequisites, configuration sequence, mapping, security, testing and failure points.

On this page

How OX App Suite XOAUTH2 with Dovecot removes stored mail passwords

An organization that wants users who sign in to OX App Suite through OIDC to reach IMAP, SMTP and ManageSieve without a separate stored mail password needs the OIDC login to produce a credential the mail layer can check. In principle, the access token from that login can be presented as an OAuth bearer credential using the XOAUTH2 or OAUTHBEARER SASL mechanisms, and Dovecot must then validate that token through its passdb configuration instead of comparing it with a password stored in a mail account. The idea is simple. The details decide whether it is workable for your users, so treat it as a design question to verify, not a setting to switch on.

The supplied sources document two parts of this path: OX App Suite's OIDC login in the OX App Suite OpenID Connect documentation, and Keycloak as an identity provider that issues tokens. They do not confirm the handoff itself, meaning whether App Suite passes the access token to the IMAP, SMTP and ManageSieve services, which Dovecot release and passdb driver validate it, and which token types, audiences and scopes are accepted. Before design starts, ask Open-Xchange to confirm the supported method, the App Suite release it applies to, and the exact Dovecot version and configuration it requires. Get that answer in writing, because the design depends on it.

Until that confirmation arrives, plan for the parts that will not change. Token lifetimes and refresh behavior determine how long a mail client stays connected, so confirm how clients that hold IMAP sessions for hours will re-authenticate. Confirm how the identity provider's signing keys are rotated and how Dovecot fetches or trusts them. Decide how revoked or disabled users lose mail access, and whether that happens immediately or at the next token check. Also confirm which clients accept XOAUTH2 or OAUTHBEARER at all, because some mobile and desktop clients will still need an application password. Those answers determine whether the stored-password removal is complete for your user base or only partial.

What must be in place before the OAuth mail path is designed

The OAuth mail path depends on several systems that already work separately. Confirm each item below against your own environment before choosing a design, because a gap in any one of them changes what the token flow can do.

OX App Suite v8 on Kubernetes

Confirm that your OX App Suite deployment is running v8 on Kubernetes and that it is installed from Helm charts with Helm 3.17.0 or newer. The token path is configured in the middleware that your Helm release manages, so a hand-edited or out-of-band install will need its configuration traced before any change. Record the exact chart and image versions in use, since the release you run determines which authentication options are available.

OX requirements

Working OIDC login for the web UI

Confirm that OX App Suite already signs users in through your OpenID Connect provider for the browser. Keycloak, licensed under Apache 2.0, is a common choice, and its current release is 26.8.1, published October 13, 2026 according to keycloak.org. Check that the same realm, client and user attributes resolve correctly, because the bearer token used for mail has to identify the same user the web login does.

OX OIDC docs

Dovecot build and passdb options

Confirm which Dovecot version and build your mail platform runs and whether it supports the OAuth2 passdb and the XOAUTH2 or OAUTHBEARER mechanisms you intend to use. Ask your mail platform team which passdb backends are already configured and how they rank, since a token-validating passdb must coexist with existing lookups. Do not assume support from a version number alone; confirm the feature set in the build you actually deploy.

Network paths and certificates

Map every connection the token travels: middleware to the IMAP endpoint, to SMTP and to ManageSieve, plus the path from Dovecot to the identity provider for token validation or introspection. Confirm which endpoints are reachable from the Kubernetes cluster, which ports are open, and whether each hop uses TLS with certificates your clients and services trust. Token-bearing sessions that cross an unencrypted or misconfigured hop expose the bearer credential.

Written support confirmation from Open-Xchange

Ask Open-Xchange in writing whether this OAuth token path is supported for your target release and your license. Supported releases follow a support commitment: a standard release is supported for 12 weeks, and an LTS release for the next LTS plus six months, so the release you pick matters. Request the confirmation to name the release, the Dovecot build and any module or license conditions, because the Operations Guide notes that some features may carry separate fees.

Support commitment

Where the token hand-off to Dovecot sits between three trust boundaries

This illustrative flow starts with the user's browser sending the login to Keycloak as the example OIDC provider, which issues tokens back to the browser. The browser then presents the bearer token to OX App Suite middleware, which would pass a token onward when it opens IMAP, SMTP or ManageSieve sessions. Dovecot passdb then has to validate the token against the issuer before the mail protocols answer. The middleware-to-Dovecot hand-off is the step to confirm with Open-Xchange, including which token type is sent and how Dovecot checks it.

Illustrative token path across identity, OX middleware and mail server trust boundaries.

Why XOAUTH2, OAUTHBEARER and Dovecot passdb decide the design

The design rests on two SASL mechanisms and one server-side capability. XOAUTH2 and OAUTHBEARER both carry a bearer token in the SASL exchange during IMAP, SMTP or ManageSieve authentication, but they differ in message format. XOAUTH2 is the older, widely deployed convention that originated with Google and many mail clients use it. OAUTHBEARER is the standardized form defined for SASL in RFC 7628. Which one OX App Suite sends, and which one your Dovecot build accepts, are separate questions that must be answered for each protocol. Confirm the mechanisms OX App Suite uses for IMAP, SMTP and ManageSieve in your release, and confirm them against your Dovecot version and its SASL configuration. IMAP, SMTP and ManageSieve do not have to accept the same mechanisms, so a setup that works for mail retrieval can still fail for sending or filter management.

A bearer token is only as trustworthy as the check the mail server performs on it. Dovecot must not accept a token simply because it is present. The validation path should confirm the token signature against the identity provider's published keys, confirm that the issuer matches the expected Keycloak realm, confirm that the audience includes the client or resource the mail service expects, and confirm that the token has not expired. Each of these checks is a decision you own. A token issued for a different application in the same realm should be rejected, and the mapping from token claims to the Dovecot username must be explicit so that a mismatch does not create a second, unintended mailbox identity. Write these expectations down before testing, since Dovecot's own documentation for OAuth2 passdb settings is the reference for what the build actually supports.

The most common failure is silent fallback. If the Dovecot build lacks the required passdb, or if token validation is not configured, the server may still offer password authentication, and OX App Suite or a client may then use a stored mail password. That defeats the purpose of the design and leaves credentials stored in the application. Plan a test that presents an invalid, expired and wrong-audience token and confirms each is refused without falling back to a password, and confirm that the stored password path is disabled for the users in scope. Because this behavior depends on your exact OX App Suite release, Dovecot version and authentication order, treat the test results as the acceptance criteria rather than assuming the design holds.

Configuration sequence for OAuth mail authentication

This sequence moves OX App Suite mail access from stored passwords to OAuth bearer tokens taken from the OIDC login, and ends with a tested path that Dovecot validates before any user depends on it. Each step closes with a check you can run and record.

  1. Confirm the supported method for your release

    Before changing anything, ask Open-Xchange in writing which OAuth mechanism (XOAUTH2 or OAUTHBEARER), which mail protocols and which Dovecot version your target OX App Suite 8 release supports for token-based IMAP, SMTP and ManageSieve login. Check the release notes and the requirements documentation for the version you run, and confirm whether token login is a supported configuration or a custom one that Open-Xchange would not support. Done when you hold a written answer naming the mechanism, the protocols and the Dovecot version, and your change record references it.

  2. Register the OX App Suite client with mail scopes

    In your identity provider (Keycloak is one option, documented separately), register the OX App Suite client for the OIDC login and add the scopes and audience that the mail server needs to accept the access token. Confirm with Open-Xchange which audience value Dovecot must see in the token, and decide whether the token is an access token or an ID token, since mail validation typically relies on the access token. Done when a test login returns an access token whose audience and scope values match the values you wrote down for Dovecot.

  3. Point Dovecot passdb at the issuer

    Configure the Dovecot passdb entry for OAuth validation so it reads the issuer's discovery document and signing keys, and set the expected issuer, audience and token lifetime handling in the same place. The Dovecot team and your platform engineers own this change, and it must match the Dovecot version confirmed in step one. Restart the mail pods in a non-production environment and check the logs for key retrieval errors. Done when Dovecot reports the keys loaded and a token signed by a different key is rejected in your test.

  4. Map the claim that carries the mail login

    Decide which token claim holds the mailbox identity, such as the email address or a dedicated login claim, and map it to the user login that Dovecot and OX App Suite use for the same account. Mismatched case, aliases or a missing claim are the most common causes of valid tokens failing at login, so test users with aliases and mixed-case addresses. Done when a token for each test account yields the expected mailbox name in the Dovecot debug log, and an account with no matching claim is refused.

  5. Pass the token through the OX middleware

    Configure the OX middleware so the access token from the OIDC session reaches the mail connection for IMAP, SMTP and ManageSieve, and confirm how it is refreshed before expiry. The exact configuration keys come from Open-Xchange's documentation for your release, so take them from there rather than from this page. Done when a session opens a mail connection with the token, and the same session after the token expires either refreshes cleanly or prompts the user to sign in again, without a stored password being used.

  6. Disable stored-password login for moved protocols

    For each protocol that now uses tokens, disable password-based login for those users or restrict it to a named exception list, and document the exception owner and review date. Keep the fallback path defined so that a failed identity provider does not leave mail unavailable without a decision. Done when a password-based IMAP login for a migrated test account is refused, and the exception list in your change record matches the accounts that still log in by password.

  7. Run a controlled pilot with expiry tests

    Run a pilot with a small group of test accounts across IMAP, SMTP and ManageSieve clients. Test that a valid token is accepted, that an expired token is rejected with a clear error, that a token signed for a different audience is rejected, and that a disabled user loses access after the identity provider revokes the session. Record each result with the time and the Dovecot log line. Done when every test case has a recorded result and no case unexpectedly passes, before you widen the rollout.

Which token claims map to which mail identity

This table compares each identifier in the OIDC token with the OX App Suite user, the context and the mailbox that Dovecot resolves for IMAP, SMTP and ManageSieve. Read the check column as the test to run in your own environment, and treat rows marked as to confirm as design decisions you must verify before any user relies on the setup.

ItemSource systemTarget systemCheck
OIDC subject (sub)Keycloak ID token or access token, sub claimOX App Suite user record linked to the external identityConfirm the sub value is stable per user and matches what OX App Suite stores for the login mapping (to confirm in your environment)
Login name or email claimToken claim such as preferred_username or email, as configured in KeycloakOX App Suite login name used to resolve the context and userConfirm which claim OX App Suite reads and that it is unique across contexts (to confirm in your environment)
OX App Suite user and contextOX App Suite user and context IDs resolved from the token during OIDC loginSession identity used by the middleware when it requests a mail tokenTest with two users in different contexts to confirm each receives only its own mailbox
Mailbox name Dovecot resolvesUsername string passed from OX App Suite to DovecotDovecot passdb lookup and mail location for the accountConfirm the username format Dovecot expects (for example, full address or local part) matches the passdb configuration (to confirm with your Dovecot setup)
Token audience (aud)Access token issued to the OX App Suite clientDovecot token validation for the IMAP, SMTP and ManageSieve servicesConfirm Dovecot accepts only tokens whose audience names the intended mail service (to confirm in your environment)
Token expiry (exp)Access token lifetime set in KeycloakDovecot validity check at each new authenticationConfirm expired tokens are rejected and that long-lived mail sessions refresh or reauthenticate as your policy requires
Scope or role for mail accessScope or client role assigned to the user in KeycloakPermission to open IMAP, SMTP or ManageSieve sessionsConfirm users without the mail scope or role are denied on each protocol, not only on the web UI
Mail service grant per protocolScope granted for IMAP, SMTP or ManageSieveDovecot service-level authorizationTest each protocol separately, since a grant for one service does not confirm the others (to confirm in your environment)

Security settings that keep tokens from becoming a new weak point

Moving IMAP, SMTP and ManageSieve from stored passwords to OIDC bearer tokens removes one secret but adds a token that can be replayed, logged or outlive a disabled account. The cards below cover the checks that keep that token scoped, short-lived and revocable across the OX App Suite, Dovecot and Keycloak chain.

Validate issuer, audience and signature

Dovecot should accept a bearer token only after checking that it was signed by the expected Keycloak realm, that its issuer matches that realm exactly, and that its audience names the mail service rather than another client in the same realm. Confirm this with a token from a different client and a token signed by a test key, and both should be refused. Without the audience check, a token issued for another application in the realm could open a mailbox. The audience check is the control most often skipped in a first rollout.

Keycloak docs

Keep token lifetimes aligned with sessions

Access tokens for mail should live no longer than the web session that produced them, so a session ended by the identity provider does not leave a long-lived mail credential behind. Set the access token lifetime in the Keycloak realm and test what happens to an IMAP connection that stays open past expiry, since clients may reconnect silently with a refresh flow. Ask the mail client vendors you support how they behave at expiry before choosing a value.

Keep tokens out of logs and client storage

A bearer token in a Dovecot debug log, a proxy access log or a web client's local storage is as usable as a password. Turn off token logging in Dovecot and in any proxy or ingress in front of it, and review what the OX App Suite middleware writes when it passes the token to the mail backend. On the client side, confirm that tokens are held in memory where the browser allows it, and that stored copies are cleared at logout.

Restrict which protocols accept bearer tokens

Enable XOAUTH2 or OAUTHBEARER only on the listeners and services that need them, typically IMAP, SMTP submission and ManageSieve on their secured ports, and keep plaintext listeners refusing bearer authentication. Decide which client types are allowed to use tokens, since legacy clients that cannot handle OAuth may push teams back to stored passwords. Write this policy down so exceptions go through review rather than being added quietly to the Dovecot configuration.

Handle revocation and disabled users

A disabled account in Keycloak does not automatically end a mail session that already has a valid access token. Plan how a disabled or removed user is cut off: shorter token lifetimes, Keycloak session termination for that user, and a check that Dovecot rejects new connections once the account is inactive. Test this with an open IMAP session, because it is the case a stolen or leaver account will exercise.

Hold Keycloak updates on manual approval

When Keycloak is the identity provider, the token format, claim names and signing behavior that Dovecot depends on can change between releases. The Keycloak Operator documentation strongly recommends manual approval mode for operator updates to avoid unintended automatic upgrades. Use that mode, and retest the mail token path against the new release in a staging environment before approving an update that touches the realm or the Keycloak version.

Operator installation

Testing IMAP, SMTP and ManageSieve as separate paths

IMAP is usually the first path to test because mail reads, folder listings and push-style sync all depend on it. Run each case with a raw IMAP client or a test harness so you see the exact authentication exchange, not only what the mail client displays. Record the mechanism the server advertises in its capability response and the mechanism the client selects.

  • Valid token login: Authenticate with a fresh access token from the OIDC login and confirm the mailbox opens and lists folders.
  • Expired token: Present a token past its lifetime and confirm the server rejects it with a clear authentication failure.
  • Token for a different user: Use a valid token for user A to open user B's mailbox and confirm the login fails.
  • Wrong audience: Present a token issued for another client or resource and confirm Dovecot refuses it.
  • Disabled account: Disable the user in the identity provider, then confirm both a new login and a reused token are refused.

Also confirm the stored-password fallback: a client configured with an old password should not get in once the mailbox is switched to token-only login. Confirm the supported IMAP mechanism with Open-Xchange before writing these cases.

Why OAuth mail logins fail and how to diagnose them

This table pairs each common symptom of a failed XOAUTH2 or OAUTHBEARER login with its likely cause and the first check to run. Work down the rows in order, because several symptoms share a cause and the passdb log entry usually settles which one applies. The main takeaway is that a failed token check often looks like a password problem, so confirm that no stored password is silently accepting the login before you change anything.

SymptomLikely causeFirst check
Token rejected as expired or not yet validClock skew between the OIDC provider, the OX middleware and the Dovecot hostsCompare the exp, iat and nbf claims with the UTC time on each host and check NTP sync
Token rejected with an audience mismatchThe access token's aud claim does not name the resource Dovecot expectsDecode the token and compare aud with the value configured for the Dovecot OAuth2 validation
Token rejected with an issuer mismatchThe iss claim differs from the issuer URL in the Dovecot configuration, often by a trailing slash or a different hostnameCopy iss from the decoded token and match it character for character against the configured issuer
Login fails with no OAuth attempt in the logpassdb for IMAP, SMTP or ManageSieve does not include an OAuth2 or bearer backend, so the token is never checkedRun doveconf and confirm the passdb block for each protocol lists the OAuth2 driver
Client connects but authentication is refusedThe mail client sends a plain password or an unsupported SASL mechanism instead of XOAUTH2 or OAUTHBEARERRead the client's SASL mechanism list in its debug log and check the mechanisms advertised in the server greeting
Token accepted but the wrong or no mailbox opensThe claim used to derive the mailbox name does not match the login name the mailbox is stored underCompare the chosen claim value in the passdb log entry with the mailbox name in the user database
Web login works but mail login failsThe token is scoped for the web application, lacks the mail scope or was issued to a different client IDDecode a token from the mail login path and compare its scope and azp claims with the web session token
Mail works, but a stored password still gets inA fallback passdb entry accepts the account password when the OAuth check fails, so the failure is hiddenDisable the password backend in a test account and retry, then check which passdb entry logged the success

Questions teams ask before building OAuth mail login

Can our own team build OAuth mail login without a partner?

Yes, if you have people who already run an OIDC identity provider, a Dovecot mail stack and a test tenant to break things in. The work sits across three areas: the identity provider's client and token settings, the OX App Suite side that carries the login token into mail sessions, and the Dovecot passdb and token validation that accepts it. Most teams find the hard part is not the first working login but the failure paths: expired tokens during a long IMAP session, clients that do not support XOAUTH2 or OAUTHBEARER, and token refresh behavior across SMTP and ManageSieve. Ask yourself whether your team has owned each of those layers before, and whether anyone can test every client you support.

What makes OAuth mail login take more or less effort?

Effort rises with the number of protocols you protect, since IMAP, SMTP and ManageSieve each need their own authentication path and test cases. It also rises with the identity provider, because a provider with custom token claims, short lifetimes or limited client registration options takes more configuration than a standard OIDC setup. The mail platform matters too: the Dovecot version, how passdb is layered with existing password lookups, and whether you run one mail server or several. The client mix drives testing scope, because desktop, mobile and web clients handle bearer tokens differently. Finally, the testing scope decides how many failure modes you verify before users depend on the setup.

Is OAuth mail login a one-time project or ongoing work?

Most of the build is one-time, but some parts recur for as long as the setup runs. Token lifetime and refresh settings may need adjusting after you see real session behavior. Identity provider and Dovecot upgrades can change how tokens are validated, so each upgrade needs a regression check against your mail clients. If you use Keycloak, plan for its release cadence: the project ships minor releases several times a year, and its upgrading guide covers schema migration, which should be tested in staging before production. Ask whether the scope includes a post-upgrade verification pass or only the initial build.

What do we need to provide for an OAuth mail login project?

You need at least four groups of people and assets. Identity administrators must own the OIDC client, scopes, token lifetimes and any claim mapping. Mail administrators must own Dovecot configuration, passdb order and the decision on which legacy password paths stay open during rollout. You need a test tenant or staging identity realm and mail domain with representative mailboxes, and a set of client builds that match what your users run. Finally, you need a named sign-off owner who accepts the test results and the rollback plan before production. Confirm who holds each role before the work starts, because delays usually come from missing approvals rather than technical problems.

Does OAuth mail login remove the need for stored mail passwords entirely?

It can remove the need for users to hold a mail password for the protocols you enable, but the answer depends on what remains in your environment. Legacy clients, service accounts, shared mailboxes and fallback passdb entries may still rely on stored credentials, and those paths must be inventoried before you claim the change is complete. Ask for a written list of every authentication path that stays active after rollout, and for a plan to retire or restrict each one. Confirm the exact behavior with your Dovecot version's documentation and your test results rather than assuming it from the design.

What should a written scope for OAuth mail login include?

A useful scope names each protocol in use (IMAP, SMTP, ManageSieve), the identity provider and version, the Dovecot version, and the exact clients you will test. It lists the OIDC client settings, token lifetime and refresh assumptions, and the passdb order with any password paths retained. It states the test matrix, the staging environment, the cutover and rollback steps, and the documentation handed over at the end. Ask for the named responsibilities of your team and of the partner, the sign-off criteria, and the change-control process for later upgrades. Ask for these items in writing before you compare any quote.

Do we need Keycloak specifically to pass OIDC tokens to Dovecot?

No. Any OpenID Connect identity provider that issues tokens your Dovecot setup can validate can work, but the validation approach and the token fields involved vary by provider and configuration. Keycloak is a common choice because it is open source, supports OpenID Connect and SAML 2.0, and documents high availability designs that need a synchronously replicated database. If you already run another identity provider, confirm that it issues access tokens in the format your Dovecot version expects, and that you can control token audience, lifetime and signing keys. Ask your identity team to confirm these settings before the mail design is fixed.

How DeployOpen scopes and delivers OX App Suite mail authentication

DeployOpen plans and delivers the OIDC-to-IMAP token path for OX App Suite as a fixed-scope engagement, covering the identity provider, the middleware login settings and the Dovecot passdb configuration. Each step is agreed in writing, tested against your own mail accounts and handed over with documentation your operations team can run.

How we scope

  • We confirm which mail protocols need token login: IMAP, SMTP and ManageSieve, each with its own client path.
  • We record the identity provider, token audience and scope settings that Dovecot must validate before any build starts.
  • We agree the written scope, deliverables and timeline, and list what your team must confirm about the Dovecot version and mail stack.

How we build

  • We configure the OIDC login and token handling in OX App Suite, then wire the matching Dovecot passdb and token validation settings.
  • We test XOAUTH2 and OAUTHBEARER sign-in from each supported client, including token expiry and refresh behavior.
  • We check that no mail passwords are stored in the path and that failed or expired tokens are refused and logged.

How we hand over

  • You receive configuration files, a build record and a test log showing each protocol and client path that was verified.
  • We document the fallback plan if the identity provider is unavailable, including which users lose mail access and how to restore it.
  • We walk your administrators through token lifetime settings, log locations and the steps to revoke access for a leaver.

How we support

  • Ongoing support covers Dovecot and identity provider upgrades that could change token validation behavior, available as a retainer.
  • We retest the token path after each planned change to the identity provider, OX App Suite release or Dovecot version.
  • Support scope, response expectations and retest frequency are set in the written agreement, so you can confirm them before signing.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.