The Simplest Way to Make Keycloak and SAML Work Like They Should
Running keycloak and saml together lets one login server check users for your apps. Your team logs in once and gets the right roles across every tool. Many older business apps still need XML messages to sign users in. Modern web apps often prefer newer JSON tokens instead. You do not need two separate login servers for these different apps. One open source server can translate user profiles into both formats with ease. This guide shows how the two systems pass user data and roles. How keycloa
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Running keycloak and saml together lets one login server check users for your apps. Your team logs in once and gets the right roles across every tool.
Many older business apps still need XML messages to sign users in. Modern web apps often prefer newer JSON tokens instead. You do not need two separate login servers for these different apps. One open source server can translate user profiles into both formats with ease. This guide shows how the two systems pass user data and roles.
How keycloak and saml pass user logins and roles
The login flow starts when a user opens a protected business app. That app acts as the service provider during the login check. It sees that the user does not have an active session yet. So the app sends the user over to your central login server.
Your login server acts as the identity provider for the whole team. It asks the user for their password and a second login code. Once the user passes that check, the server builds an XML message. This message is called an assertion, and it holds the user identity.
The server signs this XML message with a private key for safety. Then it sends the signed message back through the user browser. The business app checks the digital signature using a matching public certificate. If the signature matches, the app trusts the message and logs the user in.
You can also send group names and job roles inside this XML message. Mappers on the login server read user groups from your main directory. They write those group names into attributes inside the XML assertion. The receiving app reads those attributes and grants the right user permissions.
Common failure modes and how to scope roles
A common failure happens when signing certificates expire without any warning. When a certificate expires, the business app rejects every new XML login message. Teams often fix this in a rush by turning off signature checks. That mistake lets attackers forge login messages and take over user accounts.
Keycloak + Protocol Translation (SAML to OIDC): architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Another risk comes from sending too many group roles in one message. If a user belongs to fifty groups, the XML message grows huge. Worse, broad group mappings often give users admin rights they do not need. Shared admin accounts also hide who ran a change inside the app.
Clock drift between servers is another frequent cause of login errors. Each XML message has a short time window when it is valid. If the two server clocks differ by minutes, the app blocks the login. Keep both servers synced to the same network time server every day.
To keep roles tight, build specific mappers for each connected business app. Only send the exact group names that the target app needs to read. Map those groups to read-only roles by default for most team members. Require a separate approval step before anyone gets write or admin roles.
Keeping audit logs and user data safe
Centralizing logins gives you one place to check user sign-in events. Still, the XML assertion only covers the first door into an app. Once inside a database tool or admin panel, user actions can go unlogged. Security teams need to see what queries or commands run after login.
You also need to protect sensitive user fields during daily work. Masking rewrites matched fields like emails, phone numbers, card numbers, or national IDs in results. Combining strict role mappings with query logging keeps your data safe during audits.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
What is the difference between an identity provider and a service provider?
The identity provider checks the user password and creates the signed XML message. The service provider is the business app that reads that message to grant access.
Why do XML login messages fail when server clocks do not match?
Each login message includes a strict start and end time to stop replay attacks. If a server clock is off, the app thinks the message is expired.
Can one login server handle both XML assertions and modern JSON tokens?
Yes, you can set up clients for both protocols inside the same realm. A user logs in once and can open both older and newer apps.
Related guides
In this post