Keycloak and Open edX SSO integration

Connect Open edX to Keycloak with third-party authentication over SAML 2.0 or OAuth2, with mapped attributes, account linking and controlled auto-registration. Planned for infrastructure you control.

On this page

How Keycloak sign-in works with Open edX

If your organization runs Open edX, or plans to, and wants learners and staff to sign in with the Keycloak accounts they already use, Open edX third-party authentication can connect to Keycloak over either SAML 2.0 or OAuth2. Choosing between them is the first decision in this integration, and it shapes how attributes, roles and logout behave later. Keycloak supports OpenID Connect, OAuth 2.0 and SAML 2.0, so both routes are open to you, but the protocol you pick must match what your Open edX release supports in its third-party authentication configuration.

Keycloak is an open source identity and access management server licensed under Apache 2.0, and it provides single sign-on, identity brokering, user federation and an admin console. In this design, Keycloak acts as the identity provider and Open edX acts as the service provider or client. The integration itself sits in the Open edX third-party authentication settings, where you define the provider, its endpoints, keys or metadata, and the attribute values Open edX reads from each sign-in. Nothing in Keycloak replaces Open edX's own user records, so the platform still creates and stores accounts locally.

Before you build, confirm the following in your own environment: which Open edX release you run (the latest named release is the only one the project supports, so check the release notes for your version), whether the identity provider types you plan to use are listed for that release, and which Keycloak version your organization has standardized on. The current Keycloak release is 26.8.1, and Red Hat's supported build may lag behind upstream, so confirm the version you will actually deploy and test against.

What you need before connecting Keycloak to Open edX

Connecting Keycloak to Open edX touches two systems, a shared network path and several people's accounts. The cards below cover the platform, data store, certificates, hostnames and administrator access that should be settled before any third-party authentication settings are changed. Confirm each item in your own environment first, because a gap in one usually shows up as a failed sign-in later.

A running, supported Keycloak instance

Keycloak is an Apache 2.0 licensed identity server that supports OpenID Connect, OAuth 2.0 and SAML 2.0. Confirm that your instance is on a current release, such as the 26.8.1 release published October 13, 2026, and that it is not the development file database. Production needs a database from Keycloak's supported list, such as PostgreSQL 14 to 18, and a planned upgrade path, since Keycloak plans four minor releases a year.

Keycloak database guide

A Tutor-managed Open edX deployment

Open edX states that the latest named release is the only supported release, and that it cannot support more than one release at a time. Before you start, check the release notes and confirm which named release your Tutor deployment runs, then plan any upgrade ahead of the SSO work so you are not configuring against a moving target. Tutor is the officially recommended route for production, so keep the SSO settings in your Tutor configuration where they can be versioned.

Open edX release notes

TLS certificates for both sides

Both the LMS and Keycloak must be served over HTTPS with certificates that browsers and servers trust. Identify which certificate authority issues them, who renews them, and whether your SAML metadata or OAuth2 redirect configuration will need updating at renewal. Mismatched certificate chains are a frequent cause of failed token or assertion validation, so test the chain from the Open edX host itself, not only from your laptop.

Reachable, stable hostnames

Decide the public hostnames for the LMS and for Keycloak before you register any client. Redirect URIs and SAML entity IDs are tied to these names, so changing them later means reconfiguring both systems. Confirm that the LMS host can reach Keycloak's token and metadata endpoints over the network, including any internal DNS, firewall rules or proxy paths that sit between the two.

Administrator accounts on each system

You need an administrator account in Keycloak with rights to create realms, clients and user attribute mappers, and a Django superuser or equivalent staff account on the Open edX side to configure third-party authentication providers. Name the people who hold these accounts, keep them separate from everyday user accounts, and confirm they can sign in before the integration work starts. Record who approves changes to production client secrets.

A test realm and test learners

