Skip to content

Kelon and services

To integrate Kelon with your service you basically have to add middleware-code to your service which intercepts calls and sends them to Kelon for authorization

Writing your own request interceptor

The core thing that each interceptor for Kelon needs to do is to gather all information about the incoming request and send it via a HTTP-POST to kelon for authorization (no mather which framework or programming language you want to use)

A possible call to Kelon for an incoming GET /api/apps/1 might look like this:

POST http://{Path to kelon}:{Port of kelon}/v1/data/allow

{
    "input": {
        "method": "GET",
        "path": "/api/apps/1",
        "token": "<JWT-Token from request header>"
    }
}

Please note that the only required fields inside the input object are method and path! All other fields can be added as you like and are available inside your policies by accessing them with i.e. data.input.token.

Kelon's response to this requests can be one of following:

Commuicate via Content

Without any addidional flag Kelon sends a response with code 201 and a JSON body with following format:

{
    "Result": true/false
}

In case of any malformed input or a missing mapping for the sent path, Kelon responds with a status code other than 201.

Commuicate via Status Code

When you configure Kelon with the flag --respond-with-status-code it sends communicates the final decision via status codes (201/503 / Allow/Forbidden).

Already existing interceptors for frameworks

Due to the fact that Kelon is compatible with OPA's Data-API, every solution written for the Open Policy Agent also works for kelon. There fore it is always advisable to have a look at the official OPA-contrib repository first. Please note that you may have to change the data format which is used to post the data to Kelon!

Spring Boot

You can find an already existing implementation of an AccessDecisionVoter which can easily be integrated into existing Spring applicaitons here. Please note that you may have to change the data format which is used to post the data to Kelon!

Dart

There is also an implementation for Dart applications. Please note that you may have to change the data format which is used to post the data to Kelon!

Golang

An example with golang is avaliable here. Please note that you may have to change the data format which is used to post the data to Kelon!

Python

An example with python can be found here. Please note that you may have to change the data format which is used to post the data to Kelon!