Mattermost and Keycloak SAML SSO

Connect a self-hosted Mattermost server to Keycloak as its SAML identity provider using the documented SAML client, encrypted assertions and attribute mappers. This page covers the build sequence, identity mapping and failure points.

On this page

Mattermost and Keycloak SAML SSO: how the integration works

Your self-hosted Mattermost needs to sign users in through a central Keycloak realm, so the supported method is SAML 2.0 with a Keycloak SAML client named mattermost. Mattermost publishes a guide to configure SAML with Keycloak that was tested with Keycloak v26.4.0, and the guide is available on the Entry, Professional, Enterprise and Enterprise Advanced plans. According to the Mattermost pricing page, SSO over SAML, OIDC and OAuth is included from the Professional plan, so confirm your plan level with Mattermost before you commit to the design. Keycloak is an open source identity and access management server licensed under Apache 2.0. It supports SAML 2.0 alongside OpenID Connect, so the realm you already run for other applications can serve Mattermost without a second identity store.

In this flow, Keycloak acts as the identity provider and Mattermost acts as the service provider. When a user signs in, Mattermost redirects the browser to Keycloak, Keycloak authenticates the user and returns a signed SAML assertion that carries the user's identity attributes. The guide's settings decide what that assertion contains: the Name ID format is set to email, so the email address becomes the account identifier, and the email, givenName and surname attribute mappers supply the profile fields Mattermost reads. The assertion is encrypted with AES_256_GCM. Your team should confirm that the email value in Keycloak matches the address Mattermost expects, because a mismatch creates duplicate or unlinked accounts that are difficult to clean up later.

Certificate handling is the part most likely to break at go-live. The Keycloak realm signing certificate and the SAML encryption key must be exchanged with Mattermost, and both must be rotated on a schedule you define. Plan who owns the rotation, where the certificates are stored, and how Mattermost is updated when they change. Confirm the exact configuration keys and settings against the current Mattermost SAML documentation and your Keycloak version, since Keycloak's release cadence means minor upgrades can arrive several times a year.

What you need before configuring Keycloak for Mattermost

Six items must be in place before you touch either server. Together they decide whether the SAML handshake can succeed on the first attempt, so confirm each one with the team that owns it. The license and the public URL are the two most often missed.

A licensed Mattermost plan with SAML

SAML is not available on every plan. The Mattermost pricing page lists SSO (SAML, OIDC, OAuth) from the Professional plan upward, and the Keycloak guide is documented for Entry, Professional, Enterprise and Enterprise Advanced. Confirm your subscription tier in writing before you plan the work, because a lower tier will block the SAML settings in the System Console. Subscriptions are prepaid annual seat licenses, so ask your Mattermost contact how seat counts are set for your user population.

Mattermost pricing

A running Keycloak instance and realm

Mattermost needs a Keycloak realm that holds the users who will sign in, and the SAML client is created inside that realm. Decide whether you will use an existing realm or a dedicated one for collaboration tools, and record its name because it appears in the endpoint URLs you will paste into Mattermost. Confirm that administrators can reach the Keycloak admin console over the network path they will use for the change.

Keycloak admin guide

Keycloak version check

The Mattermost guide was tested with Keycloak v26.4.0, and the current Keycloak release is 26.8.1, published October 13, 2026. Run the version your organization has standardized on, and note any gap between it and the tested version so you can review the admin console labels before you follow the steps. Read the backwards compatibility notes for any minor release you plan to adopt, because the project makes breaking changes opt-in but still publishes them.

Keycloak release notes

A supported production database

Keycloak's production database must be one of its supported engines, including PostgreSQL 14 to 18, MySQL, MariaDB, Microsoft SQL Server, Oracle Database, Amazon Aurora PostgreSQL and Azure SQL. The default dev-file database is for development only and is not a valid base for a production SSO service that Mattermost depends on. Confirm the database host, backup schedule and access controls with your database team before the realm holds real users.

Keycloak database guide

A public Mattermost URL for ACS and metadata

Keycloak sends the SAML response to the Mattermost Assertion Consumer Service and reads Mattermost's metadata, so the Mattermost Site URL must resolve to the same public hostname that users type in their browsers. Check that the hostname, the TLS certificate and any reverse proxy forwarding rules are correct from both the user network and the Keycloak network. A mismatch here causes redirect and audience errors that look like identity problems.

Mattermost SAML docs

Signing and encryption certificate pair

The guide uses encrypted assertions with the AES_256_GCM algorithm, so you need a certificate and private key pair that both systems can use. Generate it under your organization's key management policy, store the private key in your secrets system, and record the expiry date so renewal is planned. Keycloak holds the key in the realm keys configuration, and Mattermost needs the matching public certificate to validate signatures.