Create a separate Keycloak realm or environment for testing, with a few test users covering learner, instructor and staff roles. Testing against production identities can create real accounts in the LMS and makes rollback harder. Confirm with your identity team which attributes, such as email and name, are present on every account, because missing attributes will affect the mapping and auto-registration choices you make later.

Configuration sequence for the Keycloak connection

The sequence takes a Keycloak realm and client from planning to a verified Open edX sign-in, with each step closing on a check that proves the connection works before the next one begins. Your team can follow it in order and hand the result to your security reviewers as evidence.

  1. Confirm the protocol and trust model

    Decide whether Open edX will use SAML 2.0 or OAuth2 with Keycloak, based on what your Open edX release and Keycloak deployment support and what your security team requires for token and assertion handling. Record which Keycloak realm will hold Open edX users, which identity sources feed it, and who owns the Keycloak administrator role. Confirm the exact provider options against the Open edX third-party authentication documentation for your release. The step is done when the decision, the realm name and the owners are written down and signed off.

  2. Create the Keycloak realm and client

    In Keycloak, create or select the realm for Open edX, then register a client for the LMS using the protocol chosen in the previous step. Set the redirect and callback addresses to the exact LMS hostnames your Tutor deployment uses, and confirm the client settings against the Keycloak server administration guide. Your Keycloak administrator performs this work in a non-production realm first. The step is done when the client exists, its endpoints match the LMS hostname, and an administrator can see it listed in the realm.

  3. Configure the Open edX third-party authentication provider

    In the Open edX LMS, enable third-party authentication and add a provider that points at the Keycloak client. For SAML, this means exchanging metadata between Keycloak and the LMS; for OAuth2, it means entering the client identifier and secret and the Keycloak endpoints for your realm. Your platform engineer makes the change through Tutor configuration and restarts the services it requires, following the supported identity provider documentation for exact settings. The step is done when the provider appears on the LMS sign-in page and the LMS starts an authentication redirect to Keycloak.

  4. Set the attribute mapping

    Map the claims or assertion attributes Keycloak sends to the Open edX account fields the platform requires, typically the username, email and display name, and agree how staff roles are represented. Compare the attribute names in a sample token or assertion with the names the provider configuration expects, and confirm that Keycloak mapper settings deliver each value. Your identity administrator and platform engineer complete this together. The step is done when a sample login shows every required attribute arriving with the expected value and none are blank.

  5. Test a learner login

    Using a dedicated test learner account in Keycloak, sign in from a private browser session through the Open edX sign-in page. Confirm the redirect returns to the LMS, the dashboard loads, the account has the expected email and name, and the account carries no staff permissions. Review the LMS and Keycloak event logs for the sign-in, and check that the sign-out path also works. The step is done when the test is recorded with timestamps, the account state matches the expectations, and the logs show a single successful authentication.

  6. Test a staff login

    Repeat the test with a staff account that holds the Keycloak role or group your policy assigns to course teams and platform administrators. Confirm that Open edX grants the staff or instructor access you intended, that Studio opens only for the accounts you approved, and that a standard learner account cannot reach administrative pages. Review the authorization decision in the logs and compare it with your access matrix. The step is done when each tested role reaches exactly the pages it should, and any mismatch is logged as a defect to fix before go-live.

  7. Confirm account linking for existing users

    Take an account that already exists in Open edX with a local password and sign it in through Keycloak, checking whether it links to the existing record or creates a duplicate. Decide with your data owner how existing accounts should be matched, typically by verified email, and confirm the linking behavior in the Open edX documentation for your release. Record the outcome for each test case, including accounts with mismatched emails. The step is done when one existing account links cleanly, no duplicate accounts appear in the admin view, and the matching rule is documented for the operations team.

How Keycloak claims map to Open edX account fields

This table compares each Keycloak claim with the Open edX account field it feeds and whether login depends on it. Read the required column first, because a missing or mismatched claim blocks sign-in, while optional mappings only affect profile data and staff roles. Confirm the exact attribute names each Open edX provider expects before you configure the client mappers.

