How authentik signs Matrix users in through MAS
The supported method is to connect authentik as an upstream OpenID Connect provider for Matrix Authentication Service (MAS), and MAS, not Synapse, then issues the Matrix session. Users sign in to authentik, authentik returns an OIDC identity to MAS, and MAS maps that identity to a Matrix user ID and hands the client its tokens. This split matters for planning: the authentik side is an OAuth2/OIDC application and provider, while the Matrix side is configured in MAS's upstream provider settings, so both teams need to agree on the redirect URI, client credentials and the claim that becomes the Matrix localpart before anyone creates accounts.
The authentik project is documented among the upstream OpenID Connect providers MAS supports, alongside Keycloak, Microsoft Entra ID and Google, so authentik is a documented path rather than a custom integration. SAML is not an option in MAS. If your authentik estate uses SAML for other applications, that application's SAML configuration stays where it is, and Matrix needs a separate OIDC application in authentik. The MAS documentation recommends a bridge such as Dex for SAML or LDAP sources, which is a different design from this one and should be decided before you build. Confirm the exact provider and claim settings against the current MAS upstream provider page for your MAS version.
On licensing, authentik's core code is under the MIT license, while code in the authentik/enterprise/ directory falls under a separate enterprise license. Standard OIDC provider configuration for this use case does not depend on the enterprise directory, but the edition question still matters: the authentik pricing page lists Enterprise-only features such as Microsoft Entra ID and Google Workspace integrations and enhanced audit logging. If your Matrix sign-in design relies on any of these, get the edition and license terms confirmed in writing before the build starts, and check the current authentik pricing page for what each edition includes.
What you need before configuring authentik and MAS
Four components and two network decisions have to be settled before anything is configured. Each card below names one item to confirm, the version or setting to check, and the failure it prevents when the MAS upstream entry is later written.
A supported authentik release line
Run an authentik release on a line that still receives security fixes. The authentik security policy lists 2026.5.x and 2026.8.x as supported. Confirm the exact patch level in your own environment, and plan to follow security releases, which the project announces at least 24 hours in advance. A deployment on an unsupported line leaves the identity provider in front of every Matrix login without fixes.
Security policyA Synapse server name that will not change
Before MAS is introduced, fix the server_name of the Synapse homeserver and the public URLs clients use. The server name is embedded in every user ID (for example @user:example.com) and in room identifiers, so changing it later means a different set of accounts. Record the current value from homeserver.yaml and confirm that federation delegation, if used, already points where you intend.
A dedicated PostgreSQL database for authentik
authentik stores all configuration and data except uploaded files in PostgreSQL, and in recent releases it also handles caching, tasks and sessions that earlier versions sent to Redis. Create a separate database and role for authentik rather than sharing Synapse's database. Confirm the PostgreSQL version the chosen authentik release supports, and plan backups for it before go-live.
authentik architectureA host sized for the Compose guide
The authentik Docker Compose guide calls for a host with at least 2 CPU cores and 2 GB of RAM, and positions Compose for test setups and small-scale production. Treat that as a floor. A production deployment serving every Matrix login needs capacity for the server and worker containers and PostgreSQL together, so size it from your user count and load tests, and confirm the platform choice (Compose or Kubernetes) with your operations team.
- Minimum host size
- 2 CPU, 2 GB
DNS and TLS for both hostnames
MAS and authentik each need their own public hostname with a valid TLS certificate, for example one for the MAS endpoint that Matrix clients reach and one for the authentik sign-in pages. Confirm that both names resolve to the intended hosts, that certificates chain to a trust store your clients use, and that renewal is automated. Certificate or DNS errors surface later as failed discovery or token requests, which are harder to trace.
The redirect URI MAS will send
MAS sends users to authentik and expects authentik to return them to a callback URL on the MAS host. Decide that exact URL before you create the authentik provider, because the redirect URI registered in authentik must match it character for character, including scheme, host and path. Confirm the callback path in the MAS upstream identity provider documentation for your MAS version, and write it down so the authentik and MAS configurations use the same value.
MAS upstream providersConfigure authentik, then MAS, then test a login
This sequence connects authentik to Matrix Authentication Service as an upstream OpenID Connect provider, so Matrix users sign in through authentik and receive predictable Matrix user IDs. Each step ends with a check you can run before moving on.
Confirm the authentik and MAS versions in use
Before changing anything, record the authentik version your team runs and the MAS version your homeserver uses. Check the authentik security policy to confirm your version is on the supported list, and read the MAS upstream identity provider documentation for the configuration keys your MAS release expects. Ask your identity team who owns the authentik instance and who can approve a new OAuth2/OIDC application. The step is done when you have written down both versions and a named approver.
Create the OAuth2/OIDC provider in authentik
In authentik, create an OAuth2/OIDC provider for Matrix and bind it to a new application. Set the redirect URI to the callback path that MAS documents for upstream providers, using your MAS public URL and the stable provider ID you plan to use. Request the standard OpenID scopes and any profile or email scopes your user ID mapping needs. Restrict the application to the groups allowed to sign in. The step is done when the provider saves without errors and the application appears in the authentik application list.
Record the client ID, secret and issuer URL
Copy the client ID and client secret from the new authentik provider into your secrets store, not into a shared document or ticket. Note the issuer URL, which in authentik is specific to each application slug. Open that issuer URL with a
/.well-known/openid-configurationsuffix in a browser or with curl from the MAS host. The check passes when the discovery document loads over HTTPS and lists the authorization, token and userinfo endpoints. If the document does not resolve, fix DNS, TLS or the application slug before continuing.Add the upstream provider entry to MAS
Add an upstream OpenID Connect provider entry to the MAS configuration file. Use a stable provider ID, because it becomes part of the redirect path and is referenced by the migration settings if you move existing Synapse SSO users. Set the issuer, client ID and secret, and the claim mapping that produces your Matrix localpart. Load the client secret from an environment variable or secret file rather than writing it inline. The step is done when the configuration file validates with the MAS config check command your release provides.
Restart MAS and confirm the provider is listed
Restart the MAS service so it reads the new upstream provider. Open the MAS login page in a browser and confirm that a button or link for authentik appears. Check the MAS logs for startup errors, especially discovery failures or certificate trust problems on the authentik issuer. The check passes when the login page lists the authentik provider and the logs show no errors about the upstream connection. If the provider is missing, compare the provider ID and the config file path with what the service loaded.
Run a test login with a new account
Sign in with a test user from an Element client or the MAS login page using the authentik option. Complete the authentik login and the consent prompt if one appears. Confirm that MAS creates the account and that the Matrix user ID matches the pattern your claim mapping should produce. Use a test account that is not used for real staff, and record the exact user ID returned. The step is done when the test user reaches the Matrix client and their user ID matches the expected value.
Check existing Synapse SSO users before cutover
If accounts already exist from Synapse OpenID Connect, do not run a cutover on production users yet. Compare the Synapse oidc_providers entry with the MAS provider, and confirm that the MAS provider uses the synapse_idp_id value that the MAS migration documentation requires for your provider type. Sign in with one existing test account on a staging homeserver and confirm it keeps its previous Matrix user ID and room membership. The step is done only when that test account keeps its identity; if it does not, stop and resolve the mapping before migrating anyone else.
Document the configuration and set a review point
Record the authentik application slug, provider ID, redirect URI, claim mapping, secret storage location and the MAS version in your operations runbook. Name the owner for the authentik application and the owner for the MAS configuration, and agree who approves changes to either. Schedule a review after each authentik or MAS upgrade, since redirect paths and configuration keys can change between releases. The step is complete when the runbook entry is reviewed by both the identity and Matrix administrators.
How a login travels from Matrix client to authentik and back
The login starts in a Matrix client, which sends the user to Matrix Authentication Service (MAS). MAS hands the user to authentik as its upstream OpenID Connect provider, and authentik returns an authorization code to MAS's callback URL on the internal side of the boundary. MAS exchanges that code, then issues the Matrix session to the client, and Synapse accepts the token MAS issued. Check that the issuer URL in MAS matches authentik exactly and that the callback URL is registered in the authentik application.
Login sequence across the Matrix client, MAS, authentik and Synapse.
Keeping existing Synapse SSO users on their accounts
If your Synapse homeserver already signs users in through an authentik entry in oidc_providers, the migration is mainly a matter of identifiers. Matrix Authentication Service (MAS) must define an upstream provider for each Synapse OIDC provider in use, and that entry must carry a synapse_idp_id that matches the Synapse configuration. For Synapse entries, the MAS value follows the pattern oidc-<idp_id>, so an entry with idp_id: authentik in Synapse maps to oidc-authentik in MAS. When the identifiers line up, MAS recognizes the link between each user's authentik identity and the Matrix account that already exists, instead of creating a second account.
- Inventory every provider: List each
oidc_providersentry in the Synapse configuration, not only the one users see most often. Each one needs its own MAS upstream entry. - Match the identifier exactly: Confirm the
synapse_idp_idvalue in MAS against the Synapseidp_idafter applying theoidc-prefix. A mismatch is the most likely cause of duplicated accounts. - Keep the authentik subject stable: Check that the user claim authentik sends matches what Synapse already stored for each user, so the same person resolves to the same identity.
- Run the migration steps from the MAS documentation: Follow the migration guide for the order of operations rather than improvising the cutover.
- Test with real account types: Include administrators, service accounts and users with multiple devices in the staging copy.
Before cutover, confirm in staging that a known test user signs in through MAS and lands on the same Matrix user ID as before.
If your homeserver uses SAML, CAS, a password-only setup or no SSO at all, there is no oidc_providers identifier to carry over. The linking question changes: you need to decide how each existing Matrix user ID will be attached to an authentik identity, and whether that attachment can be made reliably. Synapse account records are keyed by Matrix user ID, so the mapping must produce the same localpart and domain that users already have. Without that, MAS will create new accounts for people who already own rooms, history and devices.
- Identify the current login method: Record how each user authenticates today, including any SAML or CAS flows, which may need a different route through Dex or another bridge.
- Map identities to existing user IDs: Build a list that pairs each authentik account with the Matrix user ID it should keep, and review exceptions manually.
- Plan for accounts that cannot be matched: Decide whether unmatched users are retired, recreated or left for a supervised review.
- Check password-based accounts: Users who signed in with a local password need an explicit decision on whether they keep a credential, move to SSO or are deactivated.
- Document the decision with the identity owner: The mapping list is an access control record, so keep it under the same change control as the configuration.
Before any cutover, confirm that the matching list reconciles with the current Synapse user table and that no existing user ID would be left without a login path.
A staging copy of the homeserver is the only safe place to prove that linking works. It should use a recent copy of the production database, the same server_name, and an authentik test application configured with the same redirect and client settings as production. The goal is to show that each test user signs in through MAS, reaches the account they had before, and keeps their rooms, devices and encryption state. Run these checks against the staging copy, not against production, and record the results so the change has evidence behind it.
- Sign-in for each provider: Test every upstream provider, with at least one account per provider and one per user category such as administrators.
- Same Matrix user ID: Confirm the user ID after login is unchanged and no new duplicate account appears in the user list.
- Rooms and history: Check that joined rooms, message history and admin roles carry over.
- Devices and encryption: Verify that existing devices and key backups remain usable after the change, since session behavior can differ after migration.
- Rollback path: Confirm that you can restore the staging database and that the Synapse upgrade notes on rollback limits are understood before production cutover.
Before production, confirm that every test result matches the expected user ID and that the rollback procedure has been rehearsed.
For users, the change should feel small, but it is not invisible. Sign-in moves from Synapse's own SSO flow to a MAS-hosted flow, so the login page, redirects and session handling are different. Users may be asked to sign in again on some clients, and some older clients may need an update before they work with MAS. Communicate these points before cutover so people do not assume the account is lost when they see a new screen.
- Expect a new login screen: Users are redirected through MAS, so bookmarks and login links in internal documentation may need updating.
- Re-authenticate on each client: Plan for every client to sign in again, and list the clients your organization supports.
- Check client compatibility: Confirm with the Element and other client vendors which versions support MAS before asking users to upgrade.
- Prepare a help path: Give users one channel for failed sign-ins, and have administrators check the user ID when someone reports a duplicate.
- Watch the first day: Review sign-in errors and newly created accounts during the first working day after cutover.
For the production change, confirm the user communication plan and the support path before the cutover window opens.
Mapping authentik claims to Matrix user IDs
This table compares each claim or field that links authentik to Matrix, what it controls in MAS, and how it affects whether a user matches an existing Synapse account or gets a new one. Read it before you write the MAS upstream provider entry, because the claim choices are hard to change after users have signed in. Confirm exact claim names and template options against the MAS upstream documentation for your version.
| Field | Role in the mapping | Effect on existing Synapse accounts |
|---|---|---|
| authentik subject (sub) | Stable unique identifier for the user in the upstream provider | Strongest match key when MAS links the upstream identity to the old Synapse account; confirm how MAS stores it during migration |
| authentik username | Human-readable login name, often proposed as the Matrix localpart | Matches only if it equals the localpart Synapse already issued; renames in authentik can create a mismatch |
| Email claim | Contact address and, in some setups, a matching input | Can help match accounts, but only trust it if authentik verifies email addresses and you have confirmed the MAS behavior |
| Display name | Shown in Matrix clients; does not identify the user | No effect on matching; safe to change without creating a new account |
| Group claims | Optional input for access decisions, if you pass groups through | Does not change account matching; use them for admin or access rules, and confirm the claim is included in the token |
| MAS upstream provider ID | Internal identifier for the authentik entry in the MAS configuration | Must stay fixed once users sign in, since it ties the upstream link to the stored identity |
| synapse_idp_id | Value that links the MAS provider to the Synapse oidc_providers entry during migration | Must be set to oidc-<idp_id> to match the Synapse entry; a wrong value causes existing users to be treated as new |
| Matrix localpart and server_name | Final Matrix user ID, such as @user:example.com | Fixed by your template and server_name; changing either later creates different IDs for the same person |
Hardening the authentik to MAS trust relationship
The authentik to MAS connection is a trust relationship: authentik issues identity assertions that MAS accepts as proof of who a Matrix user is. The cards below cover the controls that keep that trust narrow, from the client secret and application access to TLS, redirect URIs and audit evidence.
Keep the client secret out of config files
The OIDC client secret that MAS uses to authenticate to the authentik provider is effectively a password for the trust link. Store it in a secrets manager or an encrypted secret store, inject it into the MAS configuration at runtime, and keep it out of version control and shell history. Plan a rotation step that updates both the authentik provider and the MAS upstream entry in one change, then confirm MAS still starts and completes a login afterward.
MAS upstream provider docsRestrict the application to intended users
In authentik, bind the Matrix application and its provider to a defined group or policy so that only the people who should have Matrix accounts can complete the OIDC flow. Without a binding, any authentik user who can reach the login page may be able to create a Matrix identity through MAS. Test with one account outside the group and confirm it is refused, then review the binding whenever group membership rules change.
Enforce TLS on issuer and MAS endpoints
The issuer URL, authorization, token and userinfo endpoints on the authentik side, and the public MAS URLs, should all be served over HTTPS with certificates that MAS trusts. Check that the issuer value in the MAS upstream entry matches the authentik issuer exactly, because mismatches surface as failed discovery rather than clear errors. Confirm the certificate chain validates from the MAS host itself, not only from a browser.
authentik provider docsLimit redirect URIs to exact values
Register the MAS callback URI for the upstream provider as a single exact value in authentik, not a wildcard or a broad prefix. Each extra redirect URI is a place where an authorization code could be sent. Compare the registered URI character by character with the one MAS generates, including the trailing path and scheme, and remove any leftover entries from earlier test hostnames or from the old Synapse SSO setup.
Review authentik audit logging
Decide what evidence you need about sign-ins, provider changes and secret rotations before go-live, then check whether the audit events you need appear in the authentik event log and how long they are retained in your deployment. Enhanced audit logging is listed as an enterprise-only feature on the authentik pricing page. Ask the vendor or your auditor which events must be retained and whether the community edition covers them, then decide whether an upgrade is required.
- Enhanced audit logging tier
- Enterprise
Confirm which enterprise controls you need
The authentik pricing page lists mTLS client certificate authentication, privileged access management, password history and enhanced audit logging as enterprise-only features. Map each one to a requirement in your security policy or assurance framework before deciding. Not every control is needed for a Matrix OIDC link, and some may already be covered by TLS, group binding and log export. Ask authentik for current edition details and confirm the scope in writing.
authentik pricingLogin failures and what usually causes them
This table pairs common sign-in failures between authentik and Matrix Authentication Service with their usual causes and fixes. Read each row by symptom first, then check the cause column against your authentik provider and the MAS upstream entry before changing anything.
| Symptom | Usual cause | Fix |
|---|---|---|
| Redirect error after authentik login | Redirect URI in the authentik provider does not exactly match the callback URI MAS sends | Copy the MAS callback URI for the upstream provider into the authentik provider's redirect URIs, matching scheme, host, port and path exactly |
| MAS fails at startup or shows no upstream login button | Issuer URL is wrong or the discovery document at the issuer's well-known path is unreachable from the MAS host | Confirm the issuer URL includes the application slug authentik expects, then fetch its discovery document from the MAS host, not only from your browser |
| Sign-in creates a second account instead of reusing the old one | Missing or wrong synapse_idp_id, so MAS does not link the existing Synapse SSO identity | Set synapse_idp_id on the MAS provider to the matching oidc_providers idp_id, using the oidc-<idp_id> form, then re-test with an existing user |
| Token exchange fails after rotating the authentik client secret | New secret was saved in authentik but not in the MAS upstream provider configuration or its secret file | Update the client secret wherever MAS reads it, restart MAS, and confirm the old secret is no longer accepted |
| ID token rejected as not yet valid or expired | Clock skew between the authentik host and the MAS host, or between either host and the browser's token timing | Sync both servers to a trusted time source and check time offset on each host before changing OIDC settings |
| Intermittent errors and slow logins after an authentik upgrade | PostgreSQL connection limit reached, since the 2025.10 release notes warn of roughly 50% more connections than before | Review max_connections and pooling on the PostgreSQL side, and watch connection counts during the upgrade window and afterward |
Questions buyers ask before adopting authentik with MAS
Is the authentik open-source edition enough for a Matrix SSO integration through MAS?
For a basic OpenID Connect sign-in, the open-source edition covers the provider type you need, because authentik documents OAuth2/OIDC providers as a core provider type and MAS lists authentik among its documented upstream providers. The pricing page places Google Workspace and Microsoft Entra ID integrations, mTLS client certificate authentication, enhanced audit logging and privileged access management in the Enterprise tier, so check whether any of those are required by your identity design. The authentik repository puts most code under the MIT license, while code in the enterprise directory uses a separate license. Confirm the edition against the authentik pricing page and the license terms before you commit to a design.
What actually drives the effort of this integration?
Three factors matter most. The first is how many Synapse users already sign in through an existing SSO provider, because each upstream provider in Synapse needs a matching MAS provider with synapse_idp_id set, and existing accounts must be mapped so they keep their identities. The second is the number of upstream providers, since each one adds configuration, claim mapping and test cases. The third is testing scope: sign-in, logout, account linking, admin access and client behavior across every Matrix client your users run. A single provider with a small, non-production test plan is a much smaller job than several providers with staged rollout and rollback rehearsal.
How long does a migration to MAS with authentik take?
Duration depends on scope and staging, and no reliable figure applies across environments. Ask for a timeline tied to the number of providers, the size of the existing user base, the number of environments that must be built (typically a test copy before production), and the change window your organization allows. The upstream migration steps for MAS must be completed in a set order, so plan time for a dry run against a copy of your database and for rollback decisions. A written scope should list the environments, the test cases and the cutover approach so the timeline can be checked against them.
What does the client need to provide before work starts?
The client needs to provide access to the Synapse homeserver configuration and its oidc_providers entries, a staging copy of the Synapse and MAS databases, a running authentik environment or the approval to deploy one, and DNS and TLS control for the MAS and authentik hostnames. Named owners for identity administration, Matrix administration and change approval are also needed, along with a list of Matrix clients and the user groups that will sign in. Confirm the authentik version you plan to run against the supported versions listed in its security policy, and confirm database and platform requirements for each component with the vendor documentation.
Can an internal team run this integration without outside help?
Yes, if the team has experience with OpenID Connect, identity administration and Synapse operations. The work is configuration-heavy but not novel: an authentik application and provider, a MAS upstream entry, a claim mapping that produces the Matrix user ID you want, and a tested migration path for existing Synapse SSO users. The risk sits in the parts that are easy to get wrong, such as a changed subject claim that orphans accounts or a mismatch between synapse_idp_id values. Teams with no prior Synapse or MAS work often benefit from a fixed-scope engagement with written deliverables, followed by a retainer if they want upgrades handled over time.
How do authentik and Synapse upgrades affect this integration?
Each upgrade can change the integration, so treat them as separate change events with their own test cycles. Synapse upgrade notes warn that rolling back can be difficult because of database schema changes between releases, and Synapse drops support for Python and PostgreSQL versions once they reach upstream end of life. On the authentik side, the security policy lists 2026.5.x and 2026.8.x as the supported lines receiving security fixes, and security releases are announced at least 24 hours ahead. The 2025.10 release notes also state that authentik moved caching, tasks and sessions to PostgreSQL and warn of roughly 50% more PostgreSQL connections after upgrading, which affects capacity planning. Plan a staging upgrade, confirm the sign-in flow end to end and keep database backups before each change.
Does the integration keep existing Synapse SSO users and their accounts?
It can, but only when the mapping is planned before cutover. MAS documents a migration path in which each upstream provider used in Synapse needs a matching MAS provider with synapse_idp_id set, using the oidc-<idp_id> form for oidc_providers entries. The identifier that authentik sends must match the one already linked to each Synapse account, so test the claim that identifies users in a staging copy before any production change. Ask for a written account inventory and a list of users who would fail to match, since those users need a defined recovery route.
What to confirm with your team and vendors
Start by recording the exact MAS and authentik versions you plan to run, and the Synapse version on your homeserver. Confirm the authentik release and support status on the authentik security policy page, which lists the versions receiving security fixes and the advance notice given for security releases, then check the authentik releases page for the newest build. Pick a version only after you have confirmed it is still supported for the window you plan to operate it in, and confirm the same for the Synapse and MAS releases with the upstream release notes. Ask your authentik contact or vendor which Synapse and MAS combinations they have tested with your chosen authentik release.
Next, find out whether any of your users sign in with SAML. MAS does not support SAML, and the MAS documentation recommends a bridge such as Dex for SAML or LDAP sources. If your directory or identity estate includes SAML-only applications or users, this design needs a Dex route in front of authentik or a separate decision about those accounts. Also confirm whether your Synapse configuration already has oidc_providers entries, because each one needs a matching MAS upstream provider with synapse_idp_id set. Check the existing homeserver.yaml on every node, including workers, so you do not miss an entry that a single file review would overlook.
Finally, decide which authentik edition covers your requirements. The pricing page lists an open source edition, an Enterprise edition billed per user with an additional charge for external users, and an Enterprise Plus edition with an annual starting price, and it lists which features sit only in the paid tiers. Confirm with the authentik vendor, in writing, the current price and terms for your user counts, and whether any feature you need, such as enhanced audit logging or privileged access management, is in the edition you buy. Also confirm the license terms for the code paths you intend to use, since the repository license names a separate enterprise license for its enterprise directory. Ask your legal and procurement teams to review these terms before rollout.
How DeployOpen scopes and delivers this integration
DeployOpen plans and builds the authentik to Matrix Authentication Service connection inside infrastructure you control, from the authentik application and provider through the MAS upstream entry and the account-mapping check for existing Synapse SSO users. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
How we scope
- Confirm your current Synapse oidc_providers entries and the idp_id values that existing accounts depend on.
- Record the authentik version, deployment method and hosting so the written scope matches your environment.
- Agree in writing which MAS, authentik and Synapse settings are changed, tested and handed over.
How we build
- Configure the authentik OAuth2/OIDC provider and application for MAS, with redirect URIs and scopes reviewed against your domain.
- Add the MAS upstream provider entry with synapse_idp_id set so existing Synapse SSO users keep their Matrix accounts.
- Test sign-in with existing and new users, and confirm account matching on a non-production homeserver before cutover.
How we hand over
- Document the authentik objects, MAS configuration and claim mapping so your administrators can review each setting.
- Provide a rollback note covering database schema changes, since rolling back Synapse upgrades can be difficult.
- Deliver the written test results, open items and the exact configuration files you need for future changes.
How we support
- Plan authentik version upgrades against the supported release lines named in the authentik security policy.
- Offer ongoing support, upgrades and continuous testing as a retainer after the initial handover.
- Retest sign-in and account mapping after each authentik, MAS or Synapse upgrade you approve.

