Skip to main content
AI
  • Get started with AI

    • Red Hat AI

      Accelerate the development and deployment of enterprise AI solutions.

    • AI learning hub

      Explore learning materials and tools, organized by task.

    • AI interactive demos

      Click through scenarios with Red Hat AI, including training LLMs and more.

    • AI/ML learning paths

      Expand your Red Hat OpenShift AI knowledge using these learning resources.

    • AI quickstarts

      Focused AI use cases designed for fast deployment on Red Hat AI platforms.

    • No-cost AI training

      Foundational Red Hat AI training.

  • Featured resources

    • Red Hat OpenShift AI
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

Red Hat AI Factory with NVIDIA

Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.

Learn
  • Self-guided

    • Documentation

      Find answers, get step-by-step guidance, and learn how to use Red Hat products.

    • Learning paths

      Explore curated walkthroughs for common development tasks.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • Hands-on

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

    • Interactive labs

      Learn by doing in these hands-on, browser-based experiences.

    • Interactive demos

      Click through product features in these guided tours.

  • Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics
  • Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
Build
  • Get started

    • Red Hat build of Podman Desktop

      A downloadable, local development hub to experiment with our products and builds.

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

  • Download products

    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products
  • Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset
  • References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
Community
  • Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions
  • Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github
  • Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

Join the Red Hat Developer program

Download Red Hat products and project builds, access support documentation, learning content, and more.

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

Event-driven ingestion of Keycloak entities