Keycloak claimOpen edX fieldRequired for loginNotes
Username claim (preferred_username)UsernametrueOpen edX needs a unique username per account. Confirm the claim name your provider configuration reads and check for collisions with existing accounts.
Email claim (email)EmailtrueUsed to match or create the account. Confirm whether the email must be verified in Keycloak before you allow auto-registration.
Full name claim (name or given_name and family_name)Full namefalsePopulates the profile name. Learners can usually edit it later, so a missing value should not block sign-in unless your provider mapping requires it.
Group or role claimStaff or instructor role (set outside the learner account)falseMap groups to course-team or staff permissions through Open edX role administration, not through the sign-in mapping. Keep learner and staff access separate.
Stable subject identifier (sub)External account linkfalseLinks a Keycloak identity to an existing Open edX user. Changing it later can create duplicate accounts, so choose it before go-live.
Email verified flagRegistration gatefalseSome setups accept only verified emails. Confirm how your Open edX release and provider settings treat unverified addresses.
Custom attributes (department, employee ID)Profile or extended fieldsfalseOptional and often unnecessary for sign-in. Send only what the course or reporting need, since each extra attribute is personal data to govern.

SAML 2.0 or OAuth2: choosing the protocol

Open edX third-party authentication is the first constraint to check. Its supported identity provider list includes OAuth2 providers such as Google, Facebook, LinkedIn and Azure Active Directory by default, along with SAML 2.0, Shibboleth and LTI. Generic OAuth2 and SAML connections to Keycloak are configured through the third-party authentication settings rather than through a separate built-in Keycloak option, so the work is in matching the Open edX configuration to what Keycloak exposes. Confirm the exact settings and any plugin requirements against the current documentation for your Open edX release before you commit to a protocol.

  • Default OAuth2 providers: Google, Facebook, LinkedIn and Azure Active Directory are named as defaults, which does not include Keycloak itself.
  • SAML 2.0 support: SAML 2.0 is listed as supported, so a Keycloak SAML client can be configured against the LMS once metadata is exchanged.
  • Shibboleth and LTI: Shibboleth is a SAML-based option, and LTI is a separate launch mechanism, not a sign-in protocol for staff accounts.
  • Legacy providers: CAS and SSL client certificates have older, provisional support, so avoid them for new builds unless you have a specific reason.
  • Release check: Confirm which options your target Open edX release exposes, because the provider list and its settings change over time.

Check the supported list and the settings you will need before you choose between the two protocols.

How account linking and auto-registration affect existing learners

The main decision in this section is what happens when a user signs in through Keycloak and the email address in the assertion already belongs to an Open edX account. Open edX third-party authentication can link the incoming identity to that existing account, or it can refuse the login and leave the account untouched. Linking by email is convenient, but it trusts that the identity provider has verified the address and that the person at the other end is the original account holder. If Keycloak accepts self-registration, a user who controls an address that was used for an old learner account could gain access to that account's enrollments, certificates and personal data. Before go-live, confirm how the Keycloak realm verifies email addresses, whether that email can change, and whether old learner accounts were created with addresses that now belong to someone else.

Duplicate accounts are the second risk. When a learner's Keycloak identifier differs from the one already stored in Open edX, or when the email changed at some point, the same person can end up with two accounts, each holding partial enrollments and certificates. Auto-registration on first login avoids manual setup and suits open catalogs, but it creates accounts for everyone who can authenticate, including people nobody intended to enroll. Pre-created accounts, built from a roster or a provisioning job, give the platform owner tighter control and make the username and email reconciliation visible before anyone signs in, at the cost of maintaining that job. Choose one model per learner population, and document how a learner who was registered twice will be merged.

