gromox-oidc(7gx)
gromox-oidc — OAuth bearer authentication and client provisioning
Description
Section titled “Description”Gromox validates issuer-signed access tokens for MAPI/HTTP, Autodiscover, Exchange Web Services (EWS) and the Offline Address Book (OAB). The built-in gromox-http compatibility bridge adapts Outlook's OAuth requests while preserving the original token issuer and signatures. IMAP (imap_auth_oidc) and Exchange ActiveSync (EAS) through zcore (zcore_auth_oidc, see zcore(8gx) and doc/oidc-eas.rst) use the same OpenID Connect (OIDC) verifier independently. Protocol details and interoperability findings are documented in doc/oidc-interop.rst.
Server policy
Section titled “Server policy”http_auth_outlook in gromox.cfg selects authentication for the /mapi/, /autodiscover/, /ews/ and /oab/ path families, case-insensitively:
legacy
Default. Existing Basic/Negotiate settings apply. OIDC verification is disabled. Bearer is neither advertised nor accepted.
mixed
Advertise and accept Bearer alongside the schemes enabled by http_auth_basic and http_auth_spnego. Password authentication can bypass Keycloak multi-factor authentication (MFA) in this mode. Outlook chooses among the advertised schemes.
oidc
Require OIDC access tokens. Basic, NTLM and Negotiate are rejected on these paths, including authentication retained from previous requests on the same connection.
Other paths and RPC-over-HTTP retain their existing policy. POP3, SMTP, ActiveSync and PHP-MAPI web single sign-on (SSO) are independent of this switch. IMAP enables the same token verifier separately with imap_auth_oidc=yes and ActiveSync with zcore_auth_oidc=yes, see zcore(8gx). The Outlook switch enables neither.
oauth2_authorization_uri=auto derives the authorization endpoint presented to clients from the built-in bridge and an allowlisted HTTP Host. When the Host of a request on the Outlook paths is not allowlisted, no Bearer challenge is emitted. In mixed mode Basic and Negotiate continue to work for such a request, and in oidc mode it receives a plain 401 response. An explicit HTTPS endpoint can select an external bridge. The challenge's client_id defaults to Exchange's resource application identifier, 00000002-0000-0ff1-ce00-000000000000. It is not Outlook's native client identifier. Optional oauth2_trusted_issuers is copied into the challenge when configured.
Configure the actual issuer, fixed resource audiences such as gromox-mapi, and protected mailbox identity claim in gromox.cfg. See oidc_adaptor(4gx). Issuer and audience validation are mandatory. Users must not be able to edit the selected identity claim to another mailbox's address. Fallback claims require the same protection.
Changes require a gromox-http restart and apply to all relevant endpoints served by that instance. An invalid http_auth_outlook value or an invalid challenge configuration prevents startup.
Keycloak and Outlook requirements
Section titled “Keycloak and Outlook requirements”Outlook uses the public client identifier d3590ed6-52b3-4102-aeff-aad2292ab01c. Its Windows broker redirect is:
ms-appx-web://Microsoft.AAD.BrokerPlugin/d3590ed6-52b3-4102-aeff-aad2292ab01cOutlook for iOS and Android uses the same client with the redirects msauth.com.microsoft.Outlook://auth and urn:ietf:wg:oauth:2.0:oob from Microsoft's AD FS guide. Both are listed in redirect_uris as well.
Use a dedicated public authorization code client with exact redirect URIs and resource audience mappers. Disable implicit flow, password grants and service accounts. The default bridge mode requires S256 Proof Key for Code Exchange (PKCE).
Native Web Account Manager (WAM) requires signed ID token identity claims: unique_name, either upn or email, and a nonempty oid. Map oid from Keycloak's built-in user ID property using oidc-usermodel-property-mapper with user.attribute=id. Keep this ID stable and protected. It need not be a fabricated Microsoft tenant or object GUID.
WAM reads form_post responses from a form named hiddenform. Keycloak's callback form must have this name. Apply the narrow response adjustment in the existing Keycloak proxy or its form generator. Gromox serves the OAuth endpoints but does not proxy or modify Keycloak login pages. See doc/oidc-interop.rst for the matching rule and proxy header inheritance requirements.
Classic Outlook's on-premises authentication path requires Windows authority trust and EnableExchangeOnPremModernAuth. These settings can be distributed by Group Policy. The server switch cannot establish client trust. An unmodified standalone Outlook installation is insufficient. Consult Microsoft's supported client requirements before deployment.
Compatibility bridge
Section titled “Compatibility bridge”The built-in module loads oidc_bridge.json from config_file_path at gromox-http startup. Without this file its endpoints are inactive. The bridge answers /adfs/.well-known/openid-configuration, /adfs/oauth2/authorize and /adfs/oauth2/token. The authorize and token endpoints are also reachable under /adfs/oauth2/v2.0/, the form requested by clients that select the resource through a scope, such as the iOS Mail application. That application also reads /common/v2.0/.well-known/openid-configuration on the authority host, which the bridge answers with the v2.0 endpoints. A malformed file is logged together with the reason and disables the bridge. Unknown keys at the top level or inside a clients profile make the file malformed, and the error names the key. gromox-http then refuses to start only when http_auth_outlook is mixed or oidc together with oauth2_authorization_uri=auto, because it could not produce Bearer challenges.
Keycloak discovery is not performed at startup. The bridge performs it on the first request and retries it, at most once every ten seconds, until it succeeds. Until then the /adfs/ endpoints and the /oidc/ downloads answer with HTTP 503 and the body {"error":"temporarily_unavailable"}. Bearer challenges are issued regardless, because the advertised authority depends only on the configuration and the HTTP Host. No separate bridge daemon is needed. See doc/oidc-bridge.json for an example and doc/oidc-keycloak.rst for Keycloak provisioning.
keycloak_issuer
Required exact HTTPS realm issuer. Discovery must match it. Authorization, token and JSON Web Key Set (JWKS) endpoints must use its origin. Requests cannot select another issuer or token endpoint.
public_hosts
Required nonempty array of allowed public HTTP hostnames, optionally including a port. Entries may be exact names or a wildcard matching one label, such as *.mail.example.com. Bare wildcards and matches spanning multiple labels are rejected. The raw Host header is validated. Forwarded headers do not select the authority.
authority
Default auto: derive https://HOST/adfs from the validated Host. An explicit HTTPS URL must have the /adfs path. Requests still require an allowed Host.
resources
Optional nonempty array of exact Microsoft resource URLs. If omitted, only HTTPS origins matching public_hosts, with an optional trailing slash, are accepted. Qualified resource scopes use the same restrictions. Each request selects at most one resource. These aliases do not replace JSON Web Token (JWT) audience checks.
keycloak_scopes
Required nonempty array of backing custom scopes, such as gromox_mapi. Every successful token response must grant all of them. Do not put openid, profile, email or offline_access in this array.
redirect_uris
Required nonempty array of exact redirect URIs for the fixed Outlook public client. Additional clients need an explicit clients profile.
ca_file
Optional PEM CA bundle for discovery and token requests. Otherwise system trust is used. TLS certificate and hostname verification cannot be disabled.
diagnostic
Default false. Logs only a finite endpoint category and HTTP status, never request query strings, parameter values, identities or token contents.
allow_native_broker_code
Default false. Allows the native code/form_post request with the exact broker redirect, a nonce and an allowed resource to omit PKCE. The dedicated Keycloak client must not require PKCE, which the recipe achieves by leaving pkce.code.challenge.method empty. The bridge itself rejects any challenge that is not S256 before forwarding a request. This mode lacks PKCE protection for unchallenged codes. A matching redirect URI does not prove the caller is the Windows broker.
allow_unbound_broker_tokens
Default false. Requires allow_native_broker_code. Accepts and discards tbidv2 for native code/refresh requests and requires an ordinary Bearer response. It does not verify a binding key or provide token binding replay protection. Keep it disabled when bound tokens are required.
Both options are needed for the observed native WAM flow. Signed tokens remain unchanged. Unsupported claims challenges, signed broker credentials, primary refresh token grants and other binding requests are rejected.
Scope-less requests inherit the existing Keycloak grant. The native broker's exact scope=openid refresh without resource also inherits that grant. The bridge requires openid and all configured backing scopes in the response. Other scope and resource requests retain their normal allowlist checks.
clients
Optional array of additional public client profiles. Each profile requires client_id, redirect_uris and keycloak_scopes. Unknown keys in a profile are rejected. Identifiers must be unique and cannot replace the fixed Outlook client. Each profile's backing scopes are validated independently. An Outlook mail grant cannot satisfy an EAS profile.
The optional profile resource_permissions array selects supported resource aliases: user_impersonation, .default or EAS.AccessAsUser.All. The default is user_impersonation and .default. Bare profile permissions select that profile's fixed backing grant. Qualified permissions and explicit resource values must also pass the global resource allowlist.
Profile require_pkce defaults to true. Setting it to false permits absent PKCE fields, while partial, empty or non-S256 challenges remain invalid. Every authorization request from an additional client requires state. An unchallenged request also requires nonce. Scope-less authorization is accepted only with require_pkce=false and an explicit allowed resource, and adds openid, profile, email and the profile's backing scopes. Only code/query and code/form_post responses and authorization code and refresh grants are supported. Native Outlook claims, binding and refresh exceptions do not apply to these clients.
An Apple or other EAS profile can map EAS.AccessAsUser.All to gromox_eas, with the fixed JWT audience gromox-eas. Device OAuth settings and the ActiveSync application's token verification must be configured separately. Protocol tests do not establish interoperability with a particular mobile client.
The bridge does not implement federation metadata, WS-Trust, device registration or cross-cloud discovery. Rate limiting belongs at the reverse proxy or identity provider. Reverse proxies must not log OAuth query strings or request bodies.
Client downloads
Section titled “Client downloads”The enabled bridge serves /oidc/, /oidc/outlook.reg, /oidc/thunderbird.xpi and /oidc/client.json without mailbox authentication, including when http_enforce_auth is enabled. Only these exact provisioning paths and the three implemented /adfs/ endpoints receive this exception. Unknown paths retain normal policy. Downloads use the validated public hostname. They do not contain credentials.
The Outlook registry download includes machine authority trust and the current user's on-premises modern authentication setting. Deploy both to the appropriate machine and user context, then restart Outlook.
With authority=auto, deploy trust for each hostname that can challenge Outlook, including a separate authenticated Autodiscover host. Download the registry settings from each such hostname, or configure one fixed bridge authority and trust that authority. A download from one hostname does not trust other hosts.
thunderbird_client_id
Optional dedicated public Keycloak client. When absent, Thunderbird downloads are disabled. Thunderbird uses Keycloak directly for IMAP and built-in EWS. It does not use the Outlook bridge's native client exceptions.
thunderbird_scope
Scopes requested by the generated provider. Default: openid profile email gromox_imap gromox_mapi offline_access. The example manifest in tools/thunderbird_oauth_provider requests the same list. offline_access asks Keycloak for an offline session, so that token refresh keeps working after the realm's regular SSO session has expired.
thunderbird_hosts
Optional nonempty array of exact DNS names for the provider, each allowed by public_hosts. By default the provider covers the requesting hostname. Wildcards and port numbers are not allowed in this list.
The XPI adds a custom OAuth provider to Thunderbird. Configure the mail account to use OAuth2 and TLS, and enable the corresponding HTTP or IMAP verifier with its fixed audience. Outgoing SMTP authentication is configured separately.
Validation
Section titled “Validation”Validate interactive sign-in, Bearer mailbox access and automatic refresh on the deployed client versions. Keep TLS enabled and private backend listeners inaccessible to untrusted clients. Check issuer, audience, lifetime and token type rejection, including ID/refresh tokens presented as access tokens.
tests/http_oidc_live.py checks endpoint policy and, with --token-stdin, authenticated Autodiscover. Its persistent connection sequence verifies that missing or invalid credentials cannot reuse the previous request's identity. Never put token values in command arguments or diagnostic logs.
tests/oidc_http_live.py checks public bridge endpoints, client downloads, Host-derived authorities, malformed request rejection and persistent connection authentication transitions without credentials. Use an isolated listener with OIDC-only policy and http_enforce_auth enabled.
Run make check for the verifier, HTTPS transport, bridge and client provisioning checks.
References
Section titled “References”Microsoft on-premises modern authentication and client requirements:
Protocol rationale and supporting references: doc/oidc-interop.rst.
See also
Section titled “See also”http(8gx), oidc_adaptor(4gx), authmgr(4gx)