CasdoorMarketplace

Kong Gateway · App integration

Protect the services behind Kong with Casdoor

The Casdoor plugin for Kong Gateway 3.x signs browsers in through Casdoor with the authorization code flow and PKCE, checks the Casdoor tokens of API calls against the JWKS, and passes the user to the upstream in X-Casdoor-User, X-Casdoor-Email and X-Casdoor-Organization headers. It runs only with a Casdoor that has a commercial edition license.

Verified by CasdoorCommercial editionOIDCPKCEAPI gatewayJWT
You need a running Casdoor, self-hosted or on Casdoor Cloud. In the examples, replace https://auth.example.com with your Casdoor address (on Casdoor Cloud, something like https://acme.casdoor.com) and the other example.com addresses with your own.

Set up Kong Gateway with Casdoor

  1. 1

    Register Kong Gateway in Casdoor

    In the Casdoor console, open Applications, add an application for Kong Gateway, and on its OIDC/OAuth tab copy the Client ID and Client secret. Add these redirect URLs to Redirect URLs:

    • https://app.example.com/casdoor/callback
    • https://app.example.com/
  2. 2

    Install from the Marketplace

    On the Marketplace page of Casdoor, install Kong Gateway with the address of the protected site. Casdoor creates the application with the callback /casdoor/callback and the logout landing page as redirect URLs. Then download kong-plugin-casdoor-0.1.0.zip from the same dialog.

  3. 3

    Install the plugin on Kong

    Unzip it on every Kong node, install it with LuaRocks and add casdoor to the plugins Kong loads.

    cd kong-plugin-casdoor
    luarocks make kong-plugin-casdoor-0.1.0-1.rockspec
    export KONG_PLUGINS=bundled,casdoor
    kong restart
  4. 4

    Enable it on a service

    Enable the plugin with the application's client ID and secret.

    curl -X POST http://localhost:8001/services/<service>/plugins \n  --data name=casdoor \n  --data config.casdoor_endpoint=https://door.casdoor.com \n  --data config.client_id=<client id> \n  --data config.client_secret=<client secret> \n  --data config.cookie_secret=<at least 32 random characters>
  5. 5

    Try it

    Open the protected site in a private window: it sends you to Casdoor, and after sign-in back to the page. /casdoor/logout signs you out.

Good to know

  • The plugin asks Casdoor for its license every 10 minutes and answers 403 when Casdoor runs as the Community edition.

Kong Gateway settings are from its documentation as of November 2026 (Kong: Custom plugins). Kong Gateway is a trademark of its owner.