Open WebUI SSO with Keycloak

Signing in to Open WebUI through a Keycloak realm with OIDC needs a confidential client, an exact redirect URI and claims mapped to groups and admins. This page covers each step and the 8080 port conflict.

On this page

Open WebUI SSO with Keycloak: how the OIDC sign-in works

If your organization already runs a Keycloak realm for workforce sign-in, the question is how to let staff use that realm to reach a self-hosted Open WebUI instance without a second password. The supported route is generic OIDC: Open WebUI acts as an OpenID Connect relying party, and Keycloak acts as the identity provider through a confidential client that Open WebUI authenticates with a client secret. Keycloak handles the password, MFA policy and session with the user, then returns an identity to Open WebUI, which creates or matches a local account. Keycloak itself is an open source identity and access management server under Apache 2.0 that supports OpenID Connect, OAuth 2.0 and SAML 2.0, so the realm you already operate can usually serve this role without a new product.

For users, the visible change is a sign-in redirect to your Keycloak login page instead of a local Open WebUI password prompt. For administrators, the change is larger. Open WebUI still keeps its own user records, roles and group memberships, so you must decide which Keycloak attributes or group claims drive those local settings, and who is allowed to sign in at all. Access in Keycloak is governed by the realm and client configuration, and Open WebUI's own role and group model applies once a user is inside. Confirm with your Keycloak administrators which realm, client and claims they already maintain, and confirm with your Open WebUI team whether local password sign-in will stay enabled as a fallback, since that choice changes your exposure if the identity provider is unavailable.

DeployOpen works inside your infrastructure on this integration: the Keycloak realm, the Open WebUI deployment, the network path between them and the secrets involved all stay in environments you control. Before any configuration, record the public Open WebUI URL, the Keycloak issuer URL, the client ID and secret ownership, and the redirect URI Keycloak will accept, because a mismatch in any of these is the most common reason first sign-ins fail. Also check the Open WebUI release you run against the Open WebUI features documentation, which describes the OIDC and group options this page relies on, and confirm the Keycloak version your team supports against the current release notes.

What you need before configuring Keycloak and Open WebUI

Most SSO problems with Open WebUI and Keycloak start before any client is created: the wrong Keycloak release, a database that cannot take the load, or an Open WebUI URL that changes later. Settle these inputs first, because the redirect URI, token lifetimes and group claims all depend on them. The cards below cover what to confirm on each side.

Target Keycloak release

Plan against Keycloak 26.8.1, the current release as of October 13, 2026. Keycloak ships four minor releases a year, and breaking changes in a minor release are opt-in, so pin the version you test with and record it. If your organization requires Red Hat support, confirm whether the Red Hat build of Keycloak version you need matches the upstream release you tested against.

Keycloak docs

Production database for Keycloak

Keycloak's dev-file database is for development only. Use one of the supported production databases, such as PostgreSQL 14 to 18, and confirm the version against the database guide before you install. Schema migration runs automatically at startup by default, so decide whether your team applies it manually for larger deployments and back up the database before any upgrade.

Database guide

Stable public HTTPS URL for Open WebUI

The redirect URI registered in Keycloak must match the public address users type in the browser, including scheme, host and path. Choose the final hostname before you create the client, and put a reverse proxy with a valid certificate in front of Open WebUI. Changing the hostname later means updating Keycloak redirect URIs, Open WebUI settings and any bookmarks in one change window.

Open WebUI version and install method

Choose one version and install method, Docker, Docker Compose, Kubernetes with Helm, or pip with open-webui serve, and record it with the Open WebUI release you tested. Newer releases fall under the Open WebUI License, so confirm the licensing terms for your user count before rollout. Keep the same version in test and production so OIDC behavior matches what you validated.

Latest release
v0.12.3
Open WebUI features

Redis and external vector store for replicas

A single replica can run on SQLite only when the database file sits on locally attached SSD or NVMe storage, not network storage. Multiple replicas need PostgreSQL, Redis for shared sessions and websocket state, shared file storage, and an external vector database, because the default ChromaDB crashes in multi-process setups. Without Redis, signing out does not revoke tokens, which stay valid for 4 weeks by default.

