Skip to content

cuioss/nifi-extensions

NiFi Extensions — JWT Authentication and REST API Gateway

Java CI with Maven End-to-End Tests Integration Tests

Apache NiFi Java 21 License Maven Central

Quality Gate Status Lines of Code Coverage

What is it?

A self-contained REST API gateway for Apache NiFi. The RestApiGatewayProcessor embeds a Jetty HTTP server with route-based dispatching, per-route JWT authorization, and RFC 9457 error responses, replacing multi-processor gateway patterns with a single node.

The project also includes a MultiIssuerJWTTokenAuthenticator for FlowFile-based JWT validation (see MultiIssuerJWTTokenAuthenticator Guide). Both processors share JWT validation through a common JwtIssuerConfigService Controller Service supporting multiple identity providers (Keycloak, Entra ID, Auth0) with automatic JWKS key rotation and caching.

The Problem

Building a REST API gateway in NiFi manually requires chaining HandleHttpRequest + custom validation + HandleHttpResponse with complex error routing. Adding JWT authentication on top means even more processors, relationships, and configuration, all for what should be a single concern.

The Solution

The RestApiGatewayProcessor is a single processor that embeds an HTTP server, authenticates and authorizes requests per-route, and converts them into FlowFiles.

RestApiGateway Pattern

Key capabilities:

  • Route-based dispatching: define routes via dynamic properties, each with its own HTTP methods and path patterns

  • Per-route JWT authorization: require specific roles for individual routes

  • RFC 9457 error responses: standardized problem details for authentication and authorization failures

  • Management endpoints: /metrics (Prometheus-compatible) and /health

Request Tracking

Routes can enable async request tracking for POST/PUT/PATCH requests. Both modes require a DistributedMapCacheClient Controller Service.

Request Tracking Modes
  • Simple (tracking-mode=simple): 202 with traceId and /status polling link

  • Attachments (tracking-mode=attachments): adds an /attachments/{traceId} upload endpoint; the parent request waits for attachments (or timeout), then the window closes (409). See Attachment Merge Guide.

Installation

You need two NAR files (NiFi Archives):

  • nifi-cuioss-api-nar: Controller Service API interfaces (required by NiFi 2.x classloader separation)

  • nifi-cuioss-nar: Processors, Controller Service implementation, configuration UI, and all dependencies

NiFi 2.x requires that Controller Service API interfaces reside in a separate NAR from their implementations. Both NARs must be deployed together.

From a Release

  1. Download both nifi-cuioss-api-nar-<version>.nar and nifi-cuioss-nar-<version>.nar from GitHub Releases or Maven Central.

  2. Copy both NARs into your NiFi extensions directory:

    cp nifi-cuioss-api-nar-*.nar nifi-cuioss-nar-*.nar $NIFI_HOME/extensions/
  3. Restart NiFi (or wait for NiFi’s auto-detection if configured).

  4. The processors MultiIssuerJWTTokenAuthenticator and RestApiGatewayProcessor appear in the "Add Processor" dialog under the tags jwt and authentication.

Configuration

Both processors can be configured through three methods (highest precedence first):

  1. NiFi UI: interactive configuration with built-in JWKS validation and token testing

  2. Environment variables: for container orchestration (Kubernetes, Docker)

  3. Static configuration files: for automated / container deployments

See the Quick Start Guide for a step-by-step walkthrough covering processor properties, issuer configuration, routes, relationships, and the custom UI. For static configuration files and environment variables, see the Configuration Reference.

Sandbox

A local sandbox spins up NiFi and Keycloak in Docker so you can explore both processors with a real identity provider.

./integration-testing/src/main/docker/run-and-deploy.sh

The script builds the NAR, copies it into the deployment directory, and starts the containers. NiFi takes about 60-80 seconds to become healthy.

Service URL Credentials

NiFi

https://localhost:9095/nifi

testUser / drowssap

Keycloak

https://localhost:9085

admin / admin

After code changes, redeploy NiFi without restarting Keycloak:

./integration-testing/src/main/docker/redeploy-nifi.sh

Stop the sandbox:

cd integration-testing/src/main/docker && docker compose down -v

The sandbox includes a pre-configured NiFi flow (flow.json) with a RestApiGatewayProcessor on port 9443 featuring multi-route JWT authorization via Keycloak, RFC 9457 error responses, and a /metrics management endpoint. The flow also contains a MultiIssuerJWTTokenAuthenticator-based endpoint on port 7777 (see MultiIssuerJWTTokenAuthenticator Guide).

Components

Module Purpose

nifi-cuioss-api

Controller Service API types (JwtIssuerConfigService interface, JwtAuthenticationConfig record)

nifi-cuioss-api-nar

NiFi Archive (NAR) for the API: required by NiFi 2.x classloader separation

nifi-cuioss-common

Shared JWT infrastructure: Controller Service implementation, configuration, utilities

nifi-cuioss-processors

MultiIssuerJWTTokenAuthenticator: FlowFile-based JWT validation processor

nifi-cuioss-rest-processors

RestApiGatewayProcessor: REST API gateway with embedded Jetty, route-based dispatching, RFC 9457 errors

nifi-cuioss-ui

Unified Custom UI serving both processors: issuer configuration, token verification, endpoint configuration, metrics

nifi-cuioss-nar

NiFi Archive (NAR): the main deployable artifact bundling processors + UI

integration-testing

Docker-based test environment (NiFi + Keycloak)

e-2-e-playwright

Playwright E2E and WCAG accessibility tests

Documentation

Architecture

Guides

Reference

Testing

Building

See the Building Guide for build commands, code quality checks, SonarQube analysis, and integration/E2E test instructions.

About

Some extensions for apache nifi

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Contributors