Microservices
Updated On 03 September 2024 | Min(s) read

Enabling Authentication using JWT

This section helps you to enable the authentication for J2EE using JWT.

Marketing Catalog Microservice supports four stacks. They are Azure, AWS, and J2EE. AWS and Azure are authenticated by default whereas you need to enable authentication for J2EE.

To enable authentication for J2EE, you must configure and deploy the respective WAR files.

Configuration

Before deploying the WAR file, you must configure the WAR file of the required stack. To do so, you must perform the following tasks:

Prerequisites

Ensure that you meet the following prerequisites:

  • If you want to enable authentication for the J2EE stack, you must download the j2ee-iris WAR file named ms-marketingcatalog-j2ee-iris-DEV.0.0-SNAPSHOT.war and the J2EE package for must be up and running.

Generating JWT Token

JWT Token is usually generated and supplied by the other system which is consuming the endpoints published in the war. The public key in base 64 encoded format has to be configured in the war prior to the deployment.

You can generate JWT token using JWT site. A sample token generation is given below.

A sample screenshot (Debugger) from JWT site is given below.

Configuring JWT

This section helps you to configure JWT.

Procedure:

  1. Uncomment the following in Web.xml.
  2. Comment the NullBean and Uncomment T24SpringSecurityContextFilter as shown below in applicationContext.xml .
  3. Set the claims that required to be extracted from the jwt payload and token validation parameters in spring-jwt-iris-authenticator.xml.
    1. Set the value of principalClaim as sub, issuer from JWT Token payload (Fabric), and public key in base 64 format in pkEncoded.
    2. Set the list of claims to be extracted from JWT as shown below.

Deployment

After configuring the WAR file, you must deploy the configured WAR file on the J2EE Complaint Application Server. This section explains you about how to deploy the configured WAR file for the following stacks:

J2EE

Before deploying the authenticated WAR of J2EE, you must set up the following:

Procedure:

  1. Marketing Catalog j2ee iris war is generated under the target folder of the container project.

  2. Perform the JWT token configuration in the generated war.
  3. Deploy the generated war under the JBoss deployments folder.
    • For JBOSS, copy the artefact to the jboss/standalone/deployments folder.
    • For WebLogic, navigate to http://localhost:9001/console based on the URL configured while installing the server, and using the Install button, deploy the artefact.

  4. Once the Marketing Catalog Microservice is up and running in application server, check the API's in the package with a JWT token.

The format of API's URL is given below:

  • Base Path

    http://<IP_ADDRESS>:<PORT>/<context-root>/api/<version>/

    For Example: http://localhost:8095/ms-marketingcatalog-api/api/v1.0.0/

  • Resource path of the endpoint can be found in the APIs document. A sample endpoint of Marketing Catalog is http://localhost:8095/ms-marketingcatalog-api/api/v1.0.0/product/products.

Copyright © 2020- Temenos Headquarters SA

Published on :
Tuesday, September 2, 2025 1:10:24 PM IST