The platform owner and the privacy function should make this policy decision together, because it determines which personal data is created automatically, who can be matched to an existing record, and how a learner's access is withdrawn. Before enabling it for all learners, run a pilot with a sample of existing users drawn from different cohorts, staff roles and any learners who changed their email address. For each sampled user, check that the Keycloak login links to the expected Open edX account, that enrollments and certificates are intact, that no second account appears, and that a user without a matching record is handled as the policy states. Record the results, then decide whether the matching rule and the registration setting can be widened.

Security settings for Keycloak and Open edX sign-in

Keycloak sits between Open edX and your staff and learner directories, so every sign-in trusts it. The cards below cover the settings that define that trust: transport security, redirect and audience restrictions, certificate lifecycle, client scoping, MFA, admin access and login monitoring. Review them together, because a loose redirect URI or an unrotated signing certificate weakens every other control.

TLS on both hostnames

Keycloak and the Open edX LMS and Studio each need valid TLS on their own hostnames, and the browser redirects between them carry login state. Confirm that the Keycloak public hostname, the LMS hostname and the Studio hostname all terminate TLS with certificates your team can renew, and that plain HTTP is redirected rather than served. Check that the proxy forwards the original hostname and scheme so Keycloak builds correct issuer and callback URLs. Follow the production configuration guidance for proxy and hostname settings.

Keycloak production guide

Exact redirect URIs and SAML audiences

Each Keycloak client should accept only the exact callback URLs that Open edX uses, with no wildcards for production hosts. For SAML, the Open edX service provider entity ID and assertion consumer service must match the Keycloak client configuration, and the audience restriction should name only that entity. Loose wildcards let an attacker who controls a second application on the same domain receive authorization codes or assertions. Review these values after every hostname or Tutor change.

Signing and encryption certificate lifecycle

SAML signing and encryption certificates expire, and an expired certificate breaks sign-in for every learner at once. Record the certificate validity dates, the owner who renews them and the procedure for publishing a new metadata file to Open edX before the old certificate lapses. Keep the Keycloak realm signing keys and the Open edX SAML key material in your secrets store, and limit who can export private keys. Test a rotation in a staging environment before production.

Least-privilege Keycloak clients

Create a dedicated Keycloak client for the Open edX LMS and, if needed, a separate one for Studio, rather than reusing an administrative or shared client. Disable direct access grants and implicit flows that Open edX does not need, turn on client authentication for confidential OAuth2 clients, and assign only the scopes and mappers that supply the attributes Open edX reads. Keep the realm's default client scopes narrow so other applications do not inherit the Open edX client's access.

MFA enforced in Keycloak

Multi-factor authentication belongs in Keycloak, because Open edX only sees the result of the login. Use a browser flow with a conditional or required OTP step for staff roles, and decide whether learners need it, based on the data they can reach. Confirm that the MFA requirement cannot be skipped by signing in through a local Open edX password, which bypasses the federated flow unless you disable local login for the affected accounts. Test each path a staff user can take.

Admin console access and metrics

The Keycloak admin console controls every realm, client and user mapping, so restrict it to a small group reached through a separate, MFA-protected route, and keep it off the public learner hostname. Enable Keycloak metrics and watch failed logins, lockouts, token errors and unexpected client registrations, then alert on sudden changes. Keep admin events and login events enabled, and confirm that the log destination is retained for the period your policy requires. Ask your Keycloak operator how metrics and audit events are exported in your deployment.

Keycloak metrics guide

Common Keycloak and Open edX login failures

This table lists the sign-in failures most often seen when Keycloak sits in front of Open edX, with the likely cause and the first check for each. Work down the rows in order of how often they block a whole cohort, and start each investigation by comparing the exact values in Keycloak's client and mapper settings with what the LMS expects. The main takeaway is that most failures trace to a mismatch between two configurations rather than to Open edX itself.

