Per-tenant branding in Keycloak: what it does and when you need it
A SaaS or B2B team that must show each customer its own sign-in page needs to know where that look is set. In Keycloak, a theme is selected per realm or per client, and the login templates can vary by organization, so the choice of tenant model (one realm per customer, or organizations inside one realm) determines how much branding work you will carry. Branding covers more than the login form: Keycloak themes also control the account pages customers use to manage their profile and the email pages that send verification, password reset and invitation messages. Each of these surfaces needs to be considered, because a customer will notice a branded login page with a default-looking email.
A single shared theme is enough when all tenants accept the same brand, when tenants sit behind one company identity, or when the only per-customer difference is a logo and a color that a realm-level setting can carry. Teams with many customers who expect their own visual identity, or who must present a partner's brand inside a shared product, usually need separate theme variants. Before committing, confirm which login pages you must vary (login, registration, account, email), whether your tenant model is realm-based or organization-based, and how the organization-aware template behavior works in the Keycloak release you plan to run. The Keycloak server administration guide documents the Organizations feature and theme selection, and that is the reference to check against your version before designing templates.
Keep the decision tied to ongoing cost. Every theme variant is code that must be tested against each Keycloak upgrade, and every realm or client that points to a theme is a configuration item to keep consistent. Ask your partner or internal team to write down the number of variants, the pages each variant overrides, the owner of each brand asset, and how a new tenant gets its look during onboarding. Those answers decide whether branding stays a small configuration task or becomes a recurring maintenance line.
Which theme selection method fits each tenant model
With a realm per tenant, each customer has its own realm, and the theme is set in that realm's settings. The login, account, admin console and email themes are chosen per realm, so a tenant's branding belongs to its realm. Your admin work is to set the theme during realm creation and to keep each realm's theme name aligned with the theme files the server actually loads.
- Theme assignment: Choose the login theme in the realm's theme settings, and repeat for the account, admin console and email themes if those should also change.
- Per-tenant change: Updating one tenant's look means editing one realm, which keeps the blast radius small but multiplies the work during a company-wide rebrand.
- Theme files: Every theme variant is a set of files deployed to the server, so each added variant becomes one more artifact in every image or deployment.
- Breakdown point: As realm count grows, theme edits and upgrades turn into a scripted job that must run for every realm, and drift between realms becomes harder to spot.
- Confirm: Check how your version handles a realm that names a missing theme, and whether theme changes need a cache refresh or a restart.
Before you script realm creation, confirm which theme settings your version exposes per realm and how it resolves a missing theme name.
When many tenants share one realm and use the Organizations feature, the realm-level theme is shared by every member by default. A per-tenant look then depends on whether your version lets templates or the login flow vary by organization. The server administration guide documents organizations for membership and domains, so verify what it says about theme selection by organization context before you design around it.
- Shared realm theme: One login theme serves every organization by default, so a single theme change reaches all tenants at once.
- Organization-aware templates: Test whether your version lets a template read organization context and which organization data the template can access.
- Domain routing: Organization domains decide which members land in which organization, so confirm that routing and branding agree for users with more than one membership.
- Breakdown point: Per-tenant looks in a shared realm push variation into template logic, and that logic needs testing for each tenant, which grows with tenant count.
- Confirm: Build one pilot organization with distinct branding in a test realm, then check the login, error, and email pages for that organization.
Record the exact behavior you observe in your version, because template and selector details change between releases.
In a shared realm, a client can carry its own login theme, so the sign-in page started by one application can look different from the others. The setting lives on the client, and it applies when a login starts from that client. This is a per-application choice. It becomes a per-customer choice only when each customer has a dedicated client, which is a separate design decision.
- Setting: Set the login theme on the client using the client attribute your version documents, so flows started by that client use that theme.
- Per-customer fit: Per-customer branding through clients means one client per tenant, which multiplies client count, redirect URIs and secrets to manage.
- Precedence: Confirm which setting wins when the realm theme and the client theme disagree, and whether organization context can override either one.
- Breakdown point: Large client counts turn client configuration into a maintenance surface, and shared clients cannot give each customer its own sign-in page.
- Coverage: Test password reset, error and consent paths from each client, because some pages may still fall back to the realm theme.
Ask your Keycloak version's documentation for the exact attribute name and precedence rules before you rely on them in production.
The right method depends on how strongly tenants must be isolated, how many tenants you expect, and how different each tenant's login must look. Most designs use one method as the base and add a second only for specific exceptions. Mixing methods raises the number of places a theme can be set, so write down which method owns which setting before rollout.
- Strict isolation, few tenants: A realm per tenant gives each customer separate settings and a clear boundary for its theme.
- Many tenants, shared application: Organizations inside one realm keep administration in one place, but per-tenant visuals depend on template behavior you must verify.
- Branding per application: Per-client themes suit different products or portals inside one realm, and they scale poorly when each customer needs its own client.
- Custom selection logic: A custom selector that chooses a theme from tenant data needs extension code, and that code carries an upgrade cost on each Keycloak release.
- Documentation: Keep a single table that lists each tenant model, the setting that controls its theme and the owner of that setting.
Before you choose, run the pilot on the exact Keycloak version you plan to operate, because selector behavior is the part most likely to change.
Theme options compared on effort, isolation and upkeep
This table compares realm themes, per-client login themes, organization-aware templates and a custom theme selector on admin effort, tenant isolation, upgrade exposure and fit. Read each row as a trade-off: the option that looks cheapest to set up often carries the most maintenance once many tenants share one theme codebase. Confirm the exact theme configuration behavior for your Keycloak version in the server administration guide before you commit to a model.
| Option | Admin effort | Isolation between tenants | Upgrade exposure | When it fits |
|---|---|---|---|---|
| Realm theme | Low for one realm, grows with each realm added | Strong, because each tenant has its own realm and theme setting | Moderate: each realm's theme files must be checked on every upgrade | Few tenants that also need separate realms for users, keys or policies |
| Per-client login theme | Moderate: a theme setting is managed for each client | Partial: tenants sharing a realm can see the same realm defaults unless each client is set | Moderate: theme files still need review, and client settings must stay in sync | One realm serving several applications that need different looks |
| Organization-aware templates | Higher: templates must read organization context and handle missing branding | Depends on the application and template logic, so test each tenant path | Higher: custom template logic is the part most likely to break on upgrade | Shared realm where each organization needs its own logo, colors and text |
| Custom theme selector | Highest: selection logic and assets must be built and tested | Depends on how the selector maps a tenant to its assets, which must be verified | Highest: custom code sits on top of Keycloak theme internals | Many variants that cannot be expressed through realm or client settings alone |
| Upkeep of many variants | Grows with each variant: every template change is tested across variants | Risk of cross-tenant leakage of assets or text if mappings are wrong | Grows with variant count, so regression testing scope grows too | Confirm a variant count and test plan before adding new variants |
How many theme variants raise the maintenance cost
Every additional login theme variant is a copy of templates, message bundles, styles and static resources that the team must keep working on every Keycloak upgrade. The cost of a theme set is therefore not the one-time build alone. The recurring cost is the retest and review of each variant after each upgrade, and that cost grows with the number of variants even when each variant looks small on its own. Before you commit to a per-tenant theme model, ask the partner or your own team to estimate the retest effort per variant and to list which pages each variant overrides.
The one-time build cost covers the first theme, the shared base, the custom template logic and the selector that chooses a theme per realm, client or organization. The recurring cost covers regression testing of login, registration, password reset, email and account pages for every variant, plus review of the changes in each Keycloak release. Costs rise with the number of variants, with the number of custom templates that override base pages rather than only changing styles, with custom SPI providers that the theme depends on, and with how often you upgrade. A team that upgrades four times a year on a supported minor line faces more retests than one that upgrades less often, so align the upgrade cadence with the theme budget.
Keycloak plans four minor releases a year and says breaking changes in a minor release will be opt-in, as described in the Keycloak backwards compatibility note. Opt-in does not mean no impact, so read the upgrade notes for each target release before every theme retest. The 26.8 upgrade notes, for example, call out changes that touch authentication and email behavior, which can surface in custom login and email templates. Build the retest checklist from those notes, and confirm with your own test environment which variants a given change affects.
How to set up per-tenant themes in Keycloak
This sequence takes a Keycloak deployment from an agreed tenant model to a tested set of login themes, so each customer sees its own login look and the team knows the deployed image serves the right assets for every tenant.
Decide the tenant model and theme scope
Before any theme files exist, the platform owner and the application team agree which tenant boundary carries the branding: a realm per tenant, a shared realm with organizations, or a per-client setting. Record which login, account and email pages each tenant can change, and which pages stay common. This decision drives every later step, because realm-level and client-level theme settings behave differently and organization-aware logic only works where organizations are in use. The step is done when a short written matrix maps each tenant or client to its theme source. Confirm the exact theme setting names and their behavior for your Keycloak version in the server administration guide before you commit to the matrix.
Create the base theme
Build one base theme that holds the shared layout, styles, messages and templates for all tenants. Use the Keycloak theme structure documented for the login, account and email types, and keep the base theme free of tenant-specific logos, colors and copy. Store the theme source in version control so every change to shared pages is reviewed once. The output is a theme directory that loads locally against a development Keycloak instance and renders the default login page without errors. Confirm the theme directory layout and inheritance rules against the Keycloak theme documentation for the version you run.
Add per-realm or per-client theme settings
Create one theme variant per tenant that inherits from the base theme and overrides only its assets, such as logo, colors and messages. Then assign each variant in the setting that matches the model chosen in step one: the login theme on the realm, or the login theme override on a specific client. Keep the variant list in configuration, not in someone's memory, so that a later audit can match each tenant to its assigned theme. The step is done when an administrator can open the realm or client settings and see the expected theme name for each tenant. Check that a client-level override takes effect for that client and does not change the realm default for other clients.
Add organization-aware template logic where chosen
If the tenant model uses organizations, extend the login templates so they read the organization context that Keycloak supplies during sign-in and render the matching name, logo or provider button. Keep this logic small and tested, since every conditional added to a template is one more path to maintain on each Keycloak upgrade. Limit it to what the login page needs, and move anything larger into the application. The step is done when a sign-in started from one organization's domain shows that organization's branding, and a sign-in with no organization context shows the default page without a template error. Confirm which organization attributes the theme can read in your version before you write the conditions.
Build the theme package
Package the base theme and tenant variants into the artifact format your deployment uses, and run the build in the same pipeline that builds the Keycloak image. Check that the package contains every variant listed in the matrix and no stray development files. Keep the build reproducible by pinning the Keycloak version the theme was written against. The output is a versioned theme artifact with a checksum recorded next to the image tag. Confirm the packaging and build steps for your chosen image or Operator path in the Keycloak deployment documentation, since the supported method differs between container and Operator installs.
Deploy the theme into the Keycloak image
Deploy the theme artifact with the Keycloak image or the Operator configuration you already run, so every replica serves the same themes. Avoid editing theme files inside a running container, because the change is lost on restart and differs between replicas. Roll the change out in the same release process as other Keycloak configuration. The step is done when every running instance reports the same theme version and the new variants appear in the realm or client theme selectors. Verify the deployment path against the Keycloak Operator installation guide or your container documentation before you use it in production.
Test the login page for each tenant
For each tenant, open the login page through that tenant's public hostname, realm path or organization domain, and confirm that the expected logo, colors, messages and provider buttons load. Check the browser developer tools for any asset that returns an error, and confirm the page refers to the tenant's own stylesheet and images, not another tenant's. Test the password reset and email pages too, since these often use separate templates. Repeat the check after each theme change. The output is a short test log listing each tenant, the URL tested, and the result. Include one test with no tenant context to confirm the default page still renders.
Record the maintenance plan for theme variants
Document who owns the base theme, how a tenant variant is added or retired, and what must be retested after each Keycloak upgrade. Every variant adds template and asset work that must be checked when the login pages change between versions, so the number of variants is a running cost, not a one-time setup. Ask the implementation partner, or confirm internally, how many variants the team can keep current and which tests run automatically. The step is done when the plan is stored with the theme source and the team agrees on the upgrade retest list.
How Keycloak chooses the login theme for a tenant
The request starts in the browser at a public frontend hostname and passes through a reverse proxy that restricts paths, so only public login paths reach Keycloak. Keycloak then resolves the realm and client from the URL, and the client's login theme or the realm default decides which templates render the tenant's login page. The admin hostname sits behind a separate trust boundary, and the check to make is that theme overrides never change what is exposed on the admin side.
Theme resolution from the tenant's login request to the rendered page, with the admin boundary marked.
Security and operational risks in tenant-branded login pages
Every tenant theme is part of the login path that customers trust with their credentials, so a branding change can create security exposure as well as a visual one. The cards below cover the risks that most often appear when many tenant looks share one Keycloak, and the checks to run before and after each change.
Tenant data leaking into the wrong theme
A theme selector that reads tenant context from the request can show one customer's logo, name or support contact on another customer's login page if the lookup falls back to a default or matches on the wrong value. The risk grows when themes are chosen per client or per organization. Check that every theme resolution path has an explicit failure mode, and test login pages for each tenant with a session started from a different tenant's URL.
Keycloak production guideUnescaped content in custom templates
Custom FreeMarker templates and tenant-supplied text such as welcome messages, footers or legal notices can inject markup into pages that handle credentials. Treat every value that comes from a tenant record as untrusted input, avoid raw output of fields you did not author, and keep tenant copy in plain text or a reviewed allowlist. Include template changes in the same security test pass as the login flow itself.
Branding assets served from untrusted hosts
Logos, background images and stylesheets loaded from a customer's own server can change what users see without any change on the Keycloak side, and they can expose users to tracking or mixed-content warnings. Decide which hosts are allowed for tenant assets, serve them over TLS, and store approved files with the theme so the login page does not depend on a third-party host being available.
Admin console on the public hostname
Themed login pages are served on the public frontend URL, and the admin console and Administration REST API should sit on a different hostname or context path. If a theme change or a shared reverse proxy rule exposes the admin paths on the same host as tenant pages, administrative endpoints become reachable from the same surface that customers use. Confirm the proxy path restrictions after every routing change, not only at initial install.
Keycloak production guideTheme changes that bypass review
Themes are files deployed with the server, so a direct edit on a running node or a per-tenant upload can change production login pages without the review that application code receives. Keep theme source in version control, require a reviewer for changes to templates and scripts, and deploy them through the same pipeline as other configuration. Record which theme version each tenant received so a rollback is a known action.
Login failures after a theme change
A template error or a missing message key can break the login form for one tenant while others keep working, and users may only report it as a failed sign-in. Watch login error counts per realm or client after each theme release, and use Keycloak's Prometheus-format metrics enabled on the management interface to compare before and after. Persisted login failures in the database can also help trace when a regression began.
Keycloak metrics guideQuestions buyers ask about per-tenant Keycloak branding
How much does a per-tenant Keycloak theme project cost?
No supplied figure sets a price for this work, and DeployOpen does not publish a price list. The cost follows from the written scope, which is driven by the number of tenant variants, how far each one departs from the base theme, whether custom templates are needed for organization-aware pages, and whether email templates are included. Ask for a quote that separates one-time build work (theme structure, base styling, testing) from recurring work (adding a tenant, upgrade regression testing, template maintenance). Ask who tests on which Keycloak version and what the handover includes.
How long does per-tenant theme setup take as tenant count grows?
Setup time depends less on the first theme than on how much each additional tenant changes. A shared base theme with small per-tenant overrides, such as logo, colors and copy, is quick to extend. Separate full theme variants for each tenant multiply testing and review work with every added tenant. Ask the vendor for a timeline tied to a named tenant count, a named set of page types (login, registration, password reset, account, email) and a named staging realm. Ask how new tenants are added after launch and whether that step is part of the quote or a separate task.
What does our team need to provide for a branding project?
Your team provides the brand assets and approvals that the build depends on. Typical inputs include logos in the formats each tenant supplies, color values, approved copy for each login page, and the name of an approver per tenant who signs off on screens. You also need test accounts in each realm or organization, and a staging realm that mirrors production clients and identity providers, so screens can be checked before release. Confirm these inputs in the statement of work, with dates for each approval, since late assets are a common cause of schedule slips.
Can our internal team build and maintain per-tenant themes alone?
Yes, if your team has someone comfortable with FreeMarker templates, Keycloak theme properties and the Keycloak documentation for theme types, and a repeatable test process. The harder part is the ongoing discipline: each theme change needs review in every tenant variant, and each Keycloak upgrade needs regression testing across all of them. Consider how many people can cover the work if the one maintainer leaves. A partner can build the initial structure and hand it over, or run it as a retainer. Whichever path you choose, put the ownership of templates, assets and the test matrix in writing.
How does theme upkeep change across Keycloak upgrades?
Every theme variant is custom code that sits on top of Keycloak's login and account pages, so each upgrade can change templates, message keys or styles that your variants depend on. Keycloak ships minor releases several times a year, and the upgrade notes for each release list changes to test against. The upkeep cost grows with the number of variants, because each one needs its own visual and functional check after the upgrade. Keep the base theme small, pin Keycloak versions in a staging realm first, and ask any provider how it will track upgrade notes and retest each tenant variant.
Can Keycloak emails carry each tenant's branding?
Yes, email templates are part of the theme and can be styled per realm or per client theme, but this needs its own design and testing. Each email type, such as verification, password reset and invitation, has its own template and message text, so a tenant variant includes them all. Email delivery also depends on your sending domain and SMTP setup. Keycloak's upgrade notes for the 26.8 line enforce STARTTLS for SMTP without plaintext fallback, so confirm your mail relay supports that before testing branded messages. Ask for test sends to real mailboxes in each tenant's configuration.
When should we move from theme variants to a different tenant model?
Move away from theme variants when the number of variants makes testing and upkeep the main cost, or when tenants need different login rules, not only different looks. If tenants differ in identity providers, MFA policy or user data, a realm or organization model may fit better than many themes. Organizations inside one realm can handle per-customer identity provider routing and membership, while a realm per tenant gives stronger separation at higher admin cost. Review the tenant model before the theme design is final, because changing it later means rebuilding both the branding and the routing around it.
What changes for your team after the theme goes live
Once tenant themes are live, the first thing to settle is who may change them. Name one owner for the shared base theme and a named approver for each tenant's brand assets, such as logos, colors, and legal footer text. Brand changes should pass through a written request that records the tenant, the asset, the approver, and the date, so that a marketing edit does not reach a production login page without review. Keep the approval list in the same change system as the theme repository, and review it whenever a customer's contact or admin changes.
Onboarding a new tenant should not require a code release. The practical pattern is to keep the base theme stable, store each tenant's brand values as configuration or assets in version control, and have the automation that creates the organization or realm assign the theme and its client bindings. Confirm with your platform team which parts of this your Keycloak version lets you set through the Admin REST API and which need a redeploy of theme files, because that determines whether a new tenant can go live in the same window as the rest of its setup. Test the first login page for each new tenant before the customer is told it is ready.
Each upgrade cycle needs a theme test pass, because Keycloak's template and message keys can change between releases and a broken page often shows up only on a less common path, such as the password reset or the error page. Plan a scripted check that loads every tenant's login, registration, and account pages in a staging instance running the target version, and keep a list of the custom templates you override so you know which ones to diff against the upstream change notes. Retiring a tenant's theme follows the reverse path: remove the client bindings first so that no live login uses the theme, then delete the theme assets, then remove the approval entries and the stored brand files, and record the retirement in the same change log.
How DeployOpen scopes and delivers tenant branding
DeployOpen plans, builds, documents and supports self-hosted Keycloak inside your own infrastructure, including the theme work that gives each tenant its own login experience. The engagement starts with a written scope that fixes which tenants, clients and pages are covered before any theme code is written.
How we scope
- Inventory every tenant, realm, organization and client that will show a branded login page.
- Agree in writing which pages are covered: login, registration, account, email and error screens.
- Define the theme selection rule, such as organization, client or realm, and the fallback for unknown tenants.
- Record the number of theme variants you expect now and how new tenants will be added later.
How we build
- Build a base theme with shared templates, then layer tenant-specific logos, colors and copy on top.
- Keep per-tenant overrides in version-controlled files so each variant can be reviewed and rolled back.
- Test each variant across login, registration, password reset and error paths on the Keycloak version you run.
- Check that branded pages do not expose tenant data, internal hostnames or admin endpoints.
How we hand over
- Deliver the theme source, build steps and a register of every tenant variant with its owner and assets.
- Document how to add a new tenant theme and which templates need retesting after a Keycloak upgrade.
- Provide a test checklist for each variant so your team can verify changes before they reach production.
- Walk your platform and support staff through the selector logic and the escalation path for broken pages.
How we support
- Retest branded pages when you move to a new Keycloak release, since custom templates can change between versions.
- Review the number of theme variants periodically, because each one adds upgrade and testing effort.
- Ongoing support, upgrades and continuous testing are available as a retainer after handover.
- Confirm support scope, response expectations and upgrade ownership in the written agreement before work begins.

