Skip to main content
Redhat Developers  Logo
  • 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 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

    • OpenShift AI learning
    • 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.
    • Explore the solution
  • 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

    • Access product downloads to start building and testing right away.
    • 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.
    • Explore the benefits

Enabling LDAP Security for DataGrid Cache

April 13, 2017
Kamesh Sampath
Related topics:
JavaSecurity
Related products:
Red Hat Data Grid

    Expanding on Tristan's blog, where he spoke of enabling security for JBoss Data Grid caches, in this post we will cover how to add LDAP based security to the JDG caches. The principles and techniques remain defined by Tristan, but there are some minor changes that I will be highlighting in this blog for a successful working configuration of JDG enabled with LDAP security.

    Before we jump on to configuring the JDG for security, I would like to brush up on the available permissions in JDG:

    • READ - typical read operations get, contains etc., except bulk read
    • WRITE - typical write operations put, putIfAbsent, replace, remove, evict
    • EXEC - distexec, mapreduce
    • LISTEN - permissions to add Listeners
    • BULK_READ - keySet, values, query, entrySet etc.,
    • BULK_WRITE - clear, putAll
    • ALL_READ - all read operations typically READ + BULK_READ
    • ALL_WRITE - all write operations typically WRITE + BULK_WRITE
    • LIFECYCLE - start/stop of caches
    • ADMIN - typical cache administration operations like getVersion, getCacheConfiguration etc.,
    • ALL -  All the permissions listed above

    More information on these is available in the JDG Developer Guide.

    Setup

    LDAP

    The complete source code of examples used in this blog is available on Github, here. If you don't have an LDAP server running on your machine and wish to quickly run one, you can do so by pulling a docker image of the same by pulling docker image fabric8/389ds, to run a 389ds-Directory Server with sample users and groups as shown in LDIF, run the following command,

    docker run -d --name "dirsrv-389ds" -p 10389:389 fabric8/389ds -e "DIRSRV_ADMIN_USERNAME=admin,DIRSRV_ADMIN_PASSWORD=admin@123, DIRSRV_MANAGER_PASSWORD=admin@123, DIRSRV_SUFFIX=dc=example,dc=com"

    Groups and Permissions

    The following section shows the Groups and Roles mapping, refer to JDG Security Permissions for more information on each of the permissions mentioned below:

    • ClusterAdmins - the user(s) belonging to this group can do ALL operations on JDG cache(s)
    • Managers - the users(s) belonging to this group can do ALL_READ,ALL_WRITE,EXEC on JDG cache(s)
    • Developers - the user(s) belonging to this group can only WRITE on JDG cache(s)
    • Business - the user(s) belonging to this group can only READ on JDG cache(s)

    If you are running the dockerized version of the 389ds then all the required groups mentioned above with sample users are all set up, if you are using your own LDAP server then you'll import the LDIF to have them created for you.

    Configuring JDG

    We leverage the jboss-cli for setting up the LDAP security and configuring the authentication and authorization JDG. The source repo's jboss-cli folder has the following JBOSS CLI commands file, which can help in setting up the LDAP Security and JDG Cache security.

    Assumptions

    • JDG Server is up and running with "clustered.xml" as configuration and its management port is on 9990, if you don't have JDG running you can download it from here, unzip it to a folder of your choice and then start it with the command,
      $JBOSS_HOME/bin/standalone.sh -c clustered.xml
    • Export JBOSS_HOME environment variable to point to JDG Home, this not a must but a convenience to run the JBOSS CLI commands.

    Before getting started, clone the repository https://github.com/kameshsampath/jdg.git to a folder of your choice, let's call it as $PROJECT_HOME and then change to directory jdg-security-demo under $PROJECT_HOME, unless explicitly stated, all the commands in the following sections will be executed from $PROJECT_HOME/jdg-security-demo directory.

    JDG LDAP Security Configuration

    • To configure LDAP security, run the following command,
    $JBOSS_HOME/bin/cli.sh --controller=127.0.0.1:9990 --connect --file=./jboss-cli/ldap-enable.cli

    NOTE: You might need to check the ./jboss-cli/ldap-enable.cli for ports, LDAP credentials etc., corresponding to your LDAP server before running the above command.

    • After running the above command the server restart, wait for the server to restart completely.
    • Now execute,
    $JBOSS_HOME/bin/cli.sh --controller=127.0.0.1:9990 --connect

    It will prompt you for a username and password, you can use any of the usernames from LDAP with this demo, the application is not configured for authorization or management. If you have imported the LDIF then you can use admin/password to log into the JBoss CLI, if you are successfully logged in then LDAP security is configured correctly. Going forward every subsequent connection via JBoss CLI will prompt for the username and password.

    JDG Cache Security Configuration

    • To configure JDG security do run the following command,
    $JBOSS_HOME/bin/cli.sh --controller=127.0.0.1:9990 --connect --file=./jboss-cli/jdg-security-enable.cli
    • The command will add security to the JDG cache container "clustered" with roles and permissions mentioned above, the command will also secure the HotRod connector, hence making the clients pass credentials to do operations on the cache.

    Example JDG Cache Configuration

    To run the test let's create a sample cache and its configuration, which we secured using the LDAP and authorization previously defined. To create sample cache and configuration run the following command,

    $JBOSS_HOME/bin/cli.sh --controller=127.0.0.1:9990 --connect --file=./jboss-cli/cache-security-config.cli

    The command above creates a distributed cache configuration called "securedConfig" and creates distributed cache called "users-cache" which will use the "securedConfig".

    Testing the Secured Cache

    To test the secured cache from the project root run the following command,

    mvn clean test

    The project has only one test case called org.workspace7.jdg.JDGSecurityTest, which runs a simple test to check all the roles mentioned above.

    Couple of points to note in the setup, the "cache-container" security authentication will still use "identity-role-mapper" instead of "common-name-role-mapper", this is a workaround for now until the JDG-951 is fixed, to enable this workaround, map correct role names, the LDAP security authorization should be configured to return SIMPLE names for the roles like shown below,

    group-search group-name="SIMPLE" iterative="true" group-dn-attribute="dn" group-name-attribute="cn"
    group-to-principal search-by="DISTINGUISHED_NAME" base-dn="ou=Groups,dc=example,dc=com"
    membership-filter principal-attribute="uniqueMember"/
    /group-to-principal
    /group-search

    Ideally, you don't need to do these updates, as the jboss-cli's that were executed earlier takes care of this workaround. Please refer to the JDG Developer guide for more information on mappers that are available.

    That's it! You are all set to rock with JDG enabled with LDAP Authentication/Authorization; you can check the complete clustered.xml sample here.


    Click here to download JBoss Data Grid an intelligent, distributed caching solution that boosts application performance and provides greater deployment flexibility.

    Last updated: March 21, 2023

    Recent Posts

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    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

    Chat Support

    Please log in with your Red Hat account to access chat support.