The Simplest Way to Make Keycloak and Pulsar Work Like They Should
Teams use keycloak and pulsar together to control who can send and read messages. Keycloak checks user identity, and Pulsar moves data streams between apps. This pairing lets you manage all user rules in one place. Apps and engineers log in through Keycloak before they touch any Pulsar topic. You do not need to make local keys inside each messaging cluster. Instead, you use standard tokens that expire on a set clock. How identity and data flow in keycloak and pulsar Keycloak acts as the sing
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.
Teams use keycloak and pulsar together to control who can send and read messages. Keycloak checks user identity, and Pulsar moves data streams between apps.
This pairing lets you manage all user rules in one place. Apps and engineers log in through Keycloak before they touch any Pulsar topic. You do not need to make local keys inside each messaging cluster. Instead, you use standard tokens that expire on a set clock.
How identity and data flow in keycloak and pulsar
Keycloak acts as the single source of truth for user identity. A client app asks Keycloak for a signed JSON Web Token. Keycloak checks the app credentials and returns a token with user roles. The client app then sends this token to the Pulsar server.
Pulsar reads the token and checks the digital signature against Keycloak public keys. If the signature matches, Pulsar reads the subject claim from the token. Pulsar then checks its own role rules to allow or block the request. One role might allow writing messages to a specific namespace. Another role might only allow reading messages from a single topic.
This setup keeps secret passwords out of your message system config files. When a worker leaves the team, you block their user account in Keycloak. Once their active token expires, Pulsar blocks their next request right away. You also get a clear view of which user owns each client session.
Common failure modes and how to scope roles
Many teams fail by sharing one admin token across multiple apps. If that single token leaks, an attacker can read every message stream. Shared tokens also ruin your audit logs. You cannot tell which app or engineer wrote bad data to a topic.
Long token lifetimes create another big risk for your data streams. If a token stays valid for months, revoking a user in Keycloak does nothing. The user can keep reading topics until the token clock runs out. Set your token life to minutes, and let client apps refresh tokens often.
Keycloak + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Broad permissions also cause trouble when teams scale up their clusters. Engineers often grant cluster-wide write rights just to fix a broken test script. Those broad rights then stay active in production for years. Instead, map each Keycloak client ID to one specific Pulsar namespace. Give apps write rights on input topics and read rights on output topics.
Network paths between the two systems need tight firewall rules too. Your Pulsar servers must reach Keycloak to fetch public signing keys. If a firewall blocks that route, valid client logins will fail right away. Keep both systems on a private network so public traffic cannot reach them.
Keeping admin work and sensitive payloads safe
Human engineers also need to run admin checks on topics and queues. Giving every engineer permanent superuser rights in Keycloak invites mistakes. One wrong command can delete an active topic or drop unread messages. Give engineers read-only roles for daily checks, and limit admin roles to emergencies.
Message payloads often hold private user data like emails, phone numbers, and card numbers. Even with tight role rules, someone might read a raw message during a debug session. Data masking rewrites matched fields in results so sensitive strings stay safe during checks. Combined with strict audit logs, this keeps your event streams clean and verifiable.
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
How does Pulsar check tokens from Keycloak?
Pulsar uses the OpenID Connect standard or public keys to check the token signature. It also checks that the token has not expired before allowing topic actions.
How do you revoke a compromised Pulsar client token?
Disable the client or user account inside Keycloak right away. Keep token lifetimes short so the active token expires within a few minutes.
Should microservices share one Keycloak client for Pulsar?
No, give each service its own client ID in Keycloak. This limits blast radius if a secret leaks and keeps audit logs clear.
Related guides
In this post