sakshi-choudhary / kong-gateway-jwt-plugin

A simple Kong Gateway JWT plugin using javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

kong

Kong Gateway JWT Plugin

The Kong Gateway JWT plugin is an API gateway authentication strategy. The plugin serves as the JWT authorizer. It authenticates the JWT in the HTTP request by verifying that token’s claims and ensuring a trusted party signed it. Then, depending on whether these steps were successful, Kong Gateway routes the upstream service request.

🔧 Configuration

  • Create a kong.conf.default file in the root dir

  • Paste these lines inside the file (This is because its DB-less mode)

    database = off
    declarative_config = /path/to/kong.yml
    
  • Run this cmd in the terminal

    sudo cp kong.conf.default /etc/kong/kong.conf
    
  • Set your username and secret code in kong.yml file.

💻 Run the Kong Server

sudo kong start

To restart

sudo kong restart

📺 Working Previews

Screenshot 2021-12-18 at 10 20 46 PM

Screenshot 2021-12-18 at 10 20 54 PM

GET request to the admin API’s endpoint /consumers/CONSUMER-USERNAME/jwt. This gives info about this consumer’s JWT credential:

Screenshot 2021-12-18 at 10 21 56 PM

Using these values and generated jwt

Screenshot 2021-12-18 at 10 25 48 PM

Using this generate jwt in bearer token, jwt validated

Screenshot 2021-12-18 at 10 26 13 PM

Additional values to upstream headers in the console

Screenshot 2021-12-18 at 10 31 06 PM

Errors when secret code and kid are wrong and exp time is in the past:

Screenshot 2021-12-18 at 10 30 40 PM

Screenshot 2021-12-18 at 10 32 14 PM

Screenshot 2021-12-18 at 10 34 22 PM

rendered with by Sakshi Choudhary.

About

A simple Kong Gateway JWT plugin using javascript

License:MIT License


Languages

Language:JavaScript 100.0%