Giter Club home page Giter Club logo

proxy's Introduction

Build Status

Proxy

API Proxy server that is hosted at https://api.flow.io

Main features:

  • Resolves an incoming path to a backend application (e.g. /users => 'user' application)
  • Authorizes the API token if present via the Authorization header (basic auth)
  • Authorizes the Bearer token if present (JWT)
  • If the path contains an :organization prefix, verifies that the user is a member of said org. This also verifies that the organization prefix is valid.
  • Inject X-Flow-Auth header containing all of the data verified, including user id, organization and membership role when checked
  • Implements optional configuration of independent thread pools for each backend service (catalog service has one thread pool)
  • Any path that starts with /internal is treated as internal to Flow. Validates that the provided API Key is valid for the flow organization
  • Implements JSONP proxy based on presence of url parameter named 'callback' and optional parameter named 'method' that is used to specify the HTTP method to use when proxying request to the backend.
  • Implements all responses in an 'envelope' with HTTP 200 response codes based on presence of url parameter named 'envelope' with value 'response'
  • Support envelope=request query parameter that allows you to POST a JSON object that we will use to create the request
  • Converts www form urlencoded strings (body and query for JSONP) into form data, validating and converting types according to one or more API Builder schemas (via environment variable named APIBUILDER_SERVICE_URIS)

Bypassing proxy

We support manually configuring the behavior of the proxy on a per request basis via the following headers:

  • X-Flow-Host (e.g. http://localhost:6291) - if specified, we forward the request to this host

  • X-Flow-Service (e.g. 'organization') - if specified, we forward the request to this service

If you specify a header, you must also specify an Authorization header for a user that is a member of the 'flow' organization.

Future features:

  • Implement expansion by detecting 'expand' query parameters

  • Implement backwards compatibility layer by upgrading responses from the latest version of the API to the user's requested version

Internal URLs

Healthcheck

http://localhost:7000/_internal_/healthcheck

Diagnostics

http://localhost:7000/_internal_/diagnostics

View current configuration, including all services and routes:

http://localhost:7000/_internal_/config

Example configuration files

environment variable example value
PROXY_CONFIG_URIS https://s3.amazonaws.com/io.flow.aws-s3-public/util/api-proxy/latest/development.config.yml
APIBUILDER_SERVICE_URIS https://s3.amazonaws.com/io.flow.aws-s3-public/util/api-proxy/latest/api.service.json
JWT_SALT test

Multiple URIS can be provided as a single, comma-separated string.

Learn more about API Builder

Resolve a route

http://localhost:7000/_internal_/route

Tests

In order to run the unit tests, the above environment variables need to be specified, eg:

APIBUILDER_SERVICE_URIS=https://s3.amazonaws.com/io.flow.aws-s3-public/util/api-proxy/latest/api.service.json PROXY_CONFIG_URIS=https://s3.amazonaws.com/io.flow.aws-s3-public/util/api-proxy/latest/development.config.yml JWT_SALT=test sbt test

proxy's People

Contributors

mbryzek avatar mikeclimbrock avatar jlogeart avatar darrenmc avatar gheine avatar ericluria avatar jpkeanu avatar sullis avatar ninjabem avatar amcguiga avatar juwen-z avatar roryh avatar benwaffle avatar plippe avatar rbern avatar gupta-himanshu avatar dasmb avatar

Watchers

 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.