Scaling guide

Administrator access in both systems

You need an administrator in the Keycloak realm who can create clients, protocol mappers and groups, and an administrator in Open WebUI who can set the OIDC configuration and role mapping. Confirm who holds each role and who approves changes. Keycloak's operator recommends manual approval mode for updates, so ask who controls operator upgrades if you deploy on Kubernetes.

Keycloak admin guide

How to configure the Keycloak client and Open WebUI

This sequence connects a Keycloak realm to Open WebUI through a confidential OIDC client, passes group data in the ID token, and proves that both regular and administrator users sign in and receive the right access. The result is a working single sign-on path you can test before any users depend on it.

  1. Choose or create the Keycloak realm

    Pick the realm that holds your workforce users, or create a dedicated realm for Open WebUI so its clients, roles and groups stay separate from other applications. Confirm that the users who need access exist in this realm, that they can sign in to the Keycloak account console, and that the groups you plan to map to Open WebUI are visible in the admin console. Check the realm's OpenID discovery document at the realm's well-known configuration path, which confirms the issuer URL you will enter in Open WebUI.

  2. Create a confidential OIDC client

    In the realm, create an OpenID Connect client for Open WebUI and set client authentication to on so Keycloak issues a client secret. Enable the standard authorization code flow and turn off flows Open WebUI does not use. Store the client ID and client secret in your secrets manager, not in a shared document. The check is that the client's Credentials tab shows a secret, and that the client appears with the confidential access type in the client list.

  3. Set the redirect URI to the Open WebUI callback

    Build the callback address from the public URL users will type into their browser, using the OAuth callback path that Open WebUI's SSO documentation specifies for your version, and add it as a valid redirect URI. The public URL must match what Open WebUI is configured to use, including scheme, host and port. Set the web origins to the same base URL. Confirm the exact path against the current Open WebUI documentation before you enter it, because a mismatch produces a redirect error at sign-in.

  4. Expose a groups claim through a mapper

    Add a group membership mapper to the client or to a dedicated client scope, set the token claim name that Open WebUI will read, and include the claim in the ID token. Decide whether group paths or group names are emitted, and keep the setting consistent with the group names you configure in Open WebUI. Add a mapper for the roles or admin group if you plan to derive administrator rights from it. The check is to sign in once as a test user and decode the ID token to confirm the groups claim is present and lists the expected groups.

  5. Set Open WebUI OAuth environment variables

    Set the OAuth client ID, client secret, OpenID discovery URL, provider name, scopes including the openid, profile and email scopes plus the groups scope if used, and the group claim name in the Open WebUI environment or deployment configuration. Also set the WebUI public URL so generated redirects are correct. Use the variable names from the Open WebUI SSO documentation for your release, since misspelled names are silently ignored. Confirm the values by reading them back from the running container's environment before you restart.

  6. Restart Open WebUI and confirm the login button

    Restart the Open WebUI service so it reads the new configuration, then open the public URL in a private browser window. The sign-in page should show the Keycloak option instead of, or alongside, local login. If it does not appear, check the startup logs for configuration errors and confirm that the discovery URL responds from the Open WebUI host. Persistent configuration in the admin settings can override environment variables, so verify those settings match what you intended.

  7. Test a non-admin sign-in

    Sign in with a standard test user from the Keycloak realm who is not in any administrator group. Confirm that the redirect returns to Open WebUI, that the user lands in the chat interface, and that the Open WebUI user list shows the account with a user role and the expected group memberships. Confirm that this user cannot open the admin settings pages. Record the result so you can compare it with the administrator test.

  8. Test an administrator sign-in

    Sign in with a test user who belongs to the administrator group or role mapped in the previous steps. Confirm that Open WebUI assigns the admin role and that the admin settings pages are available. If the role does not change, decode the ID token again to check the claim contents and the mapping configuration. Once both tests pass, repeat them with a user who has just been removed from the group to confirm that privileges are withdrawn on the next sign-in.

