Matrix SAML SSO with Dex and MAS: keeping ADFS when moving to MAS
If your Synapse homeserver signs users in through SAML2 against ADFS and you plan to move to Matrix Authentication Service (MAS), expect a gap: MAS does not support SAML providers directly. The route the MAS documentation points to is to place a bridge such as Dex between the SAML identity provider and MAS, so that MAS talks OpenID Connect to Dex and Dex talks SAML to ADFS. The projects describe Dex as a suggestion but have not yet documented that procedure, so the configuration, claim mapping and testing are work your team or a partner will have to design and verify. Synapse's own saml2_config remains the native SAML option if you stay on Synapse authentication for now, and it is the baseline to compare against before you change anything.
Before choosing a route, confirm three things with your ADFS administrators and your Matrix operators. First, which SAML attributes ADFS sends for the Matrix localpart and display name, because Dex passes whatever claims its SAML connector maps into the token MAS receives. Second, whether your users need offline access or long-lived sessions, since Dex issues no refresh token for logins through its SAML connector, and clients that need offline access depend on refresh tokens. Third, whether the Dex SAML connector is acceptable to your security team: the Dex README marks that connector as unmaintained and likely vulnerable to authentication bypasses, which is a material risk that a bridge does not remove. Those answers decide whether Dex is a viable bridge or whether you should keep SAML inside Synapse until a supported path exists.
What you need before connecting ADFS, Dex and MAS
Connecting ADFS to Matrix through Dex and MAS touches four systems that each have their own version, storage and certificate requirements. The cards below list what to confirm in each one before any build starts, and which decisions need a named owner.
Synapse and MAS versions
Confirm the Synapse release you run and the MAS release you plan to deploy, then read every upgrade note between your current version and the target. Synapse 1.143.0 and later require PostgreSQL 14 or newer, and 1.142.0 and later require Python 3.10 or newer, so check those platform floors first. Because rolling back can be difficult after schema changes, take a verified database backup before any version change.
Synapse upgrade notesDex release and storage backend
Pin a Dex release and confirm the storage backend before you deploy. Use PostgreSQL or MySQL 5.7 or later for production, because SQLite is only suitable for standing Dex up quickly and Kubernetes CRDs may not suit a large number of users. Dex v2.46.0 was released on October 7, 2026, so confirm whether that or a later release is the one you will validate.
Dex storage optionsRisk acceptance for the SAML connector
The Dex SAML 2.0 connector is marked stable in the README, but the same README says it is unmaintained and likely vulnerable to authentication bypasses. Before build, record a written risk acceptance from the security owner, or decide to use a different route. Confirm the current status of the connector with the Dex project, because a maintenance status can change between releases.
Dex READMEWorking ADFS relying party
Create and test the ADFS relying party trust for Dex before you involve Matrix. Export the token-signing certificate and confirm its validity period, then confirm which claims ADFS releases for the Dex callback, including a stable user identifier and the email attribute your Matrix user IDs depend on. Dex issues no refresh token for SAML logins, so plan for users to re-authenticate when sessions end.
DNS and TLS for Dex and MAS
Allocate separate hostnames for the Dex issuer and the MAS endpoint, and issue certificates that browsers and servers in your network trust. Dex must present a consistent issuer URL to MAS, and the callback URLs registered in ADFS and in Dex must match exactly. Record the internal certificate authority chain, because a mismatch here is one of the most common causes of failed sign-in during setup.
Host or Kubernetes platform
Decide where Dex runs before you write its configuration. Dex is built to run natively on Kubernetes with Custom Resource Definitions, so a cluster you already operate may be the simplest home. If you run it on a host instead, name the owner for patching, backups of the Dex database, and restarts. Confirm that the platform can reach ADFS, the Dex database and MAS on the required network paths.
Choosing between Synapse saml2_config and Dex in front of MAS
Synapse can handle SAML login itself through its saml2_config setting, which uses pysaml2 and requires either sp_config or config_path. In this route the homeserver is the service provider. Synapse checks ADFS assertions and maps them to Matrix accounts, so your team keeps the SAML trust settings in Synapse's own configuration and runs no extra login service.
- Who manages login: Synapse runs the SAML flow, and your team owns the service provider settings and the ADFS metadata that Synapse trusts.
- Refresh and offline access: The available facts do not describe how Synapse's SAML session lifetime or token refresh behaves, so confirm this in the Synapse configuration manual before you set expectations for long-lived sessions.
- Connector dependence: No Dex connector is involved, so the Dex SAML connector warning does not apply. You still depend on pysaml2 and on your SAML configuration staying correct and patched.
- Future MAS move: MAS does not support SAML directly, so a later move to MAS needs a different upstream login path.
- Scope of change: Staying on
saml2_configleaves the login path unchanged for existing users, which narrows what you need to retest in the first release.
Confirm the sp_config or config_path file, the certificate rotation plan on the ADFS side, and the attribute mapping that produces each Matrix user ID before go-live.
In this route Dex sits between ADFS and MAS. Dex speaks SAML 2.0 to ADFS through its SAML connector and presents OpenID Connect to MAS. Dex is an open source federated OpenID Connect provider licensed under the Apache License 2.0, and it owns no user state. ADFS still authenticates people, and Dex passes the result along. The MAS documentation suggests this pattern but does not yet document the procedure, so the wiring is your design and needs its own test plan. The Dex README is the starting point for the connector status.
- Who manages login: ADFS authenticates, Dex brokers and issues tokens, and MAS manages Matrix sessions. That means three components to patch, monitor and back up.
- Refresh and offline access: Dex issues no refresh token for logins through the SAML connector, because SAML has no non-interactive way to refresh assertions. Users must sign in again when sessions end, so test session expiry with live client sessions.
- Connector dependence: The Dex README marks the SAML 2.0 connector as unmaintained and warns that it is likely vulnerable to authentication bypasses. This is the central risk of this route.
- Storage: Dex needs a storage backend. The Dex docs allow PostgreSQL or MySQL 5.7 or later for real workloads and SQLite only for quick trials.
- Release tracking: Dex v2.46.0 was released on October 7, 2026, so set a process for reviewing Dex releases, although the SAML connector remains the weak point.
Before choosing this route, decide whether the SAML connector risk is acceptable under your threat model and whether ADFS can offer a path that avoids it.
What changes for existing accounts depends on the route and on whether users already sign in through Synapse's SAML path. Matrix user IDs come from the identifier that your login path produces. If the mapping differs after a change, the same person can end up with a new identity. Plan the mapping before any user signs in through the new path.
- Keeping saml2_config: Users who already sign in through Synapse keep their accounts, and the change is limited to the configuration you already run.
- Moving behind MAS: Accounts must resolve to the same Matrix user IDs through Dex and MAS. The available facts do not describe the claim mapping for this path, so test it with a copy of existing users before cutover.
- Database changes: The Synapse upgrade notes warn that rolling back can be difficult because of database schema changes between releases, so take backups before any change to the login path.
- Sessions: Changing the login path may end active sessions and require users to sign in again, so tell users in advance and schedule the window with support staff.
- Pilot accounts: Use a small set of accounts that already exist on the server to confirm that each one keeps its user ID and room history.
Before scheduling a cutover, check which existing users were created through SAML, whether their identifiers follow a predictable pattern, and how the MAS migration documentation describes account linking.
The right route depends on who should own the login path, how much SAML-specific risk you accept, and whether this deployment needs MAS at all. Use the checks below to record the decision before any configuration changes, and revisit it when Synapse or Dex releases change the picture.
- Login ownership: Keep
saml2_configwhen the homeserver team should own the SAML trust directly. Choose Dex when a central identity team wants one OpenID Connect broker for several applications. - Refresh requirement: If users need sessions that continue without interactive sign-in, note that the Dex SAML route issues no refresh token, so confirm the expected session behavior first.
- Risk acceptance: The unmaintained status of the Dex SAML connector is a formal risk decision, and security owners should sign it off in writing.
- MAS dependency: Confirm with the MAS documentation whether the features you need depend on MAS, since MAS does not support SAML directly.
- Exit path: Record how you would return to
saml2_configor move to another OpenID Connect provider if the Dex route fails.
Write the decision as a short design note with the tests that will confirm each point before cutover.
Configuring Dex with an ADFS connector and MAS as its client
This sequence connects ADFS to Matrix Authentication Service through Dex, so a SAML login at ADFS produces a MAS session for a Matrix user. Each step ends with a check you can run before moving on.
Register the ADFS relying party and claims
The ADFS administrator adds Dex as a relying party trust, using the SAML assertion consumer URL that Dex exposes for its connector. They also issue the claims Dex will read, usually the user's login name or email as the name identifier and attributes such as display name and group membership. Confirm the exact Dex callback path and the claim rules against your Dex version and your ADFS documentation before you configure anything. The step is done when the ADFS metadata file is exported and a test sign-in from ADFS shows the expected claim values for one account.
Deploy Dex with a single YAML file
The platform team deploys Dex, pinning a release it has reviewed. Dex is configured through one YAML file that sets the issuer URL, the static clients and the connectors, so keep that file in version control and store secrets outside it. Use a production storage backend such as PostgreSQL or MySQL 5.7 or later rather than SQLite, which the Dex documentation reserves for quick trials. The step is done when Dex starts, serves its discovery document at the issuer URL over HTTPS, and the storage backend shows no startup errors.
Configure the SAML connector
Add a SAML 2.0 connector to the Dex configuration, pointing it at the ADFS metadata and mapping the claims that Dex uses for the user ID, email and display name. The README marks the SAML 2.0 connector as unmaintained and warns that it is likely vulnerable to authentication bypasses, so record that risk in your change record and confirm the current status with the Dex project before you approve the design. Dex issues no refresh token through this connector, which affects clients that need offline access. The step is done when opening the Dex login page and choosing the ADFS connector redirects to ADFS and returns to Dex.
Register MAS as an OIDC client of Dex
Add a static client to the Dex configuration for MAS. Set the client ID and secret, and register the exact redirect URI that MAS uses for its upstream callback, which your MAS documentation for the upstream provider describes. Restrict the allowed redirect URIs to that single value. Store the client secret in a secrets mechanism and reference it at deploy time. The step is done when Dex reloads with the new client and a test request to the Dex authorization endpoint for that client ID is accepted without an error page.
Point MAS at Dex as its upstream provider
In the MAS configuration, add Dex as an upstream OpenID Connect provider using the issuer URL, the client ID and the client secret from the previous step. Match the claim mapping so the subject and the Matrix localpart come from the claims Dex returns. Restart MAS and check its logs for a clean provider discovery. The MAS upstream setup page describes the provider entry; confirm the field names against the MAS version you run. The step is done when MAS starts with the upstream provider listed and no discovery or JWKS errors appear in the log.
Verify the ID token claim set
Sign in through the Dex login page with a test account and capture the ID token that Dex returns to MAS, using a decoder or the token response from a controlled client. Check that the subject, email, name and any group claims match what ADFS sent. If a claim is missing, fix the connector mapping in Dex before changing MAS. The step is done when a decoded token from the test account contains every claim MAS needs to build a Matrix user ID, and no claim carries data that the Matrix server should not hold.
Test login and confirm the MAS session
Start a Matrix client at your homeserver, choose the SSO login option, and sign in as the test user through ADFS and Dex. Confirm that MAS creates a session, that the Matrix user ID matches the mapping you designed, and that a second login reuses the same account rather than creating a new one. Test a user who has no access in ADFS and confirm that login fails at ADFS. The step is done when the test user reaches the Matrix client with an active session and the denied user is refused.
Mapping ADFS attributes to Dex claims and Matrix user IDs
This table traces one identity from the ADFS assertion through the Dex connector and the OIDC claims MAS reads, down to the Matrix localpart. Read each row as a hop in the chain and check that the value it passes on is the same value the next hop expects. The main takeaway is that the Matrix localpart is set by the claim you choose at each hop, so that choice needs to be fixed before any users sign in.
| Stage | What it carries | What to decide or confirm |
|---|---|---|
| ADFS assertion | NameID and any attributes the relying party trust sends, such as UPN or email | Confirm which attribute ADFS sends as NameID and whether it is persistent or transient for this relying party |
| Dex SAML connector | Dex maps assertion fields to the user identity it issues, including the user ID and email | Set the userID and username mapping in the connector config and test with a real ADFS login |
| Dex ID token to MAS | OIDC claims such as sub, email and preferred_username, which MAS receives from Dex as upstream provider | Choose the claim MAS uses to derive the subject and confirm it does not change when an email address changes |
| MAS localpart | The claim value MAS turns into the localpart of the Matrix user ID | Map a stable, unique identifier to the localpart rather than a display name or mutable email |
| Synapse saml2_config | Its own mapping from SAML attributes to a Matrix localpart, handled inside Synapse | Compare the two mappings before migration because Synapse does not pass ADFS claims through MAS |
| Existing Synapse SAML users | Accounts already created by saml2_config with localparts set by the old mapping | Confirm in the MAS migration docs how existing accounts are linked, and test one account end to end before cutover |
| Stability over time | Whether the chosen value stays the same for the life of the employee's account | Document the claim choice in the design record and agree on how renamed or re-hired staff are handled |
How a login travels from ADFS through Dex to MAS and Synapse
The login starts in the Matrix client, which sends the user to Matrix Authentication Service (MAS). MAS hands the user to Dex as an upstream OpenID Connect provider, and Dex sends a SAML authentication request to ADFS on the corporate network. ADFS returns a SAML assertion to Dex, which turns it into OIDC tokens for MAS. MAS then issues the Matrix session back to the client, with Synapse serving the Matrix APIs. Check each crossing between the corporate network and the Dex host, since the SAML hop is where signing, clock and attribute mapping problems usually appear.
Login path across three trust zones, from the Matrix client through ADFS and Dex to MAS.
Security controls for SAML login behind Dex
A SAML login through Dex passes trust across three hops: the identity provider, Dex, and Matrix Authentication Service. Each hop needs its own controls, and the weakest one decides how well the whole chain resists forged or misdirected logins. The cards below cover what to verify at each point before go-live.
Signature and certificate validation
Confirm that the Dex SAML connector verifies the signature on every assertion with the identity provider's signing certificate, and that unsigned or wrongly signed responses are rejected. Pin the expected certificate in configuration and record who owns its renewal date. Test with a deliberately altered assertion in a non-production environment, because a connector that accepts it will let anyone sign in as anyone.
Dex READMERestricting issuers and audiences
Set the connector so Dex accepts assertions only from the expected identity provider entity ID and only for its own service provider audience. Assertions from another federation partner or a test tenant with the same certificate should fail. Ask your identity team to list every relying party that trusts the same signing key, since one shared key widens the audience for any leak.
TLS on every redirect
SAML login moves browser redirects and form posts between the identity provider, Dex and MAS, so each callback URL must use HTTPS with a certificate that clients trust. Check that the Dex issuer URL, the redirect URIs registered for MAS, and the assertion consumer service URL all match exactly. Mismatched hosts or plain HTTP callbacks are common causes of failed logins and of tokens being sent to the wrong place.
Protecting Dex client secrets
The client secret that MAS uses to talk to Dex, and the Dex configuration that holds the SAML signing material, are credentials in their own right. Keep them in a secrets store rather than in plain configuration files, restrict read access to the Dex and MAS operators, and rotate them after staff changes or any suspected exposure. Confirm how your Dex storage backend (PostgreSQL, MySQL, etcd or Kubernetes CRDs) encrypts or limits access to stored client data.
Limiting which groups may sign in
Matrix access should follow directory group membership, not the fact that someone holds any account at the identity provider. Decide which groups may sign in, map them to Dex and MAS policy, and deny everyone else at the connector level. Review this list on the same schedule as joiner and leaver processes, because a group that is no longer owned by a team keeps granting Matrix access.
The unmaintained SAML connector
The Dex README marks the SAML 2.0 connector as stable but warns that it is unmaintained and likely vulnerable to authentication bypasses. This is the main risk of this route, so weigh it before choosing SAML over an OpenID Connect path to the same directory. If you proceed, pin Dex to a reviewed release, track its security advisories, and ask your security team to test the connector against bypass techniques before launch.
Dex releasesCommon failures when Dex sits between ADFS and MAS
This table lists the failures teams most often hit when Dex brokers ADFS logins into Matrix Authentication Service, with the cause and fix for each. Read it before go-live and again during testing, since several failures only appear after the first real user signs in.
| Failure | Cause | Fix |
|---|---|---|
| No refresh token for offline clients | Dex issues no refresh token when a user logs in through a SAML connector, because SAML has no non-interactive way to refresh assertions. Clients that need offline access stop working once the access token expires. | Confirm which clients need offline access before choosing Dex. Plan for users to sign in again on expiry, or use a different upstream protocol where refresh is required. |
| Redirect URI mismatch | The redirect URI registered in Dex for MAS, or in ADFS for Dex, does not match the callback URL exactly, including scheme, host, port and path. | Copy each callback URL from the MAS and Dex configuration exactly. Check each registration in ADFS, Dex and MAS after any hostname or reverse proxy change. |
| SAML clock skew | The clocks on the ADFS servers, Dex host and MAS host drift apart, so SAML assertion validity windows fail to validate. | Sync all servers to a trusted time source. Check the time on each host before troubleshooting the assertion itself. |
| Certificate rotation breaks signing | ADFS token-signing certificates rotate on a schedule, and Dex still trusts the old certificate, so assertions are rejected. | Record the certificate expiry and rollover dates. Update the signing certificate in the Dex SAML connector before rotation, and test a login after the change. |
| Unexpected Matrix user IDs | The claim Dex passes to MAS, such as the email or username, does not map to the localpart pattern you expected, so users receive IDs that differ from their Synapse accounts. | Decide the claim mapping before migration. Test with several sample accounts, including names with dots, hyphens or uppercase letters, and check the resulting IDs in MAS. |
| SQLite used in production | Dex's SQLite3 storage is documented only for standing Dex up quickly, not for real workloads, so state is lost or corrupted under load or during host failure. | Use PostgreSQL or MySQL 5.7 or later for any shared environment, and include Dex state in backups. |
| Outdated SAML connector | The Dex README warns that the SAML 2.0 connector is unmaintained and likely vulnerable to authentication bypasses, so a fault in it can let an attacker sign in as another user. | Review this risk with your security team before choosing the route. Limit exposure, watch Dex release notes and test the connector against your ADFS setup. |
Questions buyers ask about SAML SSO for Matrix
Can Matrix Authentication Service sign users in with ADFS directly?
No. MAS does not support SAML providers directly, so ADFS cannot be added as an upstream provider in the way Microsoft Entra ID or Keycloak can. The MAS documentation suggests a bridge such as Dex for SAML or LDAP sources, but the projects have not yet published a step-by-step procedure for that route. Any Dex-to-MAS setup is therefore a design you will need to build, test and own, with the trade-offs weighed before you commit. Confirm the current MAS documentation before you start, since the guidance may change.
What happens to existing Synapse SAML users when we move to MAS?
Synapse's own saml2_config keeps working for a Synapse deployment that does not use MAS, so existing users can continue to sign in that way. Moving authentication to MAS changes where login happens, so the mapping between the SAML subject and the existing Matrix user ID needs to be planned and tested before cutover. Check that each existing account resolves to the same Matrix user ID under the new route, and confirm how sessions and devices behave during the switch. The migration documentation for MAS is the first read for the order of steps.
Does saml2_config still work with Synapse when MAS is in front?
It depends on how you deploy MAS and which login flow your clients use. Synapse's saml2_config uses pysaml2 and requires either sp_config or config_path, so the service provider settings must be complete and correct before any test. Once MAS handles authentication, plan on the login path moving away from Synapse's SSO endpoints, and verify each client against the new flow. Do not assume a working Synapse SAML login proves the MAS route works. Test both paths in a staging environment with real ADFS metadata.
Why does Dex lose refresh tokens with a SAML connector?
Dex issues no refresh token when a user signs in through its SAML connector, because SAML has no non-interactive way to refresh assertions. Clients that need offline access, such as kubectl, depend on refresh tokens, so they may need users to sign in again more often. For Matrix, check how long MAS sessions must last and whether users will be forced to re-authenticate at a rate your security team accepts. This limit is a property of the SAML connector, not a configuration you can simply turn on.
Is the SAML 2.0 connector in Dex safe to rely on?
The Dex README marks the SAML 2.0 connector as unmaintained and warns that it is likely vulnerable to authentication bypasses. Your security team should treat it as a significant risk point, not a routine integration. Options to discuss include assessing the connector's exposure, restricting who can reach the Dex endpoints, and asking whether an alternative path such as ADFS with an OpenID Connect layer is available in your environment. Document the decision and its review date, since the risk will not disappear with configuration alone.
How much effort does a Dex route need from our identity team?
Effort depends on the number of ADFS relying parties, the claims you need to map to Matrix user IDs, how many environments you run, and how much testing your change process requires. Your identity team will need to provide ADFS metadata, approve the claim and attribute mapping, and review the trust configuration. Dex itself is configured through a single YAML file and needs a storage backend such as PostgreSQL or MySQL 5.7 or later, which your platform team must run. Ask any provider for the work broken down by these items in a written scope, rather than a single number.
Can our team build the Dex and MAS route alone?
Your team can build it alone if it has people who know ADFS, Synapse, MAS, Dex and Kubernetes or your chosen container platform, and time to test the route before users depend on it. The harder part is the undocumented bridge, which means your team will make design decisions the projects have not written down. A partner can take on the build, testing and handover under a fixed scope, and DeployOpen plans, implements and hardens self-hosted platforms in infrastructure you control. Whichever route you choose, confirm who maintains the Dex layer after go-live.
Why is the Dex route for MAS not fully documented yet?
The MAS migration documentation says the Dex procedure is not yet documented, so the projects have not published a tested, supported recipe for connecting SAML through Dex into MAS. That means the design choices, claim mapping and failure handling fall to the operator. Treat the route as a custom integration with its own testing and upgrade risk. Ask the Matrix and MAS projects for their current status before relying on any published guidance, and review the Dex release notes when you plan upgrades.
What DeployOpen delivers for this integration
DeployOpen delivers this integration as fixed-scope work. Before any configuration starts, the scope is agreed in writing and covers which SAML identity provider is in use (for example, ADFS), how many Matrix environments are involved, whether Synapse's own saml2_config is kept for a transition period or retired, and which parts of the Dex and MAS setup are in the work. The written scope also states who handles the ADFS side, since relying party trust settings, claim rules and certificate renewal usually sit with the client's Windows team. Ask for the scope to name each of those responsibilities explicitly, so that no step is left unowned when the work moves into the client's environment.
Within the client's own infrastructure, DeployOpen configures Dex as the connector between ADFS and MAS, sets the upstream provider entry in MAS, and checks the Dex storage backend, redirect URIs and signing keys against the target environment. Testing covers the sign-in paths that matter to users and administrators: first login of a new account, login for an existing Synapse SAML user, logout behavior, and failure cases such as a disabled directory account or an expired ADFS certificate. Because the Dex SAML connector is marked unmaintained in its own documentation, testing also records which Dex release and connector configuration were validated, so the client can judge the risk before accepting the route.
DeployOpen documents the result for the client's security and compliance team. The handover pack describes the authentication flow, the trust relationships between ADFS, Dex and MAS, the settings that control account matching, the logs that show each sign-in, and the steps used to test and roll back the change. This material helps the client's reviewers assess the design, but it is not an audit report, attestation or certification. Independent auditors and certification bodies make those determinations, and the documentation is written so that the client can provide it to them as evidence of how the system is configured.
How DeployOpen scopes, delivers and supports Matrix SSO
DeployOpen plans, builds and hands over Matrix SAML SSO through Dex and Matrix Authentication Service inside your own infrastructure. We start from your existing SAML identity provider, agree the scope in writing, and deliver a working login path that your identity, security and compliance teams can review.
How we scope
- Inventory the existing SAML identity provider, its metadata, attributes and signing certificates before any build starts.
- Agree in writing which Synapse and MAS environments, user populations and login flows the engagement covers.
- Confirm the Dex, MAS and Synapse versions to be used, and whether Dex runs on Kubernetes or on servers you control.
How we build
- Configure Dex with a SAML connector to your identity provider and an OpenID Connect client for MAS.
- Set MAS upstream provider and claim mapping so Matrix user IDs are created consistently and predictably.
- Test login, logout, account linking and failure paths in a staging environment before any production cutover.
How we hand over
- Deliver configuration files, secrets handling notes and a written record of every SAML and OIDC setting used.
- Document the SAML connector's known limits, including missing refresh tokens and the vendor's maintenance warning, for your risk owners.
- Walk your administrators through the runbook for certificate rotation, user changes and troubleshooting.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after the handover.
- Re-test the login path after Dex, MAS or Synapse upgrades, and after any change to the identity provider.
- Confirm with us during scoping which support level, response expectations and reporting your team needs.

