Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Secure JBoss EAP apps with Microsoft Entra ID & OpenID Connect

April 1, 2024
Philip Hayes
Related topics:
JavaSecurity
Related products:
Red Hat JBoss Enterprise Application Platform

Share:

    The recent release of Red Hat JBoss EAP 8.0 includes native support for OpenID Connect (OIDC) via the elytron-oidc-client subsystem. OIDC is an identity layer that enables clients, such as JBoss EAP, to verify a user’s identity based on authentication performed by an OpenID provider. For example, you can secure your JBoss EAP applications using the Red Hat build of Keycloak as the OpenID provider.

    In this article, we will use the elytron-oidc-subsystem to secure a simple web application using Microsoft Entra ID (formerly Azure Active Directory) as the OpenID provider.

    For more information about JBoss EAP 8.0's native OpenID Connect support, refer to the product documentation.

    Prerequisites

    • A local installation of JBoss EAP 8.0. Download the installation manager from Red Hat Developer.
    • JBOSS_HOME environment variable set as the installation folder for JBoss EAP 8.0.
    • A Microsoft Azure account with an active subscription.

    Connect a web application to Microsoft Entra ID

    1. Check out the sample application here.

    2. Create a file src/main/webapp/WEB-INF/oidc.json with the following contents:

      {
          "client-id" : "<<from azure>",
          "provider-url" : "<<from azure>",
          "ssl-required" : "EXTERNAL",
          "credentials" : {
              "secret" : "<<from azure>>"
           }
      }
    3. In the Azure portal, go to the All Services page and click Microsoft Entra ID.

    4. In the left-hand menu, select App registrations and click New Registration. You will see the Register an application page shown in Figure 1.

      Register a new application
      Figure 1: Register a new application
      Figure 1: Register a new application.
    5. Enter a name (e.g., jboss) and click the Register button. This brings you to the App registrations overview page for your application.

    6. Click Add a Redirect URL, then click Add a Platform.

    7. Select Web; you will see the Configure Web page, as shown in Figure 2.

      Configure a web application
      Figure 2: Configure a web application
      Figure 2: Configure a web application.
    8. Enter the following URL:

      http://localhost:8080/simple-webapp-oidc/secured
    9. Click the Configure button.

    10. Go back to the Overview page and click Add a certificate or secret.

    11. Select + New Client secret. This brings you to the Add a client secret page (Figure 3).

      Create a new secret
      Figure 3: Create a new secret
      Figure 3: Create a new secret.
    12. Enter a description (e.g., EAP) and click the Add button.

    13. Copy the value shown on the next page and paste this value into src/main/webapp/WEB-INF/oidc.json as the secret value.

    14. Return to the Overview page and click on Endpoints.

    15. Copy the value from OpenID Connect metadata document and paste it into src/main/webapp/WEB-INF/oidc.json as the provider-url. Be sure to remove the text /.well-known/openid-configuration.

    16. Return to the Overview page. Copy the Application (client) ID and paste this value in src/main/webapp/WEB-INF/oidc.json as the client-id.

    17. Save the changes to the oidc.json file.

    Our connection to Microsoft Entra ID is now configured, and we can deploy our application to JBoss EAP 8.0 and test the authentication.

    Test the Azure authentication

    1. First, we're going to start our JBoss EAP 8.0 instance. Run the following command to start JBoss EAP 8.0:

      $JBOSS_HOME/bin/standalone.sh 
    2. We can now deploy our app. From the folder containing the sample application source code, enter:

      mvn wildfly:deploy 
    3. We can access our application using http://localhost:8080/simple-webapp-oidc/.

      Click Access Secured Servlet. Now you'll be redirected to the Azure login page (Figure 4). Log in with your Azure credentials.

      Azure login page
      Figure 4: Azure login page
      Figure 4: Azure login page.
    4. Next, you'll be redirected back to our application and you should see the Secured Servlet page:

      Secured Servlet
      Current Principal 'xxxx'

    We were able to successfully log in to our application via the Microsoft Entra ID provider!

    Summary

    With JBoss EAP 8.0, OpenID Connect support is provided by the included elytron-oidc-subsytem. In this article, we demonstrated how to secure a simple JBoss EAP 8.0 web application with Azure authentication via Open ID Connect.

    For further information on JBoss EAP 8.0 OpenID support, refer to the documentation.

    Related Posts

    • How JBoss EAP 8.0 makes deployment on OpenShift easier

    • How to deploy JBoss EAP on an Azure virtual machine

    • How to use JBoss EAP 8.0's new provisioning system

    • How to easily deploy JBoss EAP on Azure

    • How to migrate apps from JBoss EAP 7.x to JBoss EAP 8.0

    • How to easily deploy JBoss EAP on Azure

    Recent Posts

    • How to run a fraud detection AI model on RHEL CVMs

    • How we use software provenance at Red Hat

    • Alternatives to creating bootc images from scratch

    • How to update OpenStack Services on OpenShift

    • How to integrate vLLM inference into your macOS and iOS apps

    What’s up next?

    Want to do more with Java? Explore this free learning path, where you'll learn how to deploy applications to middleware with the IntelliJ IDE extension.

    Start the learning path
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    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

    Red Hat legal and privacy links

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

    Report a website issue