FailureLikely causeFirst check
Redirect URI mismatchThe callback URL registered in the Keycloak client does not match the LMS domain, scheme or path used at sign-in, often after a domain or HTTPS change.Compare the redirect URI in the Keycloak client with the LMS callback URL character by character, including https and any trailing slash.
Expired or mismatched SAML certificateThe Keycloak realm signing certificate was rotated or expired, or the LMS still holds an older certificate in its SAML metadata configuration.Check the certificate validity dates in the Keycloak realm keys and confirm the LMS has the matching metadata for that realm.
Missing email claimKeycloak does not send an email attribute in the token or assertion, so the LMS cannot create or match an account.Inspect a test login's attributes and confirm the email mapper is attached to the client scope the Open edX integration requests.
Duplicate accounts from email collisionsA learner already has an Open edX account with the same email under a different username or provider, so auto-registration or linking creates a second identity.Search the LMS user table for the email address and decide the account linking rule before enabling auto-registration for the cohort.
Clock skew between serversThe Keycloak host, the LMS host and the identity assertions disagree on time, so tokens or assertions appear expired or not yet valid.Verify network time synchronization on the Keycloak and Open edX hosts and compare timestamps in a failed login's logs.
Users locked out after a Keycloak upgradeA new Keycloak version changed client settings, default scopes, or database schema, or an automatic schema migration ran during startup.Review the upgrading guide for the target release, confirm client scopes and mappers still exist, and test sign-in in a staging realm first.

Questions buyers ask about Keycloak SSO for Open edX

How much effort does a Keycloak SSO integration with Open edX take?

Effort depends mostly on the protocol, the number of identity sources and the account policy you choose. A single SAML 2.0 or OAuth2 client with a clear attribute map is the smallest case. Each added source, each attribute the platform must receive, and each rule for linking existing accounts adds configuration and test cases. Ask any partner to break the quote down by protocol, by identity source, and by the account policy decisions (auto-registration, account linking, and who may sign in as staff). Those three inputs explain most of the difference between two quotes.

Can our team set up Keycloak SSO for Open edX without a partner?

Yes, if your team already runs Keycloak and Open edX, or has engineers comfortable with both. The work is mostly configuration: a Keycloak client, the Open edX third-party authentication settings, attribute mapping, and test accounts. The harder parts are the decisions about account linking and auto-registration, and the testing of edge cases such as users who already have an Open edX account with the same email address. A partner is most useful when the identity team is short on time or when the integration must be reviewed by a compliance team that expects documented evidence.

What does the work need from our identity team?

Your identity team should be ready to provide a few things early. These include the Keycloak realm and admin access for the test environment, the attributes Keycloak holds for each user (such as email, first name and last name), the rules for which users may sign in, and who approves the client secret or certificate handling. They should also confirm how Keycloak is deployed, because the high availability design and database choice affect the login path that Open edX depends on. Agree on these inputs before work starts so the schedule is not set by waiting on access.

How long does testing take, and what does it depend on?

Testing length depends on how many login paths you must cover, not on Open edX alone. Plan separate cases for new learners, returning learners, existing accounts matched by email, staff with elevated roles, users who are disabled in Keycloak, and failed or cancelled logins. Each identity source adds its own set of cases. The number of environments also matters: a test realm, a staging LMS, and a production check each need a sign-off. Ask for a written test plan with the scope so you can see which cases are included before you agree a timeline.

Do Keycloak upgrades affect the Open edX integration?

They can, so the integration should be part of your upgrade plan. Keycloak publishes minor releases several times a year, and its project states that breaking changes in a minor release are opt-in, which lowers the risk of surprise changes. The Keycloak Operator documentation also recommends manual approval mode for operator updates to avoid unintended automatic upgrades. Database schema migration runs automatically at startup by default, and administrators can apply it manually for large deployments. Test each Keycloak upgrade against a staging realm that mirrors your Open edX client settings before it reaches production.

What does a fixed-scope quote for this integration cover?

