Add Session Forwarding Authentication Mode
- Deciders: Julian Bäume
- Date: 2026-06-24
Status
Accepted
Context
Teams supported three ways to authenticate users and call the App Suite Middleware (MW) on their behalf:
- Token exchange (ADR-0011): a Keycloak service account performs an RFC 8693 exchange to impersonate the user.
- Popup / OIDC Authorization Code Flow (ADR-0014): the user authenticates directly with Keycloak in a browser popup.
- Switchboard (legacy): a proprietary impersonation API.
All three exist to manufacture an App Suite session (or a token redeemable for one) so Teams can call the MW. They require non-trivial infrastructure: a Keycloak realm and service account, JWKS trust chains, JWT validation, and — for popup mode — server-side session storage in PostgreSQL.
However, when Teams is embedded in App Suite as a microfrontend and served under the same domain as the host, the user already has a valid App Suite session: the browser holds an open-xchange-session* cookie and the host exposes the opaque session token as ox.session. The stock App Suite applications already work this way: they set no JWT, forward the session to the MW, and treat GET /user/me as both authentication and identity lookup, calling the same MW mail endpoints with exactly this session.
In other words, for the same-domain deployment the entire Keycloak/JWT/token-exchange machinery reconstructs a session the host already has.
Decision
Add a fourth authentication mode, session forwarding, selected with AUTH_MODE=session.
In this mode Teams:
- disables the JWT plugin (
jwt: false); noOIDC_ISSUERis required; - reads the App Suite session from the
?session=query parameter (set by the frontend fromox.session), falling back to theopen-xchange-session*cookie; - resolves identity by calling the MW
GET /user/mewith the forwarded session and cookies — a successful response authenticates the request and yieldsuserId/contextId; - forwards the user's own session and cookies on all subsequent MW calls, skipping
acquireToken/redeemTokenand all impersonation/token-exchange code; - validates the Yjs WebSocket the same way, with the session passed as
?session=.
The existing three modes are unchanged and remain the default when AUTH_MODE is unset.
The mechanism itself is provided by the @open-xchange/fastify-sdk sessionAuth plugin (plugins: { sessionAuth: true }), which decorates the app with verifySession. Teams enables it in session mode and wires verifySession into the API autohook and the Yjs WebSocket handler.
Consequences
Positive
- Drastically simpler deployment for the same-domain case: no Keycloak service account, no JWKS, no JWT config, and no
sessions/auth_statetables — Teams only needs to reach the middleware. - Removes the impersonation blast radius for this deployment: there is no service account that can impersonate arbitrary users.
- Matches how the App Suite host itself works, reducing conceptual surface area.
Negative / constraints
- Same-domain only. Cross-domain deployments don't receive the
open-xchange-session*cookies, so the forwarded session is rejected. Those deployments must keep one of the other modes. - No external submission. The external submission endpoint (ADR-0021) requires JWT validation, which is disabled in this mode.
- Carrying four modes adds branching to the auth path; older modes may be retired once session forwarding has proven out.