How the Keycloak login flow reaches Open WebUI

The sign-in starts when a user browser opens Open WebUI and is redirected to the Keycloak authorization endpoint in the realm. After the user authenticates, Keycloak returns an authorization code to the Open WebUI callback, and Open WebUI exchanges that code server to server for tokens and reads user details from the userinfo endpoint. Check that the groups claim arrives in that response, because Open WebUI assigns groups and admin roles from it, and that the redirect URI matches exactly.

OIDC authorization code flow between the browser, Open WebUI and Keycloak.

Which Keycloak claims map to Open WebUI groups and admin roles

This table lists each identity attribute Open WebUI needs from Keycloak, where it comes from in the realm, where it lands in Open WebUI, and what breaks when it is missing. Read it row by row when building the client scopes and mappers, and treat the admin row as the one to restrict most tightly.

AttributeKeycloak sourceOpen WebUI targetFailure if missing
Subject (sub)Built-in subject claim on the ID token, issued for the confidential client's usersStable OIDC identity key used to link the account on each sign-inSign-in fails or accounts duplicate if the subject is not stable per user
EmailUser email attribute exposed through the email client scope, with the email claim in the ID token or userinfoAccount email and the field used for email-based account matchingAccounts may be created without an email, and matching by email or domain restrictions stop working
Preferred usernameUsername property mapped through the profile client scope as preferred_usernameDisplay name and login name shown to users and adminsUsers appear with opaque IDs, which makes group and audit review harder
Groups claimGroup Membership mapper on the client's dedicated scope, set to add the group path to the ID token and userinfoOpen WebUI groups created or updated at login, when group sync is enabledUsers receive no group memberships, so group-based model access and sharing do not apply
Role or admin signalRealm role or group mapped into a dedicated claim (for example, a roles claim) through a user realm role or hardcoded role mapperAdmin rights in Open WebUI, granted only when the configured claim value matchesNo user is promoted to admin, or admin rights stay with a bootstrap account that must be managed separately
Admin group scopeA single named Keycloak group (for example, a small platform admins group) that is the only source of the admin signalLimits the admin role to people explicitly placed in that groupIf the mapper matches a broad group, too many users become Open WebUI admins; confirm membership before go-live
Claim name consistencyMapper claim name must match the claim name configured in Open WebUI's OIDC settings exactlyConfigured claim names read from the tokenGroups or admin status silently never arrive, the most common cause of empty group lists

Resolving the port 8080 conflict between Keycloak and Open WebUI

When Keycloak and Open WebUI run on the same host without a proxy, both processes try to bind 8080 and the second one fails at startup. The fix is to move one of them to another port. In most single-host setups, move Open WebUI, because Keycloak's hostname and port appear in its issuer value, discovery document and client settings, so changing them later affects every application that trusts the realm.

  • Pick the service to move: Keep Keycloak on its default if it is already integrated, and change only the Open WebUI listening port in most cases.
  • Set Keycloak's HTTP port if you move it: Use the documented http-port option (environment variable KC_HTTP_PORT), and confirm the exact key for your release in the production configuration guide.
  • Set Open WebUI's port: Use the port option or environment variable in the Open WebUI deployment documentation, and confirm which one your install method reads.
  • Update the redirect URI: The Keycloak client's valid redirect URI must match the port users actually open, so edit it whenever the Open WebUI port changes.
  • Restart in order: Start Keycloak first, then Open WebUI, so the discovery request succeeds on the first attempt.

Check that both services start without bind errors and that the realm's discovery document lists the issuer you expect.

Security settings for a Keycloak-backed Open WebUI

Keycloak can authenticate users, but the security of the sign-in path depends on how the client, redirects, admin mapping, token lifetimes and logs are configured on both sides. The cards below cover the settings to review before go-live and the checks that confirm they hold after each change.

Confidential client secret storage

