Giter VIP home page Giter VIP logo

poc-tyk-gateway's Introduction

POC API Gateway with Tyk

This POC is based on this medium article: Get Started With Tyk API Gateway.

Setup

docker-compose up -d

Configuration

In docker-compose.yml, you can set the Tyk secret editing the TYK_GW_SECRET environment entry (a value is already available but you can change it).

All the endpoints proxied by Tyk are available in json files inside .docker/data/gateway/apps. The file httpbin.json is an example of how to proxy httpbin.org. If you modify this file or add a new one, remember to notify Tyk to reload configurations (see how below).

Testing and using

  • Reload API Gateway configuration:

    http :8080/tyk/reload 'x-tyk-authorization:6cf68f93-f6d9-4a96-9ed1-68632a6e448e'
    

    or

    curl http://localhost:8080/tyk/reload -H 'x-tyk-authorization:6cf68f93-f6d9-4a96-9ed1-68632a6e448e'
    
  • Verify that the API Gateway is up and running:

    http :8080/hello
    

    or

    curl http://localhost:8080/hello
    
  • Request proxied httpbin.org:

    http :8080/httpbin/get
    

    or

    curl http://localhost:8080/httpbin/get
    
  • Request token authenticaded proxied httpbin.org:

    Request an authentication token

    cat .docker/data/request/session-token.json | http post :8080/tyk/keys 'x-tyk-authorization:6cf68f93-f6d9-4a96-9ed1-68632a6e448e'
    

    With the token (copy the value from "key" entry), request:

    http :8080/httpbin/bearer/get 'Authorization: <token>'
    
  • Request basic authenticaded proxied httpbin.org:

    Request an user session:

    cat .docker/data/request/basic-session-token.json | http post :8080/tyk/keys/a-user 'x-tyk-authorization:6cf68f93-f6d9-4a96-9ed1-68632a6e448e'
    

    Request with basic auth

    http :8080/httpbin/basic/get --auth a-user:a-very-secure-password
    

poc-tyk-gateway's People

Contributors

rpopuc 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.