A test user set for verification

Create a small set of test accounts before you configure anything, with the email address, first name and last name populated. The SAML attribute mappers for email, givenName and surname depend on these fields, and Mattermost will not create a usable account if they are empty. Include one account that is an administrator in Mattermost and one ordinary user so you can verify both the login path and the role mapping.

How to configure the Keycloak SAML client for Mattermost

This sequence produces a Keycloak SAML client that issues encrypted, signed assertions with the email and name attributes Mattermost needs, and a Mattermost SAML configuration that accepts sign-in from that realm. Each step ends with a check you can run before moving on.

  1. Create the SAML client in Keycloak

    In the Keycloak admin console, open the realm you will use for Mattermost and create a new client with the SAML protocol. Set the client ID to mattermost, so the SAML entity ID and endpoints match what the Mattermost guide expects. Set the Name ID format to email so Mattermost receives the user's email address as the identifier. Save the client. Check: the client list shows mattermost with the SAML protocol, and its settings page displays email as the Name ID format.

  2. Enable encrypted assertions with AES_256_GCM

    On the mattermost client, turn on encrypted assertions and set the encryption algorithm to AES_256_GCM, as the Mattermost Keycloak guide specifies. Confirm that your Keycloak version exposes these settings in the client's SAML keys or signature and encryption options, since the labels can differ across releases. The guide was tested with Keycloak v26.4.0, so check its settings against that version if you run a different release. Check: after saving, reopening the client shows encrypted assertions enabled and AES_256_GCM selected.

  3. Add the X500 attribute mappers

    On the mattermost client, add three attribute mappers that carry the user's identity into the SAML assertion: X500 email, X500 givenName and X500 surname. Map each one to the matching user property in the realm (email, first name and last name). Keep the attribute names exactly as the Mattermost guide lists them, because Mattermost reads these attributes when it creates or updates the account. Check: sign in to Keycloak with a test user, open the client's Client scopes or mappers view, and confirm all three mappers are listed and point at the correct user fields.

  4. Export the realm SAML metadata and signing certificate

    Open the realm's SAML metadata descriptor from the realm settings in Keycloak and save the XML. Also note the realm signing certificate that Mattermost will use to verify assertions, and keep a copy in a controlled location, because certificate handling is part of the trust setup. Plan how you will rotate this certificate before it expires, since a later change requires updating Mattermost. Check: the metadata URL opens in a browser and returns XML that includes the entity ID and a signing key, and the certificate you saved matches the one shown in the realm keys page.

  5. Enter the identity provider details in Mattermost

    In the Mattermost System Console, open the SAML single sign-on settings and enter the identity provider details from the Keycloak metadata and certificate: the IdP URL, the IdP descriptor URL, the IdP certificate and the Keycloak login endpoint. Confirm the Mattermost Site URL is the exact HTTPS address users will open, because assertion destinations depend on it. Mattermost SAML is available from the Professional plan, so confirm your plan before you rely on it. Check: the settings save without error and the SAML option appears on the Mattermost login page.

  6. Test sign-in with a non-admin account

    Sign out of Mattermost and sign in through Keycloak with a standard user account that is not a system administrator and has a real email address in the realm. Use a SAML tracer or browser developer tools to confirm the assertion is encrypted, the Name ID is the email, and the email, givenName and surname attributes are present. Testing with an admin account can hide attribute problems, so keep this test separate. Check: the user lands in Mattermost, and the user record in the System Console shows the expected email address, first name and last name.

How a SAML login moves between Mattermost and Keycloak

The login starts in the browser when a user opens Mattermost, which redirects the browser to the Keycloak realm with a SAML AuthnRequest. Keycloak authenticates the user and returns a signed, encrypted assertion through the browser to the Mattermost assertion consumer service. Mattermost then maps the email, givenName and surname attributes to the user record. Check that the SAML client ID is mattermost, that the Name ID format is email, and that each certificate is the one each side expects at its hand-off.

Browser-mediated SAML redirect and assertion flow between Mattermost and Keycloak.

Which Keycloak attributes map to Mattermost user fields

This table compares each Keycloak SAML value the guide maps against the Mattermost account field it feeds and the decision you still own. Read it to confirm which attribute sets the username, and which settings sit outside the mappers. The main takeaway is that the mappers cover identity data only, so role and removal behavior must be configured and verified separately.

