Skip to content

hakdogan/quarkus-dpop-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quarkus DPoP Example

A companion project for the article DPoP: What It Is, How It Works, and Why Bearer Tokens Aren't Enough. It demonstrates how to secure a Quarkus REST API with DPoP (Demonstration of Proof-of-Possession) as defined in RFC 9449.

What it covers

  • DPoP-bound token validation via Quarkus OIDC (quarkus.oidc.token.authorization-scheme=dpop)
  • jti replay protection with a custom @ServerRequestFilter
  • A k6 test script that exercises happy-path, replay attack, method mismatch, and URL mismatch scenarios

Requirements

  • Java 21+
  • Maven 3.9+
  • Docker and Docker Compose
  • k6 (for running tests)

Getting started

1. Start Keycloak

The included compose.yml starts PostgreSQL and Keycloak 26.5.5 with a pre-configured realm (dpop-demo client and hakdogan test user).

docker compose up -d

Wait until Keycloak is healthy:

docker compose ps

Keycloak will be available at http://localhost:8080. Admin credentials: admin / admin.

2. Start the Quarkus application

./mvnw quarkus:dev

The application starts on port 8180.

3. Run the k6 tests

k6 run k6/dpop-test.js

The script runs 6 scenarios against the Quarkus API and prints the status and response body for each:

# Scenario Expected
1 GET /user-info (Happy Path) 200
2 POST /user-info 200
3 POST /list-users 200
4 Replay Attack (jti reuse) 401
5 Method Mismatch (htm) 401
6 URL Mismatch (htu) 401

All configuration values (Keycloak URL, client ID, credentials) can be overridden via environment variables:

k6 run -e KEYCLOAK_URL=http://keycloak:8080 -e CLIENT_ID=my-client -e USERNAME=user1 -e PASSWORD=secret k6/dpop-test.js

Project structure

├── compose.yml                          # Keycloak + PostgreSQL
├── keycloak/
│   └── master-realm.json                # Pre-configured realm export
├── k6/
│   └── dpop-test.js                     # k6 test script
└── src/main/java/org/jugistanbul/
    ├── resource/
    │   └── ProtectedResource.java       # REST endpoints (GET/POST /user-info, POST /list-users)
    └── filter/
        └── DpopJtiFilter.java           # jti replay protection filter

About

A Quarkus application demonstrating DPoP (RFC 9449) token binding with Keycloak, including jti replay protection and k6 test scenarios

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors