Coder Social home page Coder Social logo

r2dedios / api-gator-dora-router Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rhecosystemappeng/api-gator-dora-router

0.0 0.0 0.0 40 KB

This repo contains a HTTP proxy for managing interactions between several APIGator instances for DORA regulation

License: Apache License 2.0

Makefile 7.22% Go 84.23% Dockerfile 3.28% Shell 5.28%

api-gator-dora-router's Introduction

Exate APIGator Dora Router

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.

How it works

The APIGatorDoraRouter follows the next steps for every incoming request:

  1. Loads the list of available APIGator instances and its properties from a INI config file
  2. Receive HTTP request from the Requester.
  3. Forwards the HTTP request to every configured APIGator.
    1. If there is no access token available for a specific APIGator instance, or it's expired, obtains a new one and continues.
    2. Sends the HTTP request to every APIGator instance (Multithreading)
    3. Waits for every APIGator response.
    4. Processes the responses looking for a correct one
    5. Based on configuration, this router will use different strategies for choosing the correct response. Check
    6. If a correct response was found, returns its content as the response for the requester who started the process.

Configuration

Response Evaluation method

Currently there are two supported ways for choosing the "best" response on the APIGatorDoraRouter:

  1. 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'

  2. 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'

Running on Local

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

Building

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

Deployment on Openshift

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

Code Docs

For generating docs about the code, use the following command:

make docs

Testing

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

Demo

This repo includes a script for demoing how the APIGatorDoraRouter works. Check this document for more info.

License

This software is released and distributed under the Apache 2.0 License.

Maintainers:

api-gator-dora-router's People

Contributors

r2dedios avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.