The Open WebUI client in Keycloak should be a confidential client, so the client secret is held server side and never placed in a browser or a shared script. Store the secret in a secrets manager or an orchestrator secret, not in a Compose file committed to version control. Rotate it on a schedule and after any staff change, then confirm that old secrets stop working in both Keycloak and the Open WebUI environment.

Exact redirect URI matching

Register the single callback URL Open WebUI uses in the Keycloak client, with no wildcards and no broad patterns such as a bare domain followed by an asterisk. Each environment, including staging and any test instance, should have its own client or its own explicit URI. Check the registered value character by character against the public WebUI URL, since a trailing slash or port mismatch is a common cause of failed logins.

HTTPS on both sides

Serve Open WebUI and the Keycloak endpoints only over HTTPS, and make sure the public URL Open WebUI advertises uses the https scheme. Keycloak should be configured for production mode with a proper hostname rather than accepting plain HTTP from users. Confirm that the reverse proxy forwards the original scheme and host, because a mismatch can produce redirects that look successful but send credentials across an insecure channel.

Admin mapping limited to one group

Map Keycloak roles or groups to Open WebUI admin rights only through a single, named administrator group that a small number of people control. Do not map broad groups such as all employees or a general IT group to admin. Review who holds membership of that Keycloak group on a fixed cadence, because a user who gains it at the identity provider gains administrative control of Open WebUI at next sign-in.

Short session and token lifetimes

Shorten Keycloak access and session lifetimes to match your risk tolerance, and make sure Open WebUI's own session settings do not outlast them. Keycloak defaults and Open WebUI token expiry are separate settings, so confirm both. Ask the vendor or your test results which lifetimes apply to refresh tokens, since the defaults determine how long a stolen token remains usable.

Redis for revocation across replicas

Without Redis, signing out of Open WebUI does not revoke tokens, which remain valid until expiry, by default after 4 weeks. For more than one replica, deploy Redis as the shared state store so that sign-out and session state are consistent across every instance. Test the path by signing out on one replica and confirming that the old token is rejected on another.

Scaling docs

Logging sign-ins and admin changes

Enable logging for successful and failed sign-ins in Keycloak, and for admin console and group membership changes, then forward those events to the central log platform your security team already uses. In Open WebUI, record changes to admin roles and group membership as well. Test that an alert fires when a user is added to the administrator group, and set a retention period that matches your audit policy.

Why Keycloak sign-in to Open WebUI fails and how to fix it

This table lists the failures that most often block Keycloak sign-in to Open WebUI, with the cause, the check to run and the fix for each. Work down the rows in order, because a wrong public URL or redirect URI blocks sign-in before group and role mapping ever matters.

SymptomLikely causeCheckFix
Keycloak shows Invalid redirect URIThe redirect URI registered on the Keycloak client does not exactly match the callback Open WebUI sendsCompare the client's valid redirect URIs in the Keycloak admin console with the callback built from your WebUI URL, including scheme, host, port and pathRegister the exact callback URL on the confidential client and remove stale or wildcard entries you do not need
Callback goes to the wrong host or port, or sign-in loopsWEBUI_URL is missing, points to an internal address, or differs from the URL users type in the browserConfirm the public URL in the Open WebUI environment and check whether the persistent config still overrides itSet the public HTTPS URL users use, restart Open WebUI, then repeat the sign-in test from a fresh browser session
Token exchange fails with invalid client or unauthorized clientThe client secret in Open WebUI does not match the secret in the Keycloak client's Credentials tab, or the client is publicConfirm Client authentication is on, so the client is confidential, and compare the secret value after copying it without stray spacesRegenerate or copy the secret from Keycloak, store it in the Open WebUI secret source, and restart so the new value loads
Sign-in succeeds but no groups appear in Open WebUIThe groups claim is not in the ID token or userinfo response, usually because no mapper exists or the scope is not requestedDecode a test token or call the userinfo endpoint and look for the groups claim with the expected name and valuesAdd a group membership mapper to the client scope, enable it for the ID token and userinfo, then sign out and sign in again
Users sign in but do not get admin rightsThe admin role or group is not in the claim, the mapping key is misspelled, or the user is not a member of the Keycloak groupCheck the user's group membership in Keycloak and confirm the claim value matches the configured admin group name exactlyAdd the user to the admin group in Keycloak, correct the claim name or value in Open WebUI, and have the user sign in again
Open WebUI or Keycloak fails to start on port 8080Both services default to 8080 on the same host, so one process cannot bind the portList listeners on the host and check which process holds 8080 before changing anythingMove one service to another port or put both behind a reverse proxy on separate hostnames, and update the WebUI URL and Keycloak hostname to match
Signed-out sessions still work after sign-outWithout Redis, sign-out does not revoke tokens, which stay valid until expiry (by default 4 weeks per the scaling guide)Sign out, then reuse the old session cookie or token in a second browser and see whether requests still succeedConfigure Redis as the shared session store for Open WebUI, and plan how long tokens and sessions should last in your environment