August 27, 2025
Kashish Mittal
Related topics:
Event-drivenNode.jsPlatform engineering
Related products:
Red Hat Developer HubRed Hat Plug-ins for Backstage

    You've probably experienced the annoyance of delayed updates to critical entity information, or witnessed the strain of constant, inefficient polling mechanisms chewing up resources just to keep data somewhat current. But what if your developer catalog could react instantly to changes in your identity provider? The Backstage Events System provides a solution to just that. This article will outline a Proof of Concept (PoC) for an event-driven ingestion mechanism, demonstrating how we can achieve near real-time synchronization of entities from Keycloak into Red Hat Developer Hub (RHDH), moving beyond the limitations of traditional polling.

    So, what's this "Events System" in Backstage all about? Think of it as an efficient messaging service. It can be used in a variety of use cases. For instance, it can be used by different plugins to communicate with each other and also by external services to interact with Backstage. In the context of this PoC, the Events System is specifically leveraged to facilitate the ingestion of entities from a Keycloak instance into the RHDH catalog.

    Benefits of event-driven

    There are benefits to going event-driven such as:

    • Near real-time updates

      Entities in the RHDH catalog are updated almost immediately after changes occur in the external system. This ensures developers always see the most accurate and current information, without the delays associated with interval-based polling.

    • Efficient, incremental syncing

      Rather than performing periodic full syncs, this event-driven approach updates only the affected entities that were actually changed, added, or deleted in the external system.

    This results in:

    • Fewer API calls, helping avoid rate limits.
    • Lower CPU usage, since there is no unnecessary processing.
    • Reduced database load because only specific records are modified.

    Setting up the PoC

    This section walks through setting up a PoC where the Backstage Keycloak plugin is modified to send user and group events to RHDH via webhooks. Since Keycloak does not natively support webhooks, we extend its functionality using the ext-event-webhook EventListener provided by p2-inc/keycloak-events. The following steps will guide you through building a custom Keycloak image, configuring realms and clients, enabling the event listener, and finally wiring it up with a locally running RHDH instance.

    You can take a look at the PoC code here: https://github.com/04kash/community-plugins/pull/9 

    Step 1 : Set up your Keycloak server

    Clone the p2-inc/keycloak-events repository:

    git clone https://github.com/p2-inc/keycloak-events
    cd keycloak-events

    Build the project:

    mvn clean install -DskipTests

    This will produce a JAR file located at target/keycloak-events-0.47-SNAPSHOT.jar, or a similarly named version based on your build.

    Create a Containerfile with the following content:

    FROM quay.io/keycloak/keycloak:26.2.4 (or use RHBK image: registry.redhat.io/rhbk/keycloak-rhel9:26.2) 
    COPY target/keycloak-events-*.jar /opt/keycloak/providers/

    Build the container image:

    podman build -t my-keycloak-with-events .

    Confirm the image is listed using the following command:

    podman images

    Start the Keycloak server by creating a podman network so that the Keycloak container and the RHDH container can communicate with each other.

    podman network create rhdhnet

    Run the Keycloak container using the image built in the previous step:

    podman run -p 8080:8080 --network rhdhnet \
      -e KC_BOOTSTRAP_ADMIN_USERNAME=admin \
      -e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \
      my-keycloak-with-events start-dev

    Next, disable SSL for development.

    Access the running container:

    podman exec -it <container-name> /bin/bash
    cd /opt/keycloak/bin

    Authenticate as the admin user:

    ./kcadm.sh config credentials --server http://localhost:8080 --realm master --user admin --password admin

    Disable SSL for development:

    ./kcadm.sh update realms/master -s sslRequired=NONE

    Create realm and client for webhooks as follows.

    In the Keycloak admin console:

    1. Create a new realm named demo-rhdh-events.
    2. Inside this realm, create a client named rhdh-events-webhook.
    3. Assign the following roles to the client's service account:
      • view-events
      • manage-events
      • query-groups
      • query-users
      • view-users

    Enable ext-event-webhook under Configure > Realm Settings > Events.

    Now we will generate an access token.

    NOTE: You might have to disable SSL for the demo-rhdh-events realm to proceed.

    Run the following:

    TOKEN=$(curl -X POST http://localhost:8080/realms/demo-rhdh-events/protocol/openid-connect/token \
      -H "Content-Type: application/x-www-form-urlencoded" \
      -d "client_id=rhdh-events-webhook" \
      -d "grant_type=client_credentials" \
      -d "client_secret=<secret>")
    ACCESS_TOKEN=$(echo $TOKEN | jq -r '.access_token')

    Replace <secret> with the actual secret from the Keycloak admin console.

    Create the webhook as follows:

    curl -X POST http://localhost:8080/realms/demo-rhdh-events/webhooks/ \
      -H "Authorization: Bearer $ACCESS_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
        "enabled": true,
        "url": "http://<rhdh-container-name>:7007/api/events/http/keycloak",
        "eventTypes": [
          "admin.GROUP-CREATE",
          "admin.GROUP-DELETE",
          "admin.USER-UPDATE",
          "admin.USER-CREATE",
          "admin.USER-DELETE",
          "admin.GROUP_MEMBERSHIP-CREATE",
          "admin.GROUP_MEMBERSHIP-DELETE"
        ]
      }'

    Verify the webhook by running the following:

    curl -X GET http://localhost:8080/realms/demo-rhdh-events/webhooks \
      -H "Authorization: Bearer $ACCESS_TOKEN"

    Step 2: Set up RHDH local

    1. Clone the 04kash/rhdh-local repository.
    git clone https://github.com/04kash/rhdh-local.git && cd rhdh-local
    1. Under configs/dynamic-plugins, create a new file dynamic-plugins.override.yaml and copy over the contents from dynamic-plugins.override.example.yaml into it.
    2. Under configs/app-config, create a file named app-config.local.yaml and copy the contents from app-config.local.example.yaml into it. In this new file, set the value of catalog.providers.keycloakOrg.default.clientSecret to your Keycloak client secret. Additionally, configure catalog.providers.keycloakOrg.default.baseUrl with the base URL of your Keycloak server, typically in the format http://<keycloak-container-name>:8080/.

    3. Run the following command to start RHDH local:

    podman-compose up -d
    1. Add the RHDH container to the rhdhnet network:
    podman network connect rhdhnet rhdh
    1. Rerun the install-dynamic-plugins container and restart the rhdh container
    podman-compose run install-dynamic-plugins
    podman-compose stop rhdh && podman-compose start rhdh

    Open http://localhost:7007 in your browser to access RHDH. You can now try creating or modifying users and groups in your Keycloak server. You should observe the corresponding entities added or updated in your RHDH catalog in real time.

    Limitations and future improvements

    There are a couple of other scenarios that can be added to this PoC:

    • Updates to the Keycloak group, such as renames or property changes. It can potentially be supported by adding a function to handle admin.GROUP-UPDATE events.
    • Adding users and groups to a Keycloak instance via partial imports. Adding users and groups using this method emits admin.REALM-CREATE, and this scenario can potentially be supported by adding a function to handle this event.

    In a real-world production setup, there may be edge cases where events fail to reach RHDH, due to:

    • Message delivery issues
    • Temporary network outages
    • Application crashes
    • Unexpected bugs or configuration errors

    To mitigate these risks, we recommend retaining periodic polling. This ensures that missed events don’t lead to catalog drift over time.

    Rather than treating event-driven ingestion as a complete replacement for polling, view it as a performance optimization that enables near-instant updates, while falling back to scheduled syncs to guarantee consistency.

    Related Posts

    • How to restrict user authentication in Keycloak during identity brokering

    • Keycloak Identity Brokering with OpenShift

    • A developer’s guide to Red Hat Developer Hub and Janus

    • Red Hat Developer Hub: Your gateway to seamless development

    Recent Posts

    • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

    • Control multicluster costs with right-sizing in Red Hat Advanced Cluster Management 5

    • Lightbits is now certified for Red Hat OpenStack Services on OpenShift

    • What's new in Red Hat OpenShift 5 for developers

    • On-demand screen context in Red Hat Developer Hub intelligent assistant

    What’s up next?

    Writing “Hello, World” hasn’t gotten any harder—but running it has. Download our developer’s guide to developer portals to learn how engineering teams can reduce friction and boost productivity using internal developer portals (IDPs).

    Get the e-book
    Red Hat Developers logo

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    Red Hat Developer

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility
    Ask AI