Keycloak valueWhat the guide setsWhat you decide or confirm
NameIDName ID format set to email, so the assertion subject is the user's email addressConfirm that email is the username source in your configuration and that every account has a unique, stable email
X500 email mapperMaps the user's email attribute into the SAML assertionCheck that the attribute name matches what Mattermost expects and that the email value equals the NameID
X500 givenName mapperMaps the user's first name into the assertionDecide whether first name should populate the Mattermost first name field and whether users may edit it in Mattermost
X500 surname mapperMaps the user's last name into the assertionDecide whether last name should populate the Mattermost last name field and how names with multiple parts are stored
Mattermost role or admin flagNot covered by the guide's mappers, which only cover identity attributesSet system admin and team roles deliberately, for example through an explicit admin list, and verify them after first login
User deprovisioningNot covered by the guide's mappersDepends on how accounts are removed in your setup. Confirm the removal and deactivation behavior against the Mattermost authentication documentation before go-live

Managing signing and encryption certificates across renewals

Keycloak's realm signing key and the encryption key behind AES_256_GCM assertions each have a life of their own, and Mattermost holds a copy of the public certificate that must match them. The cards below cover what each item is, where it lives, and how to rotate both sides without breaking sign-in.

Realm signing key

Keycloak signs SAML assertions with the realm's signing key, and Mattermost validates those assertions against the matching public certificate. Identify which key pair the SAML client uses, confirm its expiry date in the realm keys settings, and note whether the realm is configured to use a generated key or an imported one. A rotation that changes the signing key without updating Mattermost will stop all SAML sign-ins.

Keycloak docs

Assertion encryption key

The Mattermost guide sets the SAML client to encrypt assertions with AES_256_GCM. Encryption depends on a key pair that Mattermost must be able to decrypt with, so a change on the Keycloak side for this key is a change that affects sign-in even when the signing certificate is unchanged. Treat the encryption key as a separate item with its own expiry record and its own rollover step.

Public certificate on the Mattermost side

Mattermost needs the public certificate that corresponds to the Keycloak key used for validation. Confirm where your Mattermost SAML configuration stores this certificate in your deployment, who can edit it, and whether it is set through the System Console or a configuration file. Keep a dated copy of the certificate fingerprint in your change record so you can confirm which version is live.

Mattermost SAML docs

Rotation schedule before expiry

Set the rotation date well before the certificate expires, and tie it to a named owner and a change window. Keycloak's own release cadence means you may also upgrade the server during the same period, so plan the certificate work separately from any Keycloak upgrade. Ask your identity team to confirm how Keycloak reports upcoming key expiry in your version so the reminder does not depend on memory.

Keeping both sides in sync

A rollover needs an order of operations that keeps at least one valid trust path at every moment. Prepare the new public certificate, add it to the Mattermost SAML configuration as your deployment documents, verify sign-in with a test account, and only then retire the old key on the Keycloak side. Record the time of each step so that a failed sign-in can be matched to the change that caused it.

Testing and secret handling

Rehearse every rotation on a staging Mattermost server that uses the same Keycloak realm settings before touching production. Keep private keys in a secrets store or the Keycloak key storage, never in configuration files committed to version control. Restrict access to exported keystores, and confirm that deleted keys and old exports are removed from backups on the schedule your policy requires.

Why Mattermost SAML login with Keycloak fails

This table lists the failures teams most often hit when Keycloak signs users into Mattermost over SAML, with the cause and the fix for each. Read it while checking the SAML client, the assertion settings and the attribute mappers, since most failures trace back to a mismatch between the two sides.

FailureLikely causeFix
Client ID or ACS URL mismatchThe Keycloak SAML client ID is not exactly mattermost, or the assertion consumer service URL does not match the Mattermost site URLSet the client ID to mattermost and confirm the ACS URL matches your Mattermost site URL character for character, including the scheme and path
Name ID format not set to emailThe client uses a different Name ID format, so Mattermost receives a value it cannot match to an accountSet the Name ID format to email as the Mattermost guide describes, then sign in again with a test user
Encrypted assertions on one side onlyKeycloak encrypts assertions with AES_256_GCM but Mattermost is not configured to decrypt them, or the reverseEnable encrypted assertions and the AES_256_GCM algorithm on both sides, and confirm the decryption key is the one Mattermost holds
Certificate mismatch after rotationThe signing or encryption certificate in Keycloak changed, but Mattermost still holds the old certificateExport the current certificate from the Keycloak realm or client and upload it to Mattermost, then test a fresh login
Missing email attributeThe X500 email mapper is absent or points to a different attribute, so the assertion carries no email addressConfirm the X500 email mapper exists on the client and that the user record in Keycloak holds a valid email value
Blank name in the profileThe givenName or surname mappers are missing, so Mattermost creates the account without first and last namesAdd the X500 givenName and surname mappers and check that the test user has both fields filled in Keycloak
Users with no email in KeycloakAccounts were created without an email, which Mattermost needs to match or create the userRequire an email on every user in the realm and correct existing accounts before enabling SSO for them
Clock skew between serversThe Keycloak host and the Mattermost host disagree on time, so assertions appear expired or not yet validSynchronize both servers with a time service and check the clock on each before troubleshooting the SAML settings

