Giter Site home page Giter Site logo

armujahid / tyk-grpc-go-mongo-accesstoken Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 78 KB

TYK gRPC auth plugin that verifies access token validity in mongo

License: MIT License

Shell 1.44% Dockerfile 10.16% Go 88.40%
grpc mongodb plugin tyk tyk-gatewy loopback loopback3 api-gateway

tyk-grpc-go-mongo-accesstoken's Introduction

How to start gRPC server:

cp .env.example .env

modify .env

docker-compose up --build

Tyk configurations:

  1. tyk.conf:
"coprocess_options": {
  "enable_coprocess": true,
  "coprocess_grpc_server": "tcp://host.docker.internal:9111"
},

ensure that tyk can reach the gRPC server

  1. Use apidef.json in tyk

Example DB config

Create a collection in mongo with this object (I have tested this with Loopback 3 AccessToken model which already has compatible schema)

{
  "_id":"asdfasdfasdf32dsafdasdfas",
  "ttl":1209600,
  "created":"2022-08-30T09:20:20.910+00:00"
}

Testing:

curl -s 'http://localhost:8082/mongo-auth/get' -H "Authorization: asdfasdfasdf32dsafdasdfas"

Output if token is valid:

{
  "args": {}, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "gzip", 
    "Authorization": "asdfasdfasdf32dsafdasdfas", 
    "Host": "httpbin.org", 
    "User-Agent": "curl/7.81.0", 
    "X-Amzn-Trace-Id": "Root=1-6315b555-4a26f3f923cde5aa3f596b6f"
  }, 
  "origin": "172.28.0.1, <external ip>", 
  "url": "http://httpbin.org/get"
}

Output if token is invalid:

{
    "error": "Access forbidden"
}

tyk-grpc-go-mongo-accesstoken's People

Contributors

armujahid avatar

Stargazers

 avatar

Watchers

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