Skip to content

bigglesandginger/haproxy-api-monetization-demo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HAProxy API Monetization Demo

This project demonstrates how to use HAProxy with Keycloak to restrict access to the API servers to only clients that present a valid OAuth 2 access token. Each token includes a scope field that's set to bronze, silver, or gold. You could charge clients a fee to access the API at the various subscription levels.

HAProxy enforces rate limits:

  • bronze = up to 10 request/minute
  • Silver = up to 100 requests/minute
  • Gold = up to 1000 requests/minute

Setup

Add to your /etc/hosts :

127.0.0.1 keycloak

To set up the demo project, initialize it with Docker Compose:

sudo docker-compose build
sudo docker-compose up -d

The application listens on localhost and keycloak. Go to http://keycloak/ to set up clients in Keycloak. Keycloak issues access tokens, which HAProxy validates.

About

To use latest keycloak (18.0.0)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 73.7%
  • Dockerfile 26.3%