A single proxy server to authenticate requests to multiple internal APIs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
2.4 KiB

6 years ago
8 years ago
  1. # Guardian API Auth Proxy #
  2. A single proxy server to authenticate requests to multiple internal APIs. Experimenting with using Node.js as a single point of entry to access internal APIs. The idea being you have _a single_ entry point so APIs can remain inaccessible to the outside world and you only have to edit a single point when making security enhancements. Individual APIs are secured by having to pass a `client_id`, `username`, and `password` along with the request. This is validated early in the request.
  3. Added benefits include:
  4. * A single database change to the `client_id` and you have re-secured access, if for some reason a malicious intent is discovered. At that point, the method of entry can be addressed, and new `client_id`s can be distributed (typically in the form of an app update).
  5. * In the use-case of mobile apps, changing the `client_id` can also be detected, and this can be the basis for forcing an app update (i.e. trigger a popup to download new version from app store).
  6. * Logging API traffic is now made *super simple* and analytics become a natural/inherent part of this service.
  7. * And a lot more...
  8. An example of how this is intended to work is as follows:
  9. * Let's say we have an API that returns a list of books when we navigate to http://example.com/api/books.
  10. * We associate a `client_id` of `bookapiv01` to the base url above in a database (in real world use, this should be a completely random generated string so as not to be guessable).
  11. * Our "guardian" service is setup at https://guardian.serverexample.com/.
  12. * We send a post request to our new guardian server (including the uri string) which includes the following:
  13. * `https://guardian.serverexample.com/api/books` is the url
  14. * `client_id = booksapiv01`
  15. * `username = allowedusername`
  16. * `password = reallysecurepw`
  17. * `_method = GET` (optional)
  18. * `params = {"author":"bill"}` (optional)
  19. * The resulting response is the list of books as if we queried the API directly. Only we successfully authenticated the request and have all the benefits mentioned above.
  20. * Version 0.0.1 (the alpha's alpha)
  21. ### Installation ###
  22. * `git clone git@github.com:leothelocust/guardian-api-proxy.git`
  23. * `npm install`
  24. * `node` or `nodemon app.js`
  25. * Voila! It workie.
  26. ### Contribution guidelines ###
  27. * Write tests
  28. * Then code
  29. * Code review
  30. * 4 spaces (no tabs)
  31. * Submit pull request
  32. ### Contact ###
  33. * Levi Olson <leothelocust> on Github