Questions buyers ask about Keycloak SSO for Open WebUI

How long does Keycloak SSO for Open WebUI take to set up?

No duration is fixed for this work, and the honest answer depends on what already exists. The main drivers are whether a Keycloak realm is already in production, how many groups and roles need to map to Open WebUI groups and admins, and how many environments (test and production) must be configured. A team with a mature Keycloak realm, a clear group model and a test group ready to use will move much faster than one designing the realm from scratch. Ask any provider to break the estimate into realm and client configuration, Open WebUI configuration, testing and cutover, so you can see which part drives the schedule.

What does our team need to provide before the work starts?

Three things make the work move: administrative access to the Keycloak realm, administrative access to the Open WebUI instance, and a test group of users who can sign in during validation. Keycloak access is needed to create the confidential client, configure the redirect URI and add group or role claims to tokens. Open WebUI access is needed to set the OIDC environment variables and confirm group and admin mapping. A test group lets you prove that a user from each intended role lands with the right permissions before production users are affected. Confirm with your identity team who owns realm changes and change approval.

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

Yes, a team with Keycloak and Open WebUI experience can do this internally, and the configuration itself is not large. The risk lies in the details that cause sign-in failures: an incorrect WebUI URL, a redirect URI that does not match the client exactly, a group claim that never reaches the token, or a persistent configuration value overriding an environment variable. Internal teams should also plan the port conflict on 8080 that can appear when Keycloak and Open WebUI run on the same host. Decide early whether your team has the time to test each role path and document the result for your security reviewers.

What does a fixed-scope DeployOpen engagement cover for this topic?

A fixed-scope engagement covers the agreed deliverables in writing before work starts. For this topic, that typically means reviewing the Keycloak realm design, creating the confidential client and redirect URI, configuring group and role claims, mapping them to Open WebUI groups and admins, resolving the 8080 port conflict where it applies, testing sign-in for each role, and documenting the configuration. Scope is confirmed in writing, and the quote follows from that scope. DeployOpen does not publish a price list. Ask for the exact list of Keycloak and Open WebUI environments, the test cases, and whether production cutover support is included.

What recurring work follows go-live for Keycloak and Open WebUI SSO?

Recurring work falls into three groups: platform upgrades, group maintenance and configuration review. Keycloak publishes four minor releases a year and says breaking changes in a minor release will be opt-in, but each upgrade still needs testing against your realm and clients. Open WebUI also releases frequently, and its upgrade practice should be checked before each move. Group maintenance is ongoing as teams change, and new groups or roles may need mapping to Open WebUI permissions. Plan an owner for each of these tasks. Retainers for ongoing support, upgrades and testing are available from DeployOpen if you prefer to outsource them.

Does Keycloak require a separate license to use with Open WebUI?

Keycloak is open source and licensed under Apache 2.0, so self-hosting it for sign-in does not require a commercial license from the Keycloak project. Confirm the terms of any distribution you choose: Red Hat build of Keycloak is a supported product from Red Hat with its own subscription terms, so a subscription may be needed if you want Red Hat support. Separately, Open WebUI has its own licensing: code from v0.6.6 onward falls under the Open WebUI License, which has a branding clause for larger deployments. Review that license with your legal team, because it is independent of the Keycloak choice.

