This repository contains an HTTP proxy that receives an HTTP request from an APIGator by Exate instance, forwards it to a list of APIGator instances, waits for their responses, and filters the correct one to return it to the original requester.
This behavior is designed to process information that may belong to other countries and, depending on the laws and regulations of those countries, may be shared or not under specific conditions. Every APIGator instance assigned to a country must comply with the laws of the country in which it is configured. Since the requester is not aware of every law, this proxy will take the request, forward it to every APIGator instance, and retrieve the correct response if it exists.
This component was designed for running on container environmnets (K8s/Openshift) as a Stateless component.
The APIGatorDoraRouter follows the next steps for every incoming request:
- Loads the list of available APIGator instances and its properties from a INI config file
- Receive HTTP request from the Requester.
- Forwards the HTTP request to every configured APIGator.
- If there is no access token available for a specific APIGator instance, or it's expired, obtains a new one and continues.
- Sends the HTTP request to every APIGator instance (Multithreading)
- Waits for every APIGator response.
- Processes the responses looking for a correct one
- Based on configuration, this router will use different strategies for choosing the correct response. Check
- If a correct response was found, returns its content as the response for the requester who started the process.
Currently there are two supported ways for choosing the "best" response on the APIGatorDoraRouter:
-
First valid response. This method will return the first response with a correct data structure. Example:
{ "dataSet": "{\n \"employees\": {\n \"employee\": […]\n }\n}" }
To choose this method, edit the
config.ini
file on `[router].score_function='basic' -
DataSet with more fields decrypted. This method will choose the response based on which one has more decrypted information by APIGator. It takes the
restricted_text
field for identifying the crypted fields, and scores each response. The one with higher score (less crypted data) will be returned.To choose this method, edit the
config.ini
file on `[router].score_function='percentage'
For an fast try on local, use the Makefile for starting the DoraRouter:
# Starts on normal mode
make start
# Starts on DEBUG mode for more verbose output
make start-debug
Every option for building and running this software is already defined on the Makefile:
# Building container image
make build-image
# Pushing container image
make push
The manifests for deploying the APIGator Dora Router on Openshift are available
on: ./manifests/deployment
oc new-project exate-dora-router
CONFIG_FILE=<YOUR_CONFIG_FILE ENV FILE>
oc create configmap dora-router-config --from-file=$CONFIG_FILE
oc apply -f ./manifests/dora-router
For generating docs about the code, use the following command:
make docs
There is a scripts
folder on this repo which contains several scripts for
testing this component and its interaction with APIGator
Test script for APIGator:
# Generic command
bash ./scripts/test_gator.sh <APIGATOR_URL> <API_KEY> <CLIENT_ID> <CLIENT_SECRET> <PAYLOAD_FILE>
Test script for APIGatorDoraRouter:
# Generic command
bash ./scripts/test_router.sh <ROUTER_URL> <PAYLOAD_FILE>
# Example command
bash ./scripts/test_router.sh http://localhost:8080/forward ./tests/payload_example.json
This repo includes a script for demoing how the APIGatorDoraRouter works. Check this document for more info.
This software is released and distributed under the Apache 2.0 License.
- Alejandro Villegas ([email protected])