Keycloak Webhooks

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up keycloak webhooks by adding an event listener plugin to your server. This plugin watches user logins or admin changes and sends alerts to an outside URL. Teams often use these hooks to sync user accounts or log login events. Still, identity events only track when a user logs in or changes a role. If that role has broad permissions, the user can still run dangerous database commands. How keycloak webhooks work in your stack The identity server does not include a built-in webhook too

Keycloak + K8s Validating Admission Webhooks: 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 webhooks by adding an event listener plugin to your server. This plugin watches user logins or admin changes and sends alerts to an outside URL. Teams often use these hooks to sync user accounts or log login events. Still, identity events only track when a user logs in or changes a role. If that role has broad permissions, the user can still run dangerous database commands.

How keycloak webhooks work in your stack

The identity server does not include a built-in webhook tool out of the box. Instead, it offers an internal event system that tracks user and admin actions. User events include logins, password resets, and token refreshes across a given realm. Admin events cover changes to roles, groups, and client settings made by staff.

To send these events out, you must load a custom provider extension. You place the plugin package into the server directory and turn it on. Once active, the listener catches internal events as they happen in real time. It packs the event details into a JSON message and sends an HTTP request. Your target app receives this payload and runs its own logic or updates.

You should filter which events the plugin sends to your external apps. Sending every token refresh creates heavy traffic and slows down your receiving server. Most teams pick only login failures, new accounts, and role updates for export. You also need a shared secret so the receiving app can check each request. This check stops outside attackers from sending fake identity events to your webhook URL.

Why event payloads need retry and queue controls

Direct HTTP calls from an identity server can cause delays during peak login hours. If the target endpoint is slow, the identity server may wait for a reply. This wait can slow down the login flow for your users and apps. Teams often add a message queue between the event plugin and the target app. The plugin drops the event into the queue and moves on right away.

Network drops can also cause lost events if your plugin lacks retry logic. When a role update fails to reach a downstream app, permissions fall out of sync. A good extension retries failed sends with a short delay between each try. It also logs dead messages so engineers can fix broken sync jobs later.

Keycloak + K8s Validating Admission Webhooks: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What identity events solve and what they miss

Event hooks are great for keeping user lists in sync across many tools. They also help security teams spot strange login attempts or sudden admin role changes. When someone adds a user to an admin group, your chat app gets an alert. You can also trigger an automated job to revoke sessions when an employee leaves.

Still, a login event only tells you who entered the system and when. It tells you nothing about what that user does inside a database or server. Once a developer logs in with a broad role, the identity server steps back. It cannot see the SQL queries or shell commands that run during that session.

It also cannot mask sensitive fields like emails, phone numbers, or card numbers in results. To control live traffic, you need controls that inspect every query and command in flight. Relying only on login webhooks leaves a big gap after the session starts.

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 runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Does the identity server support webhooks natively?

No, the core server does not ship with a built-in HTTP webhook sender. You must install an open-source extension or write a custom event listener plugin.

What is the difference between user events and admin events?

User events track actions like logins, logouts, and password updates by regular users. Admin events track changes to realm rules, client apps, and user roles.

Can event webhooks block a dangerous database query?

No, webhooks only fire when an identity or login event happens on the server. They cannot inspect or stop SQL queries or terminal commands during a live session.

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.