Keycloak SSO Multiple Applications

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up keycloak sso multiple applications by adding each app to one shared realm. Users log in once, and the identity server shares the active session across every registered client. Engineering teams often group internal web apps, admin panels, and APIs inside the same realm. When teams assign broad realm roles, one login grants too much power across every linked system. How keycloak sso multiple applications work in one realm A realm acts as a shared trust space for your users and your

Keycloak + Legacy Application SSO: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up keycloak sso multiple applications by adding each app to one shared realm. Users log in once, and the identity server shares the active session across every registered client. Engineering teams often group internal web apps, admin panels, and APIs inside the same realm. When teams assign broad realm roles, one login grants too much power across every linked system.

How keycloak sso multiple applications work in one realm

A realm acts as a shared trust space for your users and your apps. Each app registers as a separate client inside that single realm. You can mix OpenID Connect apps and SAML apps inside the exact same realm. When a user opens the first app, the app sends them to the login page.

The user enters their password and passes a second factor check. The identity server creates a central login session and sets a browser cookie for that realm. Next, the server sends an identity token back to the first app. Now the user wants to open a second app in the same realm.

The second app redirects the browser to the identity server to check for a session. The server reads the existing realm cookie and skips the password prompt. It issues a fresh token for the second app right away. This flow lets workers move between internal tools without typing passwords all day.

Managing client roles and token scope across apps

Sharing a login session does not mean every user should enter every app. If you use global realm roles for everything, permissions bleed across different tools. A better setup uses specific client roles for each individual app in the realm. Client roles stay scoped to one target app so permissions stay separated.

You can also limit what goes inside each token by tuning client scopes. By default, a token might carry roles for every app in the whole realm. That makes tokens large and exposes role data to apps that do not need it. Scoping tokens down ensures each app only reads the roles meant for its own checks.

Teams also need a clear plan for logging out of shared sessions. When a user logs out of one app, the server can end the whole realm session. It sends logout signals to the other active apps so they clear their local sessions too. Without clean logout handling, stale sessions keeps the session active in other browser tabs.

Keycloak + Legacy Application SSO: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What single sign-on solves and where gaps remain

Central sign-on solves password sprawl and gives teams one place to turn off user accounts. When someone leaves the team, you disable one profile to block every linked web app. It also enforces strong multi-factor checks before anyone reaches an internal dashboard. Still, identity tokens only decide who can log in at the start of a session.

Once an engineer passes the login check, the identity server steps out of the way. It cannot see what queries an engineer runs inside a database tool or admin console. It cannot require a peer to approve a risky command right before it runs. And it cannot rewrite sensitive data like emails, phone numbers, or card numbers in query results.

Teams often map a single login role to a shared admin account inside backend systems. Every engineer with that role gets full write power the moment they log in. Auditing also splits across many tools because the login server only logs the initial sign-in event. To control live actions and protect sensitive fields, teams need controls at the execution layer.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev sits inline in the protocol beside each supported service as an open-source proxy, a sidecar for your database or API. For every query or command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human approval.

First, hoop.dev guardrails block banned queries before they run or hold risky ones for review, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Can OpenID Connect and SAML apps share one SSO session?

Yes, both protocol types can live inside the same realm and share one login session. The identity server handles the protocol translation behind the scenes using the same browser cookie. Users log in once and move between both app types without a second prompt.

Should I use one realm or multiple realms for my apps?

Use one realm when the same user base needs single sign-on across a group of apps. Realms do not share login sessions with other realms by default. Create separate realms only when you need strict isolation between different user groups, like customers and staff.

How do I stop a user from opening every app in a realm?

Assign client-level roles instead of broad realm-level roles, and check those roles inside each app. You can also configure the login flow to block users who lack the required client role. That way, a valid realm session still stops unauthorized users at the app door.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.