What is the most common reason Keycloak sign-in to Open WebUI fails?

The most common failures come from mismatched configuration rather than from Keycloak itself. Check that the confidential client's redirect URI matches the Open WebUI callback URL exactly, including scheme and path, that the WebUI URL setting is correct, and that the client secret is stored in the environment where Open WebUI reads it. Confirm the group or role claim is included in the access or ID token, since missing claims cause silent permission gaps. Finally, look for persistent configuration overriding environment values, and for the port conflict on 8080 when both services share a host.

Keeping Keycloak and Open WebUI upgrades from breaking sign-in

Treat every Keycloak and Open WebUI upgrade as a sign-in change until a staging test proves otherwise. Keycloak plans four minor releases a year and a major release every two to three years, and since Keycloak 26.0 the project says breaking changes in a minor release will be opt-in. That lowers the risk of a surprise, but it does not remove the need to check. Keycloak's operator documentation strongly recommends manual approval mode for operator updates, so an upgrade happens only when your team approves it. Keep that setting on. Automatic upgrades are the most common way a working realm stops accepting sign-ins without anyone making a change.

Keycloak also migrates its database schema automatically at startup by default. That is convenient for small realms but means the schema changes the moment a new image starts against the database. For large deployments, the upgrading guide suggests manual migration, where your database team reviews and applies the SQL before the new server starts. Whichever path you choose, take a database backup first and confirm that the rollback image is still available. Open WebUI releases need their own test. Check the client ID, client secret, redirect URI, the group and role claim names, and the admin mapping against a staging copy of the realm after each Open WebUI upgrade. Confirm the current release notes in the Open WebUI releases on GitHub page before you schedule the change.

Build the process around a staging realm that mirrors production users, groups, client scopes and the oidc settings Open WebUI uses. Upgrade Keycloak in staging first, then Open WebUI, then run a sign-in test with an admin account, a standard user and a user from a group that should be blocked. Write down a rollback plan before the production change: the previous Keycloak and Open WebUI image tags, the database backup and restore steps, and who can make the call to revert. Confirm with your platform team how long a restore takes in your environment, because that figure depends on your database size and infrastructure, not on a number this page can supply.

How DeployOpen scopes and delivers Open WebUI SSO with Keycloak

DeployOpen treats Open WebUI SSO with Keycloak as a fixed-scope engagement inside your own infrastructure. We agree the realm design, client settings, claim mapping and test cases in writing, then build, verify and document the integration so your identity and security teams can review it.

How we scope

  • We confirm your Keycloak version, hosting model and how Open WebUI will be deployed before any build work starts.
  • The written scope names the realm, confidential client, redirect URI, group and role claims, and the admin and user mappings in Open WebUI.
  • We agree the port handling for the 8080 conflict, the test users and the acceptance checks, with ongoing support available as a retainer.

How we build

  • We configure the Keycloak realm, client scopes and mappers so group and role claims arrive in the format Open WebUI expects.
  • We set the Open WebUI OIDC environment variables, redirect URI and group mapping, then test sign-in with users from each mapped group.
  • We check sign-out behavior, token lifetime and whether Redis is needed for your replica count, and record each decision.

How we hand over

  • You receive a written configuration record covering realm settings, client secrets handling, claim mappings and Open WebUI variables.
  • We document the test results, known limits and the steps to add a new group or change an admin mapping without a rebuild.
  • We walk your identity and operations teams through the setup so they can review it and run it after handover.

How we support

  • Support and maintenance can be covered by a retainer that includes planned Keycloak and Open WebUI upgrades and retesting of sign-in.
  • Before each Keycloak or Open WebUI upgrade, we retest the OIDC flow, claim mapping and group permissions in a non-production copy.
  • Continuous testing of the sign-in path is available as part of the retainer, with findings reported with fixes and retest results.

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.