Keeping the Keycloak and Mattermost versions aligned over time

The Mattermost Keycloak guide was tested with Keycloak v26.4.0, while the current Keycloak release is 26.8.1. That gap is normal, but it means the SAML configuration you deploy today is only known to work on the tested version. Treat every Keycloak upgrade as a change to the SSO path and retest sign-in before the upgraded identity provider serves production users. Keep the SAML client settings, the encrypted assertion configuration, the attribute mappers and the signing certificate in your change record so the retest has a known baseline to compare against.

Keycloak plans four minor releases a year and a major release every two to three years, and it states that breaking changes in a minor release will be opt-in. Read the backwards compatibility notes for each release you plan to adopt, and confirm which changes require you to enable a setting. Keycloak also migrates its database schema automatically at startup by default. For a small deployment that is convenient, but for a large one you can apply the SQL manually, as the upgrading guide suggests. Decide which method your team will use before the first upgrade, and rehearse it against a copy of the production database so a failed migration does not become a sign-in outage.

Mattermost ships a new server version in binary form on the 16th of each month, and its Extended Support Releases follow a longer support window. Your Keycloak schedule and your Mattermost schedule will not line up, so write a single upgrade plan that names both products, the SSO test cases (login, attribute population for email, first name and last name, and logout) and the owner who signs off. Confirm with Mattermost which server version your SAML configuration is documented against before you move to a new release. Every upgrade plan on either side should include the SSO test, because a passing server upgrade does not prove the identity provider still issues assertions that Mattermost accepts.

Questions buyers ask before configuring Keycloak SSO for Mattermost

What drives the cost of setting up Keycloak SSO for Mattermost?

The cost follows the amount of identity work around the SAML link, not the link itself. The main drivers are the Mattermost plan level, since SSO with SAML is included from the Professional plan and the Keycloak guide applies to Entry through Enterprise Advanced; the number of Keycloak realms and attribute sources that need mapping; the work to create, rotate and install the SAML signing and encryption certificates; the hosting of both systems; and the test scope, including how many user types, groups and failure cases you want verified. Ask any quote to separate one-time build work from recurring upgrade and certificate renewal work, and to name who holds each task. DeployOpen does not publish prices, so the figure comes from the written scope.

Can our team configure Keycloak SSO for Mattermost using the Mattermost guide alone?

A team with Keycloak and Mattermost administration experience can usually follow the Mattermost guide, which Mattermost tested with Keycloak v26.4.0. The guide creates a SAML client with the client ID mattermost, sets Name ID format to email, enables AES_256_GCM encrypted assertions and adds X500 email, givenName and surname mappers. The guide covers the happy path. Your team still has to decide how existing Keycloak realms, groups and certificate policy fit in, test login with real accounts, and plan the change window. If those decisions are new to your team, a fixed-scope engagement can move that design work out of your critical path.

What does the work need from our side before it starts?

Plan on providing four things. First, Keycloak administrator access to the target realm, with rights to create clients, mappers and keys. Second, System Console access in Mattermost to enter the SAML settings and confirm the login behavior. Third, a set of test users covering each role and group that must sign in, plus at least one account that should be denied. Fourth, an agreed change window, because the SAML configuration and certificate changes affect everyone who signs in. Also confirm who approves the signing certificate, where it is stored, and who will receive renewal reminders.

How long does Keycloak SSO for Mattermost take to set up?

Duration depends mostly on how mature your Keycloak deployment already is. A team with a supported, documented realm, existing user attributes and a certificate process can move through the SAML client and mapper steps quickly, and most of the time goes to testing. A team still building its Keycloak environment, or one that has to reconcile several realms, sources of user attributes or certificate authorities, needs more time for design and sign-off. No duration figure is supplied for this topic, so ask any quote to state the phases, the assumed starting state of your Keycloak and the testing you expect to be included.

Does Red Hat build of Keycloak change the Mattermost setup steps?