A fixed-scope quote follows from a written scope that names the work, the deliverables and the timeline. For this integration, expect the scope to list the protocol and identity sources in use, the attribute mapping, the account linking and auto-registration rules, the environments where work is done, the test cases, the handover documentation, and any post-launch support. Items outside the written scope, such as adding a second identity source later or changing account policy after launch, should be priced as separate work. DeployOpen does not publish a price list, so ask for the quote to show each of these items separately.

How a Keycloak login reaches the Open edX LMS

The flow starts with a learner's browser requesting a protected LMS page and being redirected to Keycloak, which is the identity provider. After the learner authenticates, Keycloak returns an assertion or authorization code to the LMS, which acts as the service provider or OAuth2 client. The LMS then matches the returned identity to an existing account, links it, or auto-registers a new user, depending on the chosen policy. Check that the returned email and username attributes map correctly and that the callback URLs match exactly.

Sign-in path from learner browser through Keycloak back to the LMS session.

Keeping the Keycloak connection working through upgrades

Plan Keycloak upgrades as a recurring task that can break the Open edX sign-in path, and decide before go-live who owns the client configuration. Keycloak has planned four minor releases a year since version 26.0, and a major release every two to three years, so the Open edX connection will face change several times a year. Per the Keycloak blog from October 2024, breaking changes in a minor release are opt-in, which means most upgrades should leave the openedx client, its redirect URIs and its attribute mappers untouched unless your team enables a changed behavior on purpose. Read the Keycloak upgrading guide for each target version before you schedule the change, and keep a record of which opt-in features are active.

Decide how the database schema will migrate. Keycloak applies schema changes automatically at startup by default, which is simple for a small deployment but means a rolling restart can change the database. For larger deployments the upgrading guide describes applying the SQL yourself, so a database administrator reviews it first. On the Operator side, the Keycloak Operator documentation strongly recommends manual approval mode for operator updates, so an upgrade does not happen unannounced. Confirm which mode your environment uses, who approves an update, and whether the database has a tested backup before each approval.

Test the Open edX login path after every Keycloak change, not only major ones. The check should cover a learner sign-in, a staff sign-in, a new account created through auto-registration if you enabled it, and a linked existing account, plus the attributes Open edX receives for name and email. Name one owner for the client configuration in Keycloak, such as the identity team, and one owner for the Open edX third-party authentication settings, such as the platform team, and write down who signs off a change to either side. Record the test results and the Keycloak version in your change log so a failed login can be traced to a specific release.

How DeployOpen scopes and delivers Keycloak SSO for Open edX

DeployOpen plans, builds, documents and supports Keycloak and Open edX SSO integration inside your own infrastructure, so the identity provider, the LMS and the staff who run them stay under your control. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.

How we scope

  • Confirm which protocol the LMS and Studio will use, SAML 2.0 or OAuth2, and why it fits your Keycloak setup.
  • Define which Keycloak realms, clients and user groups map to learners, course staff and administrators.
  • Agree in writing how attributes, account linking and auto-registration rules will behave before any build starts.

How we build

  • Configure the Keycloak client or identity provider entries and the matching Open edX third-party authentication settings.
  • Map name, email and role attributes from Keycloak into Open edX and test each mapping with sample accounts.
  • Test sign-in, sign-out, account linking for existing users and blocked registrations in a staging environment first.

How we hand over

  • Document the realm, client, attribute and account-linking settings so your team can review and change them later.
  • Provide a runbook covering certificate or client secret rotation, and the steps to add a new identity provider.
  • Walk your security, identity and course operations teams through the configuration and the test evidence collected.

How we support

  • Offer ongoing support, Keycloak and Open edX upgrades and continuous testing as retainers after handover.
  • Plan Keycloak upgrade checks, since minor releases follow a planned cadence and breaking changes are opt-in.
  • Retest SSO flows after each platform or identity provider change to confirm sign-in still works as documented.

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.