Red Hat build of Keycloak is Red Hat's supported distribution based on the open source Keycloak project and replaces Red Hat Single Sign-On. The SAML concepts, the client ID, the Name ID format and the mapper approach do not depend on the distribution, but the packaging, support lifecycle, patch cadence and some administration paths can differ. Red Hat's product page showed version 26.6 as its latest, while the Mattermost guide was tested with Keycloak v26.4.0. Confirm with Red Hat and with the Mattermost documentation which versions your Mattermost plan supports before you commit to a build.

What certificate handling should we plan for SAML encryption?

The Mattermost guide enables encrypted assertions with AES_256_GCM, so the signing and encryption keys must be managed deliberately. Plan who generates the key pair, where the private key is stored, how the public certificate is exchanged with Mattermost, and what happens at expiry. Set a renewal date before the certificate is installed, and test a rollover in a non-production realm first. Keep a documented fallback for administrators who need to sign in if the identity provider is unavailable. Record each change so an auditor can see the sequence.

Can DeployOpen take over ongoing Keycloak and Mattermost upgrades?

Yes, ongoing support, upgrades and continuous testing are available as retainers, and most engagements are fixed-scope with scope, deliverables and timelines agreed in writing. For this integration, the recurring work includes tracking Keycloak releases, which the project plans four times a year, and Mattermost releases, which arrive monthly with Extended Support Releases in between. Keycloak minor releases make breaking changes opt-in, but the Operator documentation strongly recommends manual approval for operator updates. Ask any retainer proposal to define which upgrades are covered, how SAML settings are retested after each change, and who approves each production change.

What a DeployOpen SSO engagement covers

A DeployOpen SSO engagement starts with a written scope that names the pieces of work before anything is built. For this topic, that scope lists the Keycloak realm and SAML client design, including the client ID, Name ID format and how encrypted assertions are set up, the attribute mappers for email, given name and surname, the Mattermost plan check, the certificate plan, the test cases and the handover documentation. Each item is written down with what it produces, so your security, identity and platform teams can review the boundaries before work starts. Most engagements are fixed-scope, and a quote follows from that written scope rather than from a generic package.

The plan check deserves attention early. SAML SSO is included from the Professional plan on Mattermost's pricing page, so the scope should confirm which plan your organization holds and whether any other identity features you expect are on that plan. The certificate plan should record who owns the signing and encryption certificates, where the private keys are stored, how the Keycloak and Mattermost configurations are updated when a certificate is renewed, and how expiry will be tracked. Your team should confirm these owners before the quote is finalized, because they decide who answers for an outage at renewal time.

DeployOpen plans, implements and documents self-hosted platforms inside your own infrastructure, including the cloud accounts, data centers or air-gapped networks you operate. The handover material is written for your operators, and it covers the realm and client settings, the test results and the steps to repeat the configuration. DeployOpen does not issue audit reports, attestations or certifications. If your compliance program needs evidence of SSO controls, the scope should say which records are delivered for your assessor, and your auditor or certification body remains responsible for any assessment outcome.

How DeployOpen scopes and delivers Mattermost SSO work

DeployOpen plans and delivers Mattermost and Keycloak SAML SSO inside infrastructure you control, from the Keycloak SAML client through to a tested, documented handover. Each engagement starts from a written scope so your security, identity and platform teams know exactly what changes and what they must review.

How we scope

  • Confirm your Mattermost plan level, since SSO with SAML is included from the Professional plan onward.
  • Agree the Keycloak version, realm layout, and whether the Keycloak deployment is new or already running.
  • Record the attribute mappers, Name ID format and assertion encryption choices your security team has approved.
  • Define certificate ownership, rotation responsibility and the environments that need separate SAML clients.

How we build

  • Create the SAML client with client ID mattermost and Name ID format email, following the documented Keycloak setup.
  • Configure encrypted assertions with the AES_256_GCM algorithm and verify that Mattermost accepts them.
  • Map the X500 email, givenName and surname attributes, then test first login and attribute updates for sample users.
  • Test sign-in, sign-out, failed login and account provisioning in a staging environment before production cutover.

How we hand over

  • Deliver the written configuration record covering the client settings, mappers, encryption and certificate locations.
  • Document the test cases used, their results, and the steps to repeat them after an upgrade of Mattermost or Keycloak.
  • Walk your administrators through certificate renewal, client changes and troubleshooting of failed SAML logins.
  • Provide evidence of configuration and testing that your compliance team can review with their assessor.

How we support

  • Plan Keycloak and Mattermost upgrades as separate changes, retesting SAML sign-in after each one.
  • Offer ongoing support, upgrades and continuous testing as a retainer, with scope agreed in writing.
  • Review identity changes such as new realms, new mappers or certificate rotation before they reach production.
  • Confirm with your team which support hours, response terms and escalation paths belong in